Skip to content

Commit

Permalink
Small changes to fix a freezing UI on Ubuntu.
Browse files Browse the repository at this point in the history
  • Loading branch information
dlemmermann committed Sep 15, 2023
1 parent 13930bd commit d0fc6b3
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public void start(Stage stage) {
routeNode.start(sessionManager);

// tray icon
if (!WebAPI.isBrowser()) {
if (!WebAPI.isBrowser() && SystemTray.isSupported()) {
RepositoryManager.repositoryUpdatedProperty().addListener(it -> {
if (trayIconManager == null) {
trayIconManager = new TrayIconManager(stage, sessionManager);
Expand All @@ -147,7 +147,9 @@ public void start(Stage stage) {
// customs stage for decorations / the chrome
CustomStage customStage = new CustomStage(stage, routeNode, sessionManager);
customStage.setCloseHandler(() -> {
trayIconManager.hide();
if (SystemTray.isSupported()) {
trayIconManager.hide();
}
stage.close();
});

Expand All @@ -160,6 +162,7 @@ public void start(Stage stage) {
updateSizeProperty(scene);

stage.setScene(scene);
stage.setFullScreenExitHint("");

// do not store stage width, height, location when we are running in a browser
if (!WebAPI.isBrowser()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public static void updateRepository(ProgressMonitor monitor) {
if (!isRepositoryUpdated()) {
try {
initialLoad(monitor);
Platform.runLater(() -> repositoryUpdated.set(true));
repositoryUpdated.set(true);
} catch (Exception e) {
LOGGER.error("Failed to update the repository", e);
}
Expand All @@ -54,8 +54,10 @@ public static boolean isFirstTimeSetup() {
private static void initialLoad(ProgressMonitor monitor) throws Exception {
// Network not available, skip the initial load
if (!isNetworkAvailable()) {
monitor.beginTask("Network not available.", 1);
monitor.endTask();
Platform.runLater(() -> {
monitor.beginTask("Network not available.", 1);
monitor.endTask();
});
return;
}

Expand All @@ -64,9 +66,11 @@ private static void initialLoad(ProgressMonitor monitor) throws Exception {
String repoUrl = GITHUB_REPOSITORY_URL;

if (isCountryEqualToChina()) {
monitor.beginTask("Checking network...", 1);
repoUrl = shouldUseGiteeMirror() ? GITEE_REPOSITORY_URL : GITHUB_REPOSITORY_URL;
monitor.endTask();
Platform.runLater(() -> {
monitor.beginTask("Checking network...", 1);
monitor.endTask();
});
}

CloneCommand cloneCmd = Git.cloneRepository()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@

public class RefreshPage extends PageBase {

/**
* The invalidation listener is called from the RepositoryManager thread,
* so any changes done to the UI must be in Platform.runLater.
*/
private final InvalidationListener invalidationListener = it -> {
if (RepositoryManager.isRepositoryUpdated()) {
Platform.runLater(() -> {
Expand Down

0 comments on commit d0fc6b3

Please sign in to comment.