Properly shutdown everything on window close

- Properly shutdown applet on window close
- Properly remove system tray icon on close
- Shutdown executorService on shutdown

Signed-off-by: Tomas Slusny <slusnucky@gmail.com>
This commit is contained in:
Tomas Slusny
2018-07-30 13:54:01 +02:00
parent 4a3fcd2f45
commit 69a6092eb7
2 changed files with 21 additions and 0 deletions

View File

@@ -35,6 +35,7 @@ import java.io.File;
import java.lang.management.ManagementFactory;
import java.lang.management.RuntimeMXBean;
import java.util.Locale;
import java.util.concurrent.ScheduledExecutorService;
import javax.annotation.Nullable;
import javax.inject.Provider;
import javax.inject.Singleton;
@@ -111,6 +112,9 @@ public class RuneLite
@Inject
private OverlayManager overlayManager;
@Inject
private ScheduledExecutorService executorService;
@Inject
private Provider<ItemManager> itemManager;
@@ -294,6 +298,7 @@ public class RuneLite
{
clientSessionManager.shutdown();
discordService.close();
executorService.shutdown();
}
@VisibleForTesting

View File

@@ -36,6 +36,7 @@ import java.awt.Graphics;
import java.awt.GraphicsConfiguration;
import java.awt.LayoutManager;
import java.awt.Rectangle;
import java.awt.SystemTray;
import java.awt.TrayIcon;
import java.awt.image.BufferedImage;
import javax.annotation.Nullable;
@@ -267,6 +268,21 @@ public class ClientUI
{
saveClientBoundsConfig();
runelite.shutdown();
if (SystemTray.isSupported())
{
SystemTray.getSystemTray().remove(trayIcon);
}
if (client != null)
{
client.stop();
}
if (client instanceof Client)
{
((Client)client).shutDown();
}
},
this::showWarningOnExit
);