diff options
author | Lyubomir Marinov <lyubomir.marinov@jitsi.org> | 2008-12-13 16:58:22 +0000 |
---|---|---|
committer | Lyubomir Marinov <lyubomir.marinov@jitsi.org> | 2008-12-13 16:58:22 +0000 |
commit | 52465acd615afa2025bd58bc1d13b2ec85aaf54d (patch) | |
tree | 19d5d4d312ea9b41c1015410d5b18975589177e0 | |
parent | 64163a7fd4661e06acc5f7bd5959a267cfcb688d (diff) | |
download | jitsi-52465acd615afa2025bd58bc1d13b2ec85aaf54d.zip jitsi-52465acd615afa2025bd58bc1d13b2ec85aaf54d.tar.gz jitsi-52465acd615afa2025bd58bc1d13b2ec85aaf54d.tar.bz2 |
On Mac OS X, waits for the application to complete its normal shutdown instead of prematurely killing it. Additionally, leaves a single shutdown procedure and uses it for both File > Quit and the Close action of the systray menu.
6 files changed, 35 insertions, 45 deletions
diff --git a/src/net/java/sip/communicator/impl/gui/UIServiceImpl.java b/src/net/java/sip/communicator/impl/gui/UIServiceImpl.java index ffd1f5e..e343466 100644 --- a/src/net/java/sip/communicator/impl/gui/UIServiceImpl.java +++ b/src/net/java/sip/communicator/impl/gui/UIServiceImpl.java @@ -972,4 +972,25 @@ public class UIServiceImpl return (osName != null) && ((osName.indexOf("Mac OS X") != -1) || (osName.indexOf("Darwin") != -1)); } + + public void beginShutdown() + { + try + { + if (mainFrame != null) + mainFrame.dispose(); + } + finally + { + try + { + GuiActivator.bundleContext.getBundle(0).stop(); + } + catch (BundleException ex) + { + logger.error("Failed to being gentle shutdown of Felix.", ex); + System.exit(0); + } + } + } } diff --git a/src/net/java/sip/communicator/impl/gui/main/menus/FileMenu.java b/src/net/java/sip/communicator/impl/gui/main/menus/FileMenu.java index ff75d9a..d4700fa 100644 --- a/src/net/java/sip/communicator/impl/gui/main/menus/FileMenu.java +++ b/src/net/java/sip/communicator/impl/gui/main/menus/FileMenu.java @@ -23,8 +23,6 @@ import net.java.sip.communicator.impl.gui.utils.*; import net.java.sip.communicator.service.gui.UIService; import net.java.sip.communicator.util.*; -import org.osgi.framework.*; - /** * The <tt>FileMenu</tt> is a menu in the main application menu bar that * contains "New account". @@ -152,20 +150,7 @@ public class FileMenu void closeActionPerformed() { - parentWindow.dispose(); - - try { - GuiActivator.bundleContext.getBundle(0).stop(); - } catch (BundleException ex) { - logger.error("Failed to gently shutdown Felix", ex); - System.exit(0); - } - //stopping a bundle doesn't leave the time to the felix thread to - //properly end all bundles and call their Activator.stop() methods. - //if this causes problems don't uncomment the following line but - //try and see why felix isn't exiting (suggesting: is it running - //in embedded mode?) - //System.exit(0); + GuiActivator.getUIService().beginShutdown(); } private void registerCloseMenuItem() diff --git a/src/net/java/sip/communicator/impl/gui/main/menus/MacOSXQuitRegistration.java b/src/net/java/sip/communicator/impl/gui/main/menus/MacOSXQuitRegistration.java index f66a076..fe823c1 100644 --- a/src/net/java/sip/communicator/impl/gui/main/menus/MacOSXQuitRegistration.java +++ b/src/net/java/sip/communicator/impl/gui/main/menus/MacOSXQuitRegistration.java @@ -23,7 +23,14 @@ public final class MacOSXQuitRegistration public void handleQuit(ApplicationEvent event)
{
((FileMenu) userData).closeActionPerformed();
- event.setHandled(true);
+
+ /*
+ * Tell Mac OS X that it shouldn't terminate the
+ * application. We've already initiated the quit and we'll
+ * eventually complete it i.e. we'll honor the request of
+ * Mac OS X to quit.
+ */
+ event.setHandled(false);
}
});
return true;
diff --git a/src/net/java/sip/communicator/impl/systray/jdic/TrayMenuFactory.java b/src/net/java/sip/communicator/impl/systray/jdic/TrayMenuFactory.java index 8bc4dc2..94b7ce1 100644 --- a/src/net/java/sip/communicator/impl/systray/jdic/TrayMenuFactory.java +++ b/src/net/java/sip/communicator/impl/systray/jdic/TrayMenuFactory.java @@ -14,9 +14,6 @@ import javax.swing.event.*; import net.java.sip.communicator.impl.systray.*; import net.java.sip.communicator.service.gui.*; -import net.java.sip.communicator.util.*; - -import org.osgi.framework.*; /** * The <tt>TrayMenu</tt> is the menu that appears when the user right-click @@ -29,12 +26,6 @@ public final class TrayMenuFactory { /** - * The logger for this class. - */ - private static final Logger logger = - Logger.getLogger(TrayMenuFactory.class.getName()); - - /** * Handles the <tt>ActionEvent</tt> when one of the menu items is selected. * * @param evt the event containing the menu item name @@ -64,22 +55,7 @@ public final class TrayMenuFactory } else if (itemName.equals("service.gui.CLOSE")) { - - /* - * TODO Quitting the application has evolved to resolve additional - * issues such as storing the configuration prior to disposing the - * MainFrame so this old copy here doesn't have them. - */ - try - { - SystrayActivator.bundleContext.getBundle(0).stop(); - } - catch (BundleException ex) - { - logger.error("Failed to gently shutdown Felix", ex); - System.exit(0); - } - + SystrayActivator.getUIService().beginShutdown(); } else if (itemName.equals("addContact")) { diff --git a/src/net/java/sip/communicator/service/gui/UIService.java b/src/net/java/sip/communicator/service/gui/UIService.java index aac1737..5b0a5d0 100644 --- a/src/net/java/sip/communicator/service/gui/UIService.java +++ b/src/net/java/sip/communicator/service/gui/UIService.java @@ -332,4 +332,6 @@ public interface UIService public boolean isContainerSupported(Container containderID); public boolean useMacOSXScreenMenuBar(); + + public void beginShutdown(); } diff --git a/src/net/java/sip/communicator/util/UtilActivator.java b/src/net/java/sip/communicator/util/UtilActivator.java index e271294..a8c796b 100644 --- a/src/net/java/sip/communicator/util/UtilActivator.java +++ b/src/net/java/sip/communicator/util/UtilActivator.java @@ -22,9 +22,9 @@ import org.osgi.framework.*; /** * The only raison d'etre for this Activator is so that it would set a global * exception handler. It doesn't export any services and neither it runs any - * iniitialization - all it does is call + * initialization - all it does is call * <tt>Thread.setUncaughtExceptionHandler()</tt> - * + * * @author Emil Ivov */ public class UtilActivator @@ -97,7 +97,6 @@ public class UtilActivator public void stop(BundleContext context) throws Exception { - } public static ConfigurationService getConfigurationService() |