From 24e53c31643efdca13019b462b1cfeb41f400105 Mon Sep 17 00:00:00 2001 From: Vhati Date: Thu, 22 Aug 2013 00:39:37 -0400 Subject: [PATCH] Fixed race condition if patching finishes before the popup is shown --- .../vhati/modmanager/ui/ModPatchDialog.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/main/java/net/vhati/modmanager/ui/ModPatchDialog.java b/src/main/java/net/vhati/modmanager/ui/ModPatchDialog.java index 57c0e99..76e0e91 100644 --- a/src/main/java/net/vhati/modmanager/ui/ModPatchDialog.java +++ b/src/main/java/net/vhati/modmanager/ui/ModPatchDialog.java @@ -169,6 +169,15 @@ public class ModPatchDialog extends JDialog implements ActionListener, ModPatchO patchingSucceeded = success; continueBtn.setEnabled( true ); + + if ( !ModPatchDialog.this.isShowing() ) { + // The window's not visible, no continueBtn to click. + ModPatchDialog.this.dispose(); + + if ( patchingSucceeded && successTask != null ) { + successTask.run(); + } + } } }); } @@ -180,4 +189,13 @@ public class ModPatchDialog extends JDialog implements ActionListener, ModPatchO public void setSuccessTask( Runnable r ) { successTask = r; } + + /** + * Shows or hides this component depending on the value of parameter b. + * + * If patching has already completed, this method will do nothing. + */ + public void setVisible( boolean b ) { + if ( !done ) super.setVisible( b ); + } }