Skip to content

Commit

Permalink
Fix color widget opens in wrong panel (fix #15705)
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Oct 14, 2016
1 parent ea2fbd1 commit 721d3c5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/gui/qgspanelwidget.cpp
Expand Up @@ -55,6 +55,13 @@ QgsPanelWidget*QgsPanelWidget::findParentPanel( QWidget* widget )
if ( QgsPanelWidget* panel = qobject_cast< QgsPanelWidget* >( p ) )
return panel;

if ( p->window() == p )
{
// break on encountering a window - eg a dialog opened from a panel should not inline
// widgets inside the parent panel
return false;
}

p = p->parentWidget();
}
return nullptr;
Expand Down
8 changes: 7 additions & 1 deletion tests/src/python/test_qgspanelwidget.py
Expand Up @@ -14,7 +14,7 @@

import qgis # NOQA

from qgis.PyQt.QtWidgets import QWidget
from qgis.PyQt.QtWidgets import QWidget, QDialog
from qgis.gui import QgsPanelWidget
from qgis.testing import start_app, unittest

Expand Down Expand Up @@ -49,6 +49,12 @@ def testFindParentPanel(self):
w5 = QWidget(w4)
self.assertEqual(QgsPanelWidget.findParentPanel(w5), w3)

# chain should be broken when a new window is encountered
n = QgsPanelWidget()
n2 = QDialog(n)
n3 = QWidget(n2)
self.assertFalse(QgsPanelWidget.findParentPanel(n3))


if __name__ == '__main__':
unittest.main()

0 comments on commit 721d3c5

Please sign in to comment.