changeset 366:a55affd7ab6c

* Avoid setting a new colour on layer when adding the same layer more than once
author Chris Cannam
date Mon, 11 Feb 2008 11:06:17 +0000
parents 26ce2fb7bcbf
children 06360ed99cd1
files layer/SingleColourLayer.cpp layer/SingleColourLayer.h
diffstat 2 files changed, 9 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/layer/SingleColourLayer.cpp	Thu Feb 07 15:25:05 2008 +0000
+++ b/layer/SingleColourLayer.cpp	Mon Feb 11 11:06:17 2008 +0000
@@ -27,7 +27,8 @@
 
 SingleColourLayer::SingleColourLayer() :
     m_colour(0),
-    m_colourExplicitlySet(false)
+    m_colourExplicitlySet(false),
+    m_defaultColourSet(false)
 {
     setDefaultColourFor(0);
 }
@@ -125,7 +126,9 @@
 void
 SingleColourLayer::setDefaultColourFor(View *v)
 {
-    if (m_colourExplicitlySet) return;
+    std::cerr << "SingleColourLayer::setDefaultColourFor: m_colourExplicitlySet = " << m_colourExplicitlySet << ", m_defaultColourSet " << m_defaultColourSet << std::endl;
+
+    if (m_colourExplicitlySet || m_defaultColourSet) return;
 
     bool dark = false;
     if (v) {
@@ -155,6 +158,7 @@
 
     if (hint >= 0 && impose) {
         setBaseColour(hint);
+        m_defaultColourSet = true;
         return;
     }
 
@@ -190,6 +194,8 @@
     } else {
         m_colourRefCount[m_colour]++;
     }
+
+    m_defaultColourSet = true;
 }
 
 void
--- a/layer/SingleColourLayer.h	Thu Feb 07 15:25:05 2008 +0000
+++ b/layer/SingleColourLayer.h	Mon Feb 11 11:06:17 2008 +0000
@@ -70,6 +70,7 @@
 
     int m_colour;
     bool m_colourExplicitlySet;
+    bool m_defaultColourSet;
 };
 
 #endif