]> vaikene.ee Git - evaf/blobdiff - src/plugins/SdiWindow/sdiwindow.cpp
Made it safe to delete widgets and layouts added to the main window in the original...
[evaf] / src / plugins / SdiWindow / sdiwindow.cpp
index a804dfc14cc64dc70a8739612dc8decf3a0636a7..d0294d8c83c1e18fddee8cc105170a9020de20eb 100644 (file)
@@ -63,6 +63,10 @@ MainWindow::MainWindow(QWidget * parent, Qt::WindowFlags flags)
     // Apply the size specified in a) properties; or b) on the command line
     setWindowSize();
 
+    // Create the default layout
+    mLayout = new QVBoxLayout;
+    setLayout(mLayout);
+
     EVAF_INFO("%s created", qPrintable(objectName()));
 }
 
@@ -89,9 +93,28 @@ void MainWindow::done()
 {
     close();
 
+    // Delete all the items added to the main window
+    while (mItemsAdded.count() > 0) {
+        QPointer<QObject> item = mItemsAdded.takeAt(0);
+        if (item)
+            delete item.data();
+    }
+
     EVAF_INFO("%s finalized", qPrintable(objectName()));
 }
 
+void MainWindow::addWidget(QWidget * widget)
+{
+    mLayout->addWidget(widget);
+    mItemsAdded.append(widget);
+}
+
+void MainWindow::addLayout(QLayout * layout)
+{
+    mLayout->addLayout(layout);
+    mItemsAdded.append(layout);
+}
+
 void MainWindow::saveSettings()
 {
     static int ver[4] = {VER_FILE_VERSION};