Commit fb056b1a authored by con's avatar con
Browse files

Don't crash when unsplitting more complicated editor splits.

Whenever we want to re-use widgets from the former child SplitterOrView,
we must make sure that this doesn't delete it later on.
parent 62aab5fc
...@@ -835,6 +835,24 @@ QSize SplitterOrView::minimumSizeHint() const ...@@ -835,6 +835,24 @@ QSize SplitterOrView::minimumSizeHint() const
return QSize(64, 64); return QSize(64, 64);
} }
QSplitter *SplitterOrView::takeSplitter()
{
QSplitter *oldSplitter = m_splitter;
if (m_splitter)
m_layout->removeWidget(m_splitter);
m_splitter = 0;
return oldSplitter;
}
EditorView *SplitterOrView::takeView()
{
EditorView *oldView = m_view;
if (m_view)
m_layout->removeWidget(m_view);
m_view = 0;
return oldView;
}
void SplitterOrView::split(Qt::Orientation orientation) void SplitterOrView::split(Qt::Orientation orientation)
{ {
Q_ASSERT(m_view && m_splitter == 0); Q_ASSERT(m_view && m_splitter == 0);
...@@ -903,13 +921,12 @@ void SplitterOrView::unsplit() ...@@ -903,13 +921,12 @@ void SplitterOrView::unsplit()
Q_ASSERT(m_splitter->count() == 1); Q_ASSERT(m_splitter->count() == 1);
EditorManager *em = CoreImpl::instance()->editorManager(); EditorManager *em = CoreImpl::instance()->editorManager();
SplitterOrView *childSplitterOrView = qobject_cast<SplitterOrView*>(m_splitter->widget(0)); SplitterOrView *childSplitterOrView = qobject_cast<SplitterOrView*>(m_splitter->widget(0));
QSplitter *oldSplitter = m_splitter; QSplitter *oldSplitter = m_splitter;
m_splitter = 0; m_splitter = 0;
if (childSplitterOrView->isSplitter()) { if (childSplitterOrView->isSplitter()) {
Q_ASSERT(childSplitterOrView->view() == 0); Q_ASSERT(childSplitterOrView->view() == 0);
m_splitter = childSplitterOrView->splitter(); m_splitter = childSplitterOrView->takeSplitter();
m_layout->addWidget(m_splitter); m_layout->addWidget(m_splitter);
m_layout->setCurrentWidget(m_splitter); m_layout->setCurrentWidget(m_splitter);
} else { } else {
...@@ -923,8 +940,7 @@ void SplitterOrView::unsplit() ...@@ -923,8 +940,7 @@ void SplitterOrView::unsplit()
} }
em->emptyView(childView); em->emptyView(childView);
} else { } else {
m_view = childView; m_view = childSplitterOrView->takeView();
childSplitterOrView->m_layout->removeWidget(m_view);
m_layout->addWidget(m_view); m_layout->addWidget(m_view);
} }
m_layout->setCurrentWidget(m_view); m_layout->setCurrentWidget(m_view);
......
...@@ -197,6 +197,8 @@ public: ...@@ -197,6 +197,8 @@ public:
inline bool hasEditors() const { return m_view && m_view->editorCount() != 0; } inline bool hasEditors() const { return m_view && m_view->editorCount() != 0; }
inline EditorView *view() const { return m_view; } inline EditorView *view() const { return m_view; }
inline QSplitter *splitter() const { return m_splitter; } inline QSplitter *splitter() const { return m_splitter; }
QSplitter *takeSplitter();
EditorView *takeView();
SplitterOrView *findView(Core::IEditor *editor); SplitterOrView *findView(Core::IEditor *editor);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment