Small reliability fixes

This commit is contained in:
crschnick 2024-08-04 02:53:55 +00:00
parent 675fb6972a
commit a26917b500
3 changed files with 13 additions and 6 deletions

View file

@ -79,7 +79,7 @@ public class BrowserQuickAccessContextMenu extends ContextMenu {
getItems().addAll(r.getItems()); getItems().addAll(r.getItems());
// Prevent NPE in show() // Prevent NPE in show()
if (getScene() == null) { if (getScene() == null || anchor == null) {
return; return;
} }
show(anchor, Side.RIGHT, 0, 0); show(anchor, Side.RIGHT, 0, 0);

View file

@ -113,6 +113,9 @@ public class AppTheme {
} }
}); });
}); });
} catch (UnsupportedOperationException ex) {
// The platform preferences are sometimes not initialized yet
ErrorEvent.fromThrowable(ex).expected().omit().handle();
} catch (Throwable t) { } catch (Throwable t) {
ErrorEvent.fromThrowable(t).omit().handle(); ErrorEvent.fromThrowable(t).omit().handle();
} }
@ -136,6 +139,9 @@ public class AppTheme {
} else { } else {
AppPrefs.get().theme.setValue(Theme.getDefaultLightTheme()); AppPrefs.get().theme.setValue(Theme.getDefaultLightTheme());
} }
} catch (UnsupportedOperationException ex) {
// The platform preferences are sometimes not initialized yet
ErrorEvent.fromThrowable(ex).expected().omit().handle();
} catch (Exception ex) { } catch (Exception ex) {
// The color scheme query can fail if the toolkit is not initialized properly // The color scheme query can fail if the toolkit is not initialized properly
AppPrefs.get().theme.setValue(Theme.getDefaultLightTheme()); AppPrefs.get().theme.setValue(Theme.getDefaultLightTheme());

View file

@ -15,14 +15,15 @@ public class AppUserDirectoryCheck {
Files.createDirectories(dataDirectory); Files.createDirectories(dataDirectory);
var testDirectory = dataDirectory.resolve("permissions_check"); var testDirectory = dataDirectory.resolve("permissions_check");
Files.createDirectories(testDirectory); Files.createDirectories(testDirectory);
if (!Files.exists(testDirectory)) {
throw new IOException("Directory creation in user home directory failed silently");
}
Files.delete(testDirectory); Files.delete(testDirectory);
// if (true) throw new IOException(); // if (true) throw new IOException();
} catch (IOException e) { } catch (IOException e) {
ErrorEvent.fromThrowable( ErrorEvent.fromThrowable("Unable to access directory " + dataDirectory
new IOException(
"Unable to access directory " + dataDirectory
+ ". Please make sure that you have the appropriate permissions and no Antivirus program is blocking the access. " + ". Please make sure that you have the appropriate permissions and no Antivirus program is blocking the access. "
+ "In case you use cloud storage, verify that your cloud storage is working and you are logged in.")) + "In case you use cloud storage, verify that your cloud storage is working and you are logged in.", e)
.term() .term()
.expected() .expected()
.handle(); .handle();