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
(cherry-picked from 721d3c5)
  • Loading branch information
nyalldawson committed Oct 17, 2016
1 parent 979d619 commit e15c93d
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
Original file line number Diff line number Diff line change
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 nullptr;
}

p = p->parentWidget();
}
return nullptr;
Expand Down
8 changes: 7 additions & 1 deletion tests/src/python/test_qgspanelwidget.py
Original file line number Diff line number Diff line change
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 e15c93d

Please sign in to comment.