opt: enable debug stacktrace output & add json serde check

This commit is contained in:
Kingtous 2022-12-09 10:49:47 +08:00
parent d5a93adbf0
commit d3d4c7dac4
7 changed files with 22 additions and 20 deletions

View File

@ -1013,7 +1013,7 @@ class LastWindowPosition {
return LastWindowPosition(m["width"], m["height"], m["offsetWidth"], return LastWindowPosition(m["width"], m["height"], m["offsetWidth"],
m["offsetHeight"], m["isMaximized"]); m["offsetHeight"], m["isMaximized"]);
} catch (e) { } catch (e) {
debugPrint(e.toString()); debugPrintStack(label: e.toString());
return null; return null;
} }
} }
@ -1147,7 +1147,7 @@ Future<bool> restoreWindowPosition(WindowType type, {int? windowId}) async {
final pos = bind.getLocalFlutterConfig(k: kWindowPrefix + type.name); final pos = bind.getLocalFlutterConfig(k: kWindowPrefix + type.name);
var lpos = LastWindowPosition.loadFromString(pos); var lpos = LastWindowPosition.loadFromString(pos);
if (lpos == null) { if (lpos == null) {
debugPrint("window position saved, but cannot be parsed"); debugPrint("no window position saved, ignoring position restoration");
return false; return false;
} }
@ -1212,7 +1212,7 @@ Future<void> initUniLinks() async {
} }
parseRustdeskUri(initialLink); parseRustdeskUri(initialLink);
} catch (err) { } catch (err) {
debugPrint("$err"); debugPrintStack(label: "$err");
} }
} }
@ -1422,7 +1422,7 @@ void onActiveWindowChanged() async {
rustDeskWinManager.closeAllSubWindows() rustDeskWinManager.closeAllSubWindows()
]); ]);
} catch (err) { } catch (err) {
debugPrint("$err"); debugPrintStack(label: "$err");
} finally { } finally {
await windowManager.setPreventClose(false); await windowManager.setPreventClose(false);
await windowManager.close(); await windowManager.close();

View File

@ -79,16 +79,19 @@ class _PeerTabPageState extends State<PeerTabPage>
.toList() .toList()
.obs; .obs;
try { try {
final json = jsonDecode(bind.getLocalFlutterConfig(k: 'peer-tab-order')); final conf = bind.getLocalFlutterConfig(k: 'peer-tab-order');
if (json is List) { if (conf.isNotEmpty) {
final List<String> list = json.map((e) => e.toString()).toList(); final json = jsonDecode(conf);
if (list.length == visibleOrderedTabs.length && if (json is List) {
visibleOrderedTabs.every((e) => list.contains(e))) { final List<String> list = json.map((e) => e.toString()).toList();
visibleOrderedTabs.value = list; if (list.length == visibleOrderedTabs.length &&
visibleOrderedTabs.every((e) => list.contains(e))) {
visibleOrderedTabs.value = list;
}
} }
} }
} catch (e) { } catch (e) {
debugPrint('$e'); debugPrintStack(label: '$e');
} }
adjustTab(); adjustTab();

View File

@ -63,7 +63,7 @@ class DesktopSettingPage extends StatefulWidget {
DesktopTabPage.onAddSetting(initialPage: page); DesktopTabPage.onAddSetting(initialPage: page);
} }
} catch (e) { } catch (e) {
debugPrint('$e'); debugPrintStack(label: '$e');
} }
} }
} }

View File

@ -31,7 +31,7 @@ class DesktopTabPage extends StatefulWidget {
initialPage: initialPage, initialPage: initialPage,
))); )));
} catch (e) { } catch (e) {
debugPrint('$e'); debugPrintStack(label: '$e');
} }
} }
} }

View File

@ -460,7 +460,7 @@ Future<bool> loginDialog() async {
debugPrint('$resp'); debugPrint('$resp');
completer.complete(true); completer.complete(true);
} catch (err) { } catch (err) {
debugPrint(err.toString()); debugPrintStack(label: err.toString());
cancel(); cancel();
return; return;
} }

View File

@ -564,7 +564,7 @@ void androidChannelInit() {
} }
} }
} catch (e) { } catch (e) {
debugPrint("MethodCallHandler err:$e"); debugPrintStack(label: "MethodCallHandler err:$e");
} }
return ""; return "";
}); });

View File

@ -126,7 +126,7 @@ class PlatformFFI {
// no need to set home dir // no need to set home dir
} }
} catch (e) { } catch (e) {
debugPrint('initialize failed: $e'); debugPrintStack(label: 'initialize failed: $e');
} }
String id = 'NA'; String id = 'NA';
String name = 'Flutter'; String name = 'Flutter';
@ -151,9 +151,8 @@ class PlatformFFI {
WindowsDeviceInfo winInfo = await deviceInfo.windowsInfo; WindowsDeviceInfo winInfo = await deviceInfo.windowsInfo;
name = winInfo.computerName; name = winInfo.computerName;
id = winInfo.computerName; id = winInfo.computerName;
} catch (e, stacktrace) { } catch (e) {
debugPrint("get windows device info failed: $e"); debugPrintStack(label: "get windows device info failed: $e");
debugPrintStack(stackTrace: stacktrace);
name = "unknown"; name = "unknown";
id = "unknown"; id = "unknown";
} }
@ -174,7 +173,7 @@ class PlatformFFI {
await _ffiBind.mainSetHomeDir(home: _homeDir); await _ffiBind.mainSetHomeDir(home: _homeDir);
await _ffiBind.mainInit(appDir: _dir); await _ffiBind.mainInit(appDir: _dir);
} catch (e) { } catch (e) {
debugPrint('initialize failed: $e'); debugPrintStack(label: 'initialize failed: $e');
} }
version = await getVersion(); version = await getVersion();
} }