diff layer/SingleColourLayer.cpp @ 294:919740b20cc9

* Better abbreviation modes for layer names in pane (and input model combo of plugin parameter dialog) * Avoid crash when loading SV file containing model derived from nonexistent model (shouldn't happen of course, but see bug #1771769) * Remember last-used input model in plugin parameter dialog * Don't override a layer colour loaded from a session file with the generated default colour when attaching it to a view
author Chris Cannam
date Fri, 10 Aug 2007 16:36:50 +0000
parents 15b8a4bfe855
children ea37c229a578
line wrap: on
line diff
--- a/layer/SingleColourLayer.cpp	Thu Aug 09 14:40:03 2007 +0000
+++ b/layer/SingleColourLayer.cpp	Fri Aug 10 16:36:50 2007 +0000
@@ -25,7 +25,8 @@
 SingleColourLayer::m_colourRefCount;
 
 SingleColourLayer::SingleColourLayer() :
-    m_colour(0)
+    m_colour(0),
+    m_colourExplicitlySet(false)
 {
     setDefaultColourFor(0);
 }
@@ -117,6 +118,8 @@
 void
 SingleColourLayer::setDefaultColourFor(View *v)
 {
+    if (m_colourExplicitlySet) return;
+
     bool dark = false;
     if (v) {
         dark = !v->hasLightBackground();
@@ -185,6 +188,8 @@
 void
 SingleColourLayer::setBaseColour(int colour)
 {
+    m_colourExplicitlySet = true;
+
     if (m_colour == colour) return;
 
     if (m_colourRefCount.find(m_colour) != m_colourRefCount.end() &&
@@ -270,5 +275,12 @@
     QString darkbg = attributes.value("darkBackground");
     m_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;
+    flagBaseColourChanged();
 }