aboutsummaryrefslogtreecommitdiff
path: root/src/mainwindow.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mainwindow.cpp')
-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)