aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2017-10-10 20:54:59 +0200
committerAqua-sama <aqua@iserlohn-fortress.net>2017-10-10 20:54:59 +0200
commitd5f310e8285e783ec914a9e75d2230731c1868fe (patch)
tree8c06254415e51c278dbeb410031fbd7787c6edb8
parentSplit off DownloadsWidget into library (diff)
downloadsmolbote-d5f310e8285e783ec914a9e75d2230731c1868fe.tar.xz
Fixed crash on exit properly
-rw-r--r--src/mainwindow.cpp24
1 files changed, 16 insertions, 8 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 1036cbb..daf344d 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -139,16 +139,21 @@ MainWindow::MainWindow(QWidget *parent) :
MainWindow::~MainWindow()
{
+ // Release all dock widgets before deleting so we don't accidentally delete them
+ // Also fixes that annoying crash when closing
+ QList<QDockWidget*> allDockWidgets = findChildren<QDockWidget*>();
+ for(QDockWidget *w : allDockWidgets) {
+ if(w->widget()) {
+ w->widget()->setParent(0);
+ }
+ }
+
delete ui;
}
void MainWindow::addTabbedDock(Qt::DockWidgetArea area, QWidget *widget)
{
- QDockWidget *dock = new QDockWidget(widget->windowTitle(), this);
- dock->setWidget(widget);
- addDockWidget(area, dock);
-
- /*
+ // create a list for the dock widgets we're appending to
QList<QDockWidget*> allDockWidgets = findChildren<QDockWidget*>();
QVector<QDockWidget*> areaDockWidgets;
for(QDockWidget *w : allDockWidgets) {
@@ -157,12 +162,15 @@ void MainWindow::addTabbedDock(Qt::DockWidgetArea area, QWidget *widget)
}
}
+ QDockWidget *dock = new QDockWidget(widget->windowTitle(), this);
+ dock->setWidget(widget);
+
if(areaDockWidgets.empty()) {
// no other widgets
- addDockWidget(area, widget);
+ addDockWidget(area, dock);
} else {
- tabifyDockWidget(areaDockWidgets.last(), widget);
- }*/
+ tabifyDockWidget(areaDockWidgets.last(), dock);
+ }
}
void MainWindow::newTab(const QUrl &url)