fix: linux memory-safe workaround

Signed-off-by: Kingtous <kingtous@qq.com>
This commit is contained in:
Kingtous 2022-08-30 16:45:47 +08:00
parent 8858d0342d
commit 66a2c51ca5
8 changed files with 21 additions and 46 deletions

View File

@ -9,8 +9,6 @@ import 'package:flutter_hbb/desktop/widgets/tabbar_widget.dart';
import 'package:flutter_hbb/utils/multi_window_manager.dart';
import 'package:get/get.dart';
import '../../models/model.dart';
class ConnectionTabPage extends StatefulWidget {
final Map<String, dynamic> params;
@ -73,14 +71,7 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
fullscreen.isTrue ? 0 : kDesktopRemoteTabBarHeight,
))));
} else if (call.method == "onDestroy") {
tabController.state.value.tabs.forEach((tab) {
print("executing onDestroy hook, closing ${tab.label}}");
final tag = tab.label;
ffi(tag).close().then((_) {
Get.delete<FFI>(tag: tag);
});
});
Get.back();
tabController.state.value.tabs.clear();
}
});
}
@ -116,9 +107,8 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
}
void onRemoveId(String id) {
ffi(id).close();
if (tabController.state.value.tabs.length == 0) {
WindowController.fromWindowId(windowId()).close();
if (tabController.state.value.tabs.isEmpty) {
WindowController.fromWindowId(windowId()).hide();
}
}

View File

@ -5,7 +5,6 @@ import 'package:flutter/material.dart';
import 'package:flutter_hbb/common.dart';
import 'package:flutter_hbb/desktop/pages/file_manager_page.dart';
import 'package:flutter_hbb/desktop/widgets/tabbar_widget.dart';
import 'package:flutter_hbb/models/model.dart';
import 'package:flutter_hbb/utils/multi_window_manager.dart';
import 'package:get/get.dart';
@ -42,7 +41,7 @@ class _FileManagerTabPageState extends State<FileManagerTabPage> {
rustDeskWinManager.setMethodHandler((call, fromWindowId) async {
print(
"call ${call.method} with args ${call.arguments} from window ${fromWindowId}");
"call ${call.method} with args ${call.arguments} from window ${fromWindowId} to ${windowId()}");
// for simplify, just replace connectionId
if (call.method == "new_file_transfer") {
final args = jsonDecode(call.arguments);
@ -55,21 +54,15 @@ class _FileManagerTabPageState extends State<FileManagerTabPage> {
unselectedIcon: unselectedIcon,
page: FileManagerPage(key: ValueKey(id), id: id)));
} else if (call.method == "onDestroy") {
tabController.state.value.tabs.forEach((tab) {
print("executing onDestroy hook, closing ${tab.label}}");
final tag = 'ft_${tab.label}';
ffi(tag).close().then((_) {
Get.delete<FFI>(tag: tag);
});
});
Get.back();
tabController.state.value.tabs.clear();
}
});
}
@override
Widget build(BuildContext context) {
final theme = isDarkTheme() ? TarBarTheme.dark() : TarBarTheme.light();
final theme =
isDarkTheme() ? const TarBarTheme.dark() : const TarBarTheme.light();
return SubWindowDragToResizeArea(
windowId: windowId(),
child: Container(
@ -90,9 +83,8 @@ class _FileManagerTabPageState extends State<FileManagerTabPage> {
}
void onRemoveId(String id) {
ffi("ft_$id").close();
if (tabController.state.value.tabs.length == 0) {
WindowController.fromWindowId(windowId()).close();
if (tabController.state.value.tabs.isEmpty) {
WindowController.fromWindowId(windowId()).hide();
}
}

View File

@ -5,7 +5,6 @@ import 'package:flutter/material.dart';
import 'package:flutter_hbb/common.dart';
import 'package:flutter_hbb/desktop/pages/port_forward_page.dart';
import 'package:flutter_hbb/desktop/widgets/tabbar_widget.dart';
import 'package:flutter_hbb/models/model.dart';
import 'package:flutter_hbb/utils/multi_window_manager.dart';
import 'package:get/get.dart';
@ -44,7 +43,7 @@ class _PortForwardTabPageState extends State<PortForwardTabPage> {
tabController.onRemove = (_, id) => onRemoveId(id);
rustDeskWinManager.setMethodHandler((call, fromWindowId) async {
print(
debugPrint(
"call ${call.method} with args ${call.arguments} from window ${fromWindowId}");
// for simplify, just replace connectionId
if (call.method == "new_port_forward") {
@ -59,14 +58,7 @@ class _PortForwardTabPageState extends State<PortForwardTabPage> {
unselectedIcon: unselectedIcon,
page: PortForwardPage(id: id, isRDP: isRDP)));
} else if (call.method == "onDestroy") {
tabController.state.value.tabs.forEach((tab) {
print("executing onDestroy hook, closing ${tab.label}}");
final tag = 'pf_${tab.label}';
ffi(tag).close().then((_) {
Get.delete<FFI>(tag: tag);
});
});
Get.back();
tabController.state.value.tabs.clear();
}
});
}
@ -95,8 +87,8 @@ class _PortForwardTabPageState extends State<PortForwardTabPage> {
void onRemoveId(String id) {
ffi("pf_$id").close();
if (tabController.state.value.tabs.length == 0) {
WindowController.fromWindowId(windowId()).close();
if (tabController.state.value.tabs.isEmpty) {
WindowController.fromWindowId(windowId()).hide();
}
}

View File

@ -6,8 +6,8 @@ import 'package:flutter_hbb/common.dart';
import 'package:flutter_hbb/consts.dart';
import 'package:flutter_hbb/main.dart';
import 'package:get/get.dart';
import 'package:window_manager/window_manager.dart';
import 'package:scroll_pos/scroll_pos.dart';
import 'package:window_manager/window_manager.dart';
import '../../utils/multi_window_manager.dart';
@ -323,7 +323,8 @@ class WindowActionPanel extends StatelessWidget {
if (mainTab) {
windowManager.close();
} else {
WindowController.fromWindowId(windowId!).close();
// only hide for multi window, not close
WindowController.fromWindowId(windowId!).hide();
}
},
is_close: true,

View File

@ -1110,7 +1110,7 @@ class FFI {
ffiModel.clear();
canvasModel.clear();
resetModifiers();
print("model closed");
debugPrint("model $id closed");
}
/// Send **get** command to the Rust core based on [name] and [arg].

View File

@ -163,7 +163,7 @@ class RustDeskMultiWindowManager {
// no such window already
return;
}
await WindowController.fromWindowId(wId).close();
await WindowController.fromWindowId(wId).hide();
} on Error {
return;
}

View File

@ -252,8 +252,8 @@ packages:
dependency: "direct main"
description:
path: "."
ref: "14a001e83ab0e7c8cb119f7f65be4e3056a954fb"
resolved-ref: "14a001e83ab0e7c8cb119f7f65be4e3056a954fb"
ref: e0368a023ba195462acc00d33ab361b499f0e413
resolved-ref: e0368a023ba195462acc00d33ab361b499f0e413
url: "https://github.com/Kingtous/rustdesk_desktop_multi_window"
source: git
version: "0.1.0"

View File

@ -65,7 +65,7 @@ dependencies:
desktop_multi_window:
git:
url: https://github.com/Kingtous/rustdesk_desktop_multi_window
ref: 14a001e83ab0e7c8cb119f7f65be4e3056a954fb
ref: e0368a023ba195462acc00d33ab361b499f0e413
freezed_annotation: ^2.0.3
tray_manager:
git: