# HG changeset patch # User Chris Cannam # Date 1391524559 0 # Node ID d1c0abfb11bef9bf9af010a8468f6c2a717d36bb # Parent dd64efa0dac81a9c61416329835ed7a0a230676d Fix bug in choosing which layer to bring to the front when asked programmatically diff -r dd64efa0dac8 -r d1c0abfb11be widgets/PropertyStack.cpp --- 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;