[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kate] part/utils: guard some options against setting it twice
From:       Dominik Haumann <dhaumann () kde ! org>
Date:       2013-06-27 10:30:13
Message-ID: E1Us9Sv-0003yM-9z () scm ! kde ! org
[Download RAW message or body]

Git commit 256f7654bd7a1dd20c60558307511b4be1c090bd by Dominik Haumann.
Committed on 27/06/2013 at 10:30.
Pushed by dhaumann into branch 'master'.

guard some options against setting it twice

Setting an option that already is the correct value
should not emit configChanged(). So all setters should
have the form:
  if (!m_optionSet || m_option != option) {
    configStart();
    m_optionSet = true;
    m_option = option;
    configEnd();
  }
This should be done for all setters in KateConfig. Then,
potentially lots of unnecessary config-changed signals could be
suppressed. Any volunteers?

CCMAIL: kwrite-devel@kde.org

M  +34   -30   part/utils/kateconfig.cpp

http://commits.kde.org/kate/256f7654bd7a1dd20c60558307511b4be1c090bd

diff --git a/part/utils/kateconfig.cpp b/part/utils/kateconfig.cpp
index abd1923..3a22c4c 100644
--- a/part/utils/kateconfig.cpp
+++ b/part/utils/kateconfig.cpp
@@ -1566,17 +1566,19 @@ bool KateViewConfig::viInputMode () const
 
 void KateViewConfig::setViInputMode (bool on)
 {
-  configStart ();
+  if (!m_viInputModeSet || m_viInputMode != on) {
+    configStart ();
 
-  m_viInputModeSet = true;
-  m_viInputMode = on;
+    m_viInputModeSet = true;
+    m_viInputMode = on;
 
-  // make sure to turn off edits mergin when leaving vi input mode
-  if (!on && m_view) {
-    m_view->doc()->setUndoMergeAllEdits(false);
-  }
+    // make sure to turn off edits mergin when leaving vi input mode
+    if (!on && m_view) {
+      m_view->doc()->setUndoMergeAllEdits(false);
+    }
 
-  configEnd ();
+    configEnd ();
+  }
 }
 
 bool KateViewConfig::viInputModeStealKeys () const
@@ -1589,12 +1591,12 @@ bool KateViewConfig::viInputModeStealKeys () const
 
 void KateViewConfig::setViInputModeStealKeys (bool on)
 {
-  configStart ();
-
-  m_viInputModeStealKeysSet = true;
-  m_viInputModeStealKeys = on;
-
-  configEnd ();
+  if (!m_viInputModeStealKeysSet || m_viInputModeStealKeys != on) {
+    configStart ();
+    m_viInputModeStealKeysSet = true;
+    m_viInputModeStealKeys = on;
+    configEnd ();
+  }
 }
 
 
@@ -1608,10 +1610,12 @@ bool KateViewConfig::viInputModeEmulateCommandBar() const
 
 void KateViewConfig::setViInputModeEmulateCommandBar(bool on)
 {
-  configStart();
-  m_viInputModeEmulateCommandBarSet = true;
-  m_viInputModeEmulateCommandBar = on;
-  configEnd();
+  if (!m_viInputModeEmulateCommandBarSet || m_viInputModeEmulateCommandBar != on) {
+    configStart();
+    m_viInputModeEmulateCommandBarSet = true;
+    m_viInputModeEmulateCommandBar = on;
+    configEnd();
+  }
 }
 
 bool KateViewConfig::automaticCompletionInvocation () const
@@ -1624,12 +1628,12 @@ bool KateViewConfig::automaticCompletionInvocation () const
 
 void KateViewConfig::setAutomaticCompletionInvocation (bool on)
 {
-  configStart ();
-
-  m_automaticCompletionInvocationSet = true;
-  m_automaticCompletionInvocation = on;
-
-  configEnd ();
+  if (!m_automaticCompletionInvocationSet || m_automaticCompletionInvocation != on) {
+    configStart ();
+    m_automaticCompletionInvocationSet = true;
+    m_automaticCompletionInvocation = on;
+    configEnd ();
+  }
 }
 
 bool KateViewConfig::wordCompletion () const
@@ -1642,12 +1646,12 @@ bool KateViewConfig::wordCompletion () const
 
 void KateViewConfig::setWordCompletion (bool on)
 {
-  configStart ();
-
-  m_wordCompletionSet = true;
-  m_wordCompletion = on;
-
-  configEnd ();
+  if (!m_wordCompletionSet || m_wordCompletion != on) {
+    configStart ();
+    m_wordCompletionSet = true;
+    m_wordCompletion = on;
+    configEnd ();
+  }
 }
 
 int KateViewConfig::wordCompletionMinimalWordLength () const
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic