Fixed race condition if patching finishes before the popup is shown

This commit is contained in:
Vhati 2013-08-22 00:39:37 -04:00
parent 37e84a0d55
commit 24e53c3164

View file

@ -169,6 +169,15 @@ public class ModPatchDialog extends JDialog implements ActionListener, ModPatchO
patchingSucceeded = success; patchingSucceeded = success;
continueBtn.setEnabled( true ); 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 ) { public void setSuccessTask( Runnable r ) {
successTask = 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 );
}
} }