summaryrefslogtreecommitdiffstats
path: root/tools/designer/src
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@nokia.com>2010-10-11 08:48:54 (GMT)
committerFriedemann Kleint <Friedemann.Kleint@nokia.com>2010-10-11 08:48:54 (GMT)
commit36438bc216f939acd4e6772847d435e2e77d41c3 (patch)
tree31c23b3bd55c3201771d62637923b7a73257c876 /tools/designer/src
parentf0c1f381af7d6338ded9f65d00ed54b1b9405ba9 (diff)
downloadQt-36438bc216f939acd4e6772847d435e2e77d41c3.zip
Qt-36438bc216f939acd4e6772847d435e2e77d41c3.tar.gz
Qt-36438bc216f939acd4e6772847d435e2e77d41c3.tar.bz2
Designer: Fix a crash when copying empty page-based containers.
Reviewed-by: Jarek Kobus <jaroslaw.kobus@nokia.com> Task-number: QTBUG-14208
Diffstat (limited to 'tools/designer/src')
-rw-r--r--tools/designer/src/components/formeditor/formwindow.cpp17
1 files changed, 12 insertions, 5 deletions
diff --git a/tools/designer/src/components/formeditor/formwindow.cpp b/tools/designer/src/components/formeditor/formwindow.cpp
index 15775f6..38a0544 100644
--- a/tools/designer/src/components/formeditor/formwindow.cpp
+++ b/tools/designer/src/components/formeditor/formwindow.cpp
@@ -1683,10 +1683,13 @@ void FormWindow::cut()
// for cases like QMainWindow (central widget is an inner container) or QStackedWidget (page is an inner container)
QWidget *FormWindow::innerContainer(QWidget *outerContainer) const
{
- bool isContainer = m_core->widgetDataBase()->isContainer(outerContainer);
- if (isContainer)
- if (QDesignerContainerExtension *container = qt_extension<QDesignerContainerExtension*>(m_core->extensionManager(), outerContainer))
- return container->widget(container->currentIndex());
+ if (m_core->widgetDataBase()->isContainer(outerContainer))
+ if (const QDesignerContainerExtension *container = qt_extension<QDesignerContainerExtension*>(m_core->extensionManager(), outerContainer)) {
+ const int currentIndex = container->currentIndex();
+ return currentIndex >= 0 ?
+ container->widget(currentIndex) :
+ static_cast<QWidget *>(0);
+ }
return outerContainer;
}
@@ -1706,8 +1709,10 @@ QWidget *FormWindow::containerForPaste() const
QWidget *containerOfW = findContainer(selection.first(), /* exclude layouts */ true);
if (!containerOfW || containerOfW == mainContainer())
break;
- // No layouts, must be container
+ // No layouts, must be container. No empty page-based containers.
containerOfW = innerContainer(containerOfW);
+ if (!containerOfW)
+ break;
if (LayoutInfo::layoutType(m_core, containerOfW) != LayoutInfo::NoLayout || !m_core->widgetDataBase()->isContainer(containerOfW))
break;
w = containerOfW;
@@ -1716,6 +1721,8 @@ QWidget *FormWindow::containerForPaste() const
// and the like as the central widget has the layout).
w = innerContainer(w);
+ if (!w)
+ return 0;
if (LayoutInfo::layoutType(m_core, w) != LayoutInfo::NoLayout)
return 0;
// Go up via container extension (also includes step from QMainWindow to its central widget)