Преглед изворни кода

Use atomic bools properly

Change-Id: Ic4c0f6b5a02b4a046a43f25731a796412b5b2f2a
Reviewed-on: http://gerrit.dmdirc.com/443
Reviewed-by: Gregory Holmes <greboid@dmdirc.com>
Tested-by: Gregory Holmes <greboid@dmdirc.com>
tags/0.6.3
Chris Smith пре 14 година
родитељ
комит
1ca5607ab9

+ 1
- 1
src/com/dmdirc/addons/ui_swing/dialogs/StandardInputDialog.java Прегледај датотеку

@@ -54,7 +54,7 @@ public abstract class StandardInputDialog extends StandardDialog {
54 54
     /** Message. */
55 55
     private String message;
56 56
     /** Are we saving? */
57
-    protected AtomicBoolean saving = new AtomicBoolean(false);
57
+    protected final AtomicBoolean saving = new AtomicBoolean(false);
58 58
 
59 59
     /**
60 60
      * Instantiates a new standard input dialog.

+ 4
- 7
src/com/dmdirc/addons/ui_swing/dialogs/actionsmanager/ActionsManagerDialog.java Прегледај датотеку

@@ -100,7 +100,7 @@ public final class ActionsManagerDialog extends StandardDialog implements
100 100
     /** Group panel. */
101 101
     private JPanel groupPanel;
102 102
     /** Are we saving? */
103
-    private AtomicBoolean saving = new AtomicBoolean(false);
103
+    private final AtomicBoolean saving = new AtomicBoolean(false);
104 104
 
105 105
     /** 
106 106
      * Creates a new instance of ActionsManagerDialog.
@@ -322,8 +322,7 @@ public final class ActionsManagerDialog extends StandardDialog implements
322 322
             delGroup();
323 323
         } else if (e.getSource() == getOkButton() || e.getSource()
324 324
                 == getCancelButton()) {
325
-            if (!saving.get()) {
326
-                saving.set(true);
325
+            if (!saving.getAndSet(true)) {
327 326
                 if (ActionEditorDialog.isOpen()) {
328 327
                     if (JOptionPane.showConfirmDialog(this,
329 328
                             "The action editor is currently open, do you want to cotinue and lose any unsaved changes?",
@@ -367,8 +366,7 @@ public final class ActionsManagerDialog extends StandardDialog implements
367 366
             /** {@inheritDoc} */
368 367
             @Override
369 368
             public boolean save() {
370
-                if (!saving.get()) {
371
-                    saving.set(true);
369
+                if (!saving.getAndSet(true)) {
372 370
                     if (getText() == null || getText().isEmpty() && !ActionManager.
373 371
                             getGroups().
374 372
                             containsKey(getText())) {
@@ -416,8 +414,7 @@ public final class ActionsManagerDialog extends StandardDialog implements
416 414
             /** {@inheritDoc} */
417 415
             @Override
418 416
             public boolean save() {
419
-                if (!saving.get()) {
420
-                    saving.set(true);
417
+                if (!saving.getAndSet(true)) {
421 418
                     if (getText() == null || getText().isEmpty()) {
422 419
                         return false;
423 420
                     } else {

Loading…
Откажи
Сачувај