]> vaikene.ee Git - evaf/blobdiff - src/plugins/SdiWindow/sdiwindow.cpp
Replaced QPointer<> with QWeakPointer<>
[evaf] / src / plugins / SdiWindow / sdiwindow.cpp
index a804dfc14cc64dc70a8739612dc8decf3a0636a7..02de43a320a80ecf231a3b51d7305e93905764b5 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) {
+        QWeakPointer<QObject> item = mItemsAdded.takeAt(0);
+        if (!item.isNull())
+            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};