From: <cr...@us...> - 2008-08-02 04:36:06
|
Revision: 4383 http://jnode.svn.sourceforge.net/jnode/?rev=4383&view=rev Author: crawley Date: 2008-08-02 04:36:03 +0000 (Sat, 02 Aug 2008) Log Message: ----------- Fix for bug #2361 - the halt & restart menu items did not do a clean shutdown of the plugins. Modified Paths: -------------- trunk/gui/src/awt/org/jnode/awt/JNodeToolkit.java trunk/gui/src/desktop/org/jnode/desktop/classic/Desktop.java Modified: trunk/gui/src/awt/org/jnode/awt/JNodeToolkit.java =================================================================== --- trunk/gui/src/awt/org/jnode/awt/JNodeToolkit.java 2008-08-01 23:20:01 UTC (rev 4382) +++ trunk/gui/src/awt/org/jnode/awt/JNodeToolkit.java 2008-08-02 04:36:03 UTC (rev 4383) @@ -112,6 +112,7 @@ private int refCount = 0; private final Dimension screenSize = new Dimension(640, 480); private Frame top; + private Runnable exitAction; public JNodeToolkit() { refCount = 0; @@ -1114,5 +1115,26 @@ JNodeToolkit.waitUntilStopped(); } } + ((JNodeToolkit) JNodeToolkit.getDefaultToolkit()).runExitAction(); } + + /** + * Set the action to be performed after the GUI has been shutdown, and + * before control is returned to (for instance) the CommandShell. + * + * @param exitAction an action, or <code>null</code>. + */ + public static void setExitAction(Runnable exitAction) { + // FIXME ... This method probably needs a security check. (The way it + // is currently used potentially offers a small window for some other + // thread to insert an action that would then be executed in the security + // context of the GUI's owner.) + ((JNodeToolkit) JNodeToolkit.getDefaultToolkit()).exitAction = exitAction; + } + + private synchronized void runExitAction() { + if (exitAction != null) { + exitAction.run(); + } + } } Modified: trunk/gui/src/desktop/org/jnode/desktop/classic/Desktop.java =================================================================== --- trunk/gui/src/desktop/org/jnode/desktop/classic/Desktop.java 2008-08-01 23:20:01 UTC (rev 4382) +++ trunk/gui/src/desktop/org/jnode/desktop/classic/Desktop.java 2008-08-02 04:36:03 UTC (rev 4383) @@ -116,21 +116,30 @@ taskBar.quitMI.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { taskBar.startMenu.setVisible(false); + JNodeToolkit.setExitAction(null); JNodeToolkit.stopGui(); } }); taskBar.haltMI.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { + JNodeToolkit.setExitAction(new Runnable() { + public void run() { + VmSystem.halt(false); + } + }); JNodeToolkit.stopGui(); - VmSystem.halt(false); } }); taskBar.restartMI.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { + JNodeToolkit.setExitAction(new Runnable() { + public void run() { + VmSystem.halt(true); + } + }); JNodeToolkit.stopGui(); - VmSystem.halt(true); } }); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |