From 58a32c41f0427c2f17c112a0465a12aea1feea5e Mon Sep 17 00:00:00 2001 From: SiboVG Date: Wed, 1 Feb 2023 20:48:49 +0000 Subject: [PATCH] [#2009] Check for unmodified component earlier on --- .../gui/configdialog/RocketComponentConfig.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/swing/src/net/sf/openrocket/gui/configdialog/RocketComponentConfig.java b/swing/src/net/sf/openrocket/gui/configdialog/RocketComponentConfig.java index c7b12c99d..c7cd80b99 100644 --- a/swing/src/net/sf/openrocket/gui/configdialog/RocketComponentConfig.java +++ b/swing/src/net/sf/openrocket/gui/configdialog/RocketComponentConfig.java @@ -276,16 +276,18 @@ public class RocketComponentConfig extends JPanel { cancelButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { + // Don't do anything on cancel if you are editing an existing component, and it is not modified + if (!isNewComponent && parent != null && !parent.isModified()) { + ComponentConfigDialog.disposeDialog(); + return; + } + // Apply the cancel operation if set to auto discard in preferences if (preferences.getBoolean(IGNORE_DISCARD_EDITING_WARNING, false)) { ComponentConfigDialog.clearConfigListeners = false; // Undo action => config listeners of new component will be cleared ComponentConfigDialog.disposeDialog(); document.undo(); return; } - if (!isNewComponent && parent != null && !parent.isModified()) { - ComponentConfigDialog.disposeDialog(); - return; - } // Yes/No dialog: Are you sure you want to discard your changes? JPanel msg = createCancelOperationContent();