JAL-591 reduced updating by checking/setting 'updating' flag
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Thu, 10 May 2018 14:17:20 +0000 (15:17 +0100)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Thu, 10 May 2018 14:17:20 +0000 (15:17 +0100)
src/jalview/gui/OptsAndParamsPage.java

index 5ef7169..dcd07ef 100644 (file)
@@ -552,13 +552,23 @@ public class OptsAndParamsPage
      */
     private void checkIfModified()
     {
-      Object newValue = updateSliderFromValueField();
-      boolean modified = true;
-      if (newValue.getClass() == lastVal.getClass())
+      if (!adjusting)
       {
-        modified = !newValue.equals(lastVal);
+        try
+        {
+          adjusting = true;
+          Object newValue = updateSliderFromValueField();
+          boolean modified = true;
+          if (newValue.getClass() == lastVal.getClass())
+          {
+            modified = !newValue.equals(lastVal);
+          }
+          pmdialogbox.argSetModified(this, modified);
+        } finally
+        {
+          adjusting = false;
+        }
       }
-      pmdialogbox.argSetModified(this, modified);
     }
 
     @Override
@@ -632,8 +642,13 @@ public class OptsAndParamsPage
     @Override
     public void stateChanged(ChangeEvent e)
     {
-      if (!adjusting)
+      if (adjusting)
       {
+        return;
+      }
+      try
+      {
+        adjusting = true;
         if (!isLogarithmicParameter)
         {
           /*
@@ -651,6 +666,9 @@ public class OptsAndParamsPage
           valueField.setText(formatDouble(value));
         }
         checkIfModified();
+      } finally
+      {
+        adjusting = false;
       }
     }