diff --git a/lib/cwtch/cwtch.dart b/lib/cwtch/cwtch.dart index 1cc06e22..b19d0f72 100644 --- a/lib/cwtch/cwtch.dart +++ b/lib/cwtch/cwtch.dart @@ -156,4 +156,6 @@ abstract class Cwtch { void DeleteServerInfo(String profile, String handle); void PublishServerUpdate(String onion); Future ConfigureConnections(String onion, bool listen, bool peers, bool servers); + + bool IsLoaded(); } diff --git a/lib/cwtch/ffi.dart b/lib/cwtch/ffi.dart index aeb81df9..059ff55d 100644 --- a/lib/cwtch/ffi.dart +++ b/lib/cwtch/ffi.dart @@ -268,6 +268,8 @@ class CwtchFfi implements Cwtch { // Called on object being disposed to (presumably on app close) to close the isolate that's listening to libcwtch-go events @override void dispose() { + EnvironmentConfig.debugLog("tearing down cwtch FFI isolate"); + library.close(); cwtchIsolate.kill(priority: Isolate.immediate); } @@ -1121,4 +1123,11 @@ class CwtchFfi implements Cwtch { PublishServerUpdate(utf8profile, utf8profile.length); malloc.free(utf8profile); } + + @override + bool IsLoaded() { + bool check = library.providesSymbol("c_UpdateSettings"); + EnvironmentConfig.debugLog("Checking that the FFI Interface is Correctly Loaded... $check"); + return check; + } } diff --git a/lib/cwtch/gomobile.dart b/lib/cwtch/gomobile.dart index 4e9804f0..3eca7ecd 100644 --- a/lib/cwtch/gomobile.dart +++ b/lib/cwtch/gomobile.dart @@ -469,4 +469,9 @@ class CwtchGomobile implements Cwtch { void PublishServerUpdate(String profile) { cwtchPlatform.invokeMethod("PublishServerUpdate", {"ProfileOnion": profile}); } + + @override + bool IsLoaded() { + return true; + } } diff --git a/lib/main.dart b/lib/main.dart index d58ef0b7..45dd4b64 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -173,6 +173,10 @@ class FlwtchState extends State with WindowListener { getServerListStateProvider(), ], builder: (context, widget) { + // in test mode...rebuild everything every second...if cwtch isn't loaded... + if (EnvironmentConfig.TEST_MODE && cwtch.IsLoaded() == false) { + Timer t = new Timer.periodic(Duration(seconds: 1), (Timer t) => setState(() {})); + } return Consumer2( builder: (context, settings, appState, child) => MaterialApp( key: Key('app'), @@ -190,7 +194,7 @@ class FlwtchState extends State with WindowListener { title: 'Cwtch', showSemanticsDebugger: settings.useSemanticDebugger, theme: mkThemeData(settings), - home: (!appState.cwtchInit || appState.modalState != ModalState.none) ? SplashView() : ProfileMgrView(), + home: (!appState.cwtchInit || appState.modalState != ModalState.none) || !cwtch.IsLoaded() ? SplashView() : ProfileMgrView(), ), ); }, diff --git a/lib/views/globalsettingsview.dart b/lib/views/globalsettingsview.dart index 2a6062cc..69829d6f 100644 --- a/lib/views/globalsettingsview.dart +++ b/lib/views/globalsettingsview.dart @@ -83,7 +83,7 @@ class _GlobalSettingsViewState extends State { } Widget _buildSettingsList() { - return Consumer(builder: (context, settings, child) { + return Consumer(builder: (ccontext, settings, child) { return LayoutBuilder(builder: (BuildContext context, BoxConstraints viewportConstraints) { var appIcon = Icon(Icons.info, color: settings.current().mainTextColor); return Scrollbar(