diff layer/SingleColourLayer.cpp @ 296:ea37c229a578

* Fix #1757772 tempo, dynamic related plug-ins bug -- make auto-align only auto-align if there is a unit involved * Fix #1755366 text layer bug in retrieved session * Fix input model selection in plugin parameter dialog (was being ignored) * Use lighter background than the standard widget one for panes (assuming the widget background is light but not white) -- similarly darker if dark * Fix colour reference counting in loaded session in SingleColourLayer * Reset overview pane colour when switching dark background on or off
author Chris Cannam
date Tue, 14 Aug 2007 13:58:53 +0000
parents 919740b20cc9
children 860f9ada4327
line wrap: on
line diff
--- a/layer/SingleColourLayer.cpp	Mon Aug 13 14:53:28 2007 +0000
+++ b/layer/SingleColourLayer.cpp	Tue Aug 14 13:58:53 2007 +0000
@@ -141,9 +141,9 @@
         // means we're being called from the constructor, and this is
         // a virtual function
         hint = getDefaultColourHint(dark, impose);
-//        std::cerr << "hint = " << hint << ", impose = " << impose << std::endl;
+        std::cerr << "hint = " << hint << ", impose = " << impose << std::endl;
     } else {
-//        std::cerr << "(from ctor)" << std::endl;
+        std::cerr << "(from ctor)" << std::endl;
     }
 
     if (hint >= 0 && impose) {
@@ -164,15 +164,15 @@
             count = m_colourRefCount[index];
         }
 
-//        std::cerr << "index = " << index << ", count = " << count;
+        std::cerr << "index = " << index << ", count = " << count;
 
         if (bestColour < 0 || count < bestCount) {
             bestColour = index;
             bestCount = count;
-//            std::cerr << " *";
+            std::cerr << " *";
         }
 
-//        std::cerr << std::endl;
+        std::cerr << std::endl;
     }
     
     if (bestColour < 0) m_colour = 0;
@@ -273,14 +273,30 @@
     QString colourName = attributes.value("colourName");
     QString colourSpec = attributes.value("colour");
     QString darkbg = attributes.value("darkBackground");
-    m_colour = ColourDatabase::getInstance()->putStringValues
+
+    int colour = ColourDatabase::getInstance()->putStringValues
         (colourName, colourSpec, darkbg);
-    if (m_colourRefCount.find(m_colour) == m_colourRefCount.end()) {
-        m_colourRefCount[m_colour] = 1;
-    } else {
-        m_colourRefCount[m_colour]++;
+
+    m_colourExplicitlySet = true;
+
+    if (m_colour != colour) {
+
+        std::cerr << "SingleColourLayer::setProperties: changing colour from " << m_colour << " to " << colour << std::endl;
+
+        if (m_colourRefCount.find(m_colour) != m_colourRefCount.end() &&
+            m_colourRefCount[m_colour] > 0) {
+            m_colourRefCount[m_colour]--;
+        }
+
+        m_colour = colour;
+
+        if (m_colourRefCount.find(m_colour) == m_colourRefCount.end()) {
+            m_colourRefCount[m_colour] = 1;
+        } else {
+            m_colourRefCount[m_colour]++;
+        }
+
+        flagBaseColourChanged();
     }
-    m_colourExplicitlySet = true;
-    flagBaseColourChanged();
 }