Commit 8e480a81 authored by Jouni Pentikäinen's avatar Jouni Pentikäinen

Remove placeholder widget used in detached canvas mode

parent 57ed30da
......@@ -37,7 +37,6 @@ KisCanvasWindow::KisCanvasWindow(KisMainWindow *mainWindow)
QLayout *layout = new QHBoxLayout(this);
setLayout(layout);
layout->addWidget(new QWidget(this));
}
KisCanvasWindow::~KisCanvasWindow() {}
......@@ -50,7 +49,9 @@ void KisCanvasWindow::closeEvent(QCloseEvent *event)
QWidget * KisCanvasWindow::swapMainWidget(QWidget *newWidget)
{
QWidget *oldWidget = layout()->takeAt(0)->widget();
layout()->addWidget(newWidget);
QWidget *oldWidget = (layout()->count() > 0) ? (layout()->takeAt(0)->widget()) : nullptr;
if (newWidget) {
layout()->addWidget(newWidget);
}
return oldWidget;
}
......@@ -678,9 +678,12 @@ void KisMainWindow::setCanvasDetached(bool detach)
{
if (detach == canvasDetached()) return;
QWidget *outgoingWidget = takeCentralWidget();
QWidget *outgoingWidget = centralWidget() ? takeCentralWidget() : nullptr;
QWidget *incomingWidget = d->canvasWindow->swapMainWidget(outgoingWidget);
setCentralWidget(incomingWidget);
if (incomingWidget) {
setCentralWidget(incomingWidget);
}
if (detach) {
KIS_SAFE_ASSERT_RECOVER_NOOP(outgoingWidget == d->mdiArea);
......@@ -1388,7 +1391,7 @@ void KisMainWindow::mouseReleaseEvent(QMouseEvent *event)
* need to make a canvas first, will find the new image
* dialog on click.
*/
if (centralWidget()->geometry().contains(event->pos())
if (centralWidget() && centralWidget()->geometry().contains(event->pos())
&& KisPart::instance()->documents().size()==0 && event->button() == Qt::LeftButton) {
this->slotFileNew();
event->accept();
......
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