changeset 723:d1c0abfb11be tonioni

Fix bug in choosing which layer to bring to the front when asked programmatically
author Chris Cannam
date Tue, 04 Feb 2014 14:35:59 +0000
parents dd64efa0dac8
children 62e7d4b378ae
files widgets/PropertyStack.cpp
diffstat 1 files changed, 13 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/widgets/PropertyStack.cpp	Tue Feb 04 13:54:42 2014 +0000
+++ b/widgets/PropertyStack.cpp	Tue Feb 04 14:35:59 2014 +0000
@@ -153,9 +153,19 @@
 int
 PropertyStack::getContainerIndex(PropertyContainer *pc) const
 {
-    for (size_t i = 0; i < m_client->getPropertyContainerCount(); ++i) {
-	PropertyContainer *container = m_client->getPropertyContainer(i);
-	if (pc == container) return i;
+    // This is used to obtain an index to be passed to setCurrentIndex
+    // -- which is the index of the property container's box in our
+    // stack of boxes. That is not the same thing as the index of the
+    // container (i.e. the layer) in the view: the view reorders its
+    // containers whenever one is raised to the top, while our boxes
+    // remain in the same order. So we must find this container in the
+    // box list, not in the view.
+
+    for (size_t i = 0; i < m_boxes.size(); ++i) {
+	PropertyContainer *container = m_boxes[i]->getContainer();
+	if (pc == container) {
+            return i;
+        }
     }
 
     return false;