Fix memory leak caused by minimizing to tray

This commit is contained in:
0xb00bface 2021-06-21 20:39:55 +02:00
parent 5d3b8e2790
commit adbb1bd562
3 changed files with 22 additions and 1 deletions

View File

@ -1,6 +1,10 @@
4.4.2
========================
* Fixed memory leak caused by minimizing to tray
4.4.1
========================
* Fix camsoda stream URLs
* Fixed camsoda stream URLs
4.4.0
========================

View File

@ -151,6 +151,14 @@ public class CamrecApplication extends Application {
LOG.error(ex.getMessage(), ex);
}
}
if (Objects.equals("stage_restored", evt.get("event"))) {
LOG.debug("Main stage restored");
Platform.runLater(() -> {
if (tabPane.getSelectionModel().getSelectedItem() instanceof TabSelectionListener) {
((TabSelectionListener) tabPane.getSelectionModel().getSelectedItem()).selected();
}
});
}
}
});
}
@ -289,8 +297,16 @@ public class CamrecApplication extends Application {
primaryStage.iconifiedProperty().addListener((obs, oldV, newV) -> {
if (newV.booleanValue() && Config.getInstance().getSettings().minimizeToTray && primaryStage.isShowing()) {
DesktopIntegration.minimizeToTray(primaryStage);
suspendTabUpdates();
}
});
}
private void suspendTabUpdates() {
tabPane.getTabs().stream()
.filter(TabSelectionListener.class::isInstance)
.forEach(t -> ((TabSelectionListener)t).deselected());
}
private javafx.event.EventHandler<WindowEvent> createShutdownHandler() {

View File

@ -262,6 +262,7 @@ public class DesktopIntegration {
stage.setIconified(false);
stage.show();
stage.toFront();
EventBusHolder.BUS.post(Map.of("event", "stage_restored"));
});
}