X-Git-Url: https://vaikene.ee/gitweb/pswgen09.html?a=blobdiff_plain;f=src%2Fplugins%2FSdiWindow%2Fsdiwindow.cpp;h=25a86acab2639b0505ebf10fc35f6b938b5a4ca1;hb=4c0329c5c2690bde28212c89029015a5da4c7e34;hp=5956276b3add6f79abb0a9c05a0691bd777d7697;hpb=196fb465dc1fd7495cd79f35a2272118cdb0d9a8;p=evaf
diff --git a/src/plugins/SdiWindow/sdiwindow.cpp b/src/plugins/SdiWindow/sdiwindow.cpp
index 5956276..25a86ac 100644
--- a/src/plugins/SdiWindow/sdiwindow.cpp
+++ b/src/plugins/SdiWindow/sdiwindow.cpp
@@ -3,7 +3,7 @@
* @brief SdiWindow module's implementation
* @author Enar Vaikene
*
- * Copyright (c) 2011 Enar Vaikene
+ * Copyright (c) 2011-2019 Enar Vaikene
*
* This file is part of the eVaf C++ cross-platform application development framework.
*
@@ -32,7 +32,7 @@ namespace eVaf {
namespace SdiWindow {
namespace Internal {
/// iSdiWindow interface instance singleton
- static iSdiWindow * mSdiWindow = 0;
+ static iSdiWindow * mSdiWindow = nullptr;
} // namespace eVaf::SdiWindow::Internal
} // namespace eVaf::SdiWindow
} // namespace eVaf
@@ -53,7 +53,7 @@ SdiWindow::iSdiWindow * SdiWindow::iSdiWindow::instance()
SdiWindow::Internal::MainWindow::MainWindow(QWidget * parent, Qt::WindowFlags flags)
: QWidget(parent, flags)
, mReady(false)
- , mMainPanel(0)
+ , mMainPanel(nullptr)
{
setObjectName(QString("%1-%2").arg(VER_MODULE_NAME_STR).arg(__FUNCTION__));
@@ -74,7 +74,7 @@ SdiWindow::Internal::MainWindow::MainWindow(QWidget * parent, Qt::WindowFlags fl
SdiWindow::Internal::MainWindow::~MainWindow()
{
- mSdiWindow = 0;
+ mSdiWindow = nullptr;
// Save geometry
saveSettings();
@@ -126,7 +126,7 @@ void SdiWindow::Internal::MainWindow::done()
mPanels.clear();
mMinimizedPanels.clear();
mPanelNames.clear();
- mMainPanel = 0;
+ mMainPanel = nullptr;
mMainPanelName.clear();
EVAF_INFO("%s finalized", qPrintable(objectName()));
@@ -160,7 +160,7 @@ Gui::Panel * SdiWindow::Internal::MainWindow::panel(QString const & name) const
QHash::const_iterator it = mPanelNames.constFind(name);
if (it != mPanelNames.constEnd())
return it.value();
- return 0;
+ return nullptr;
}
bool SdiWindow::Internal::MainWindow::showPanel(QString const & name)
@@ -292,6 +292,20 @@ void SdiWindow::Internal::MainWindow::panelDestroyed(QObject * obj)
}
}
}
+ {
+ QVector::iterator it = mMinimizedPanels.begin();
+ while (it != mMinimizedPanels.end())
+ {
+ if (*it == obj)
+ {
+ it = mMinimizedPanels.erase(it);
+ }
+ else
+ {
+ ++it;
+ }
+ }
+ }
// Do the same with panel names
{
@@ -306,8 +320,9 @@ void SdiWindow::Internal::MainWindow::panelDestroyed(QObject * obj)
}
}
+ // If it was the main panel, set the main panel to NULL
if (mMainPanel == obj) {
- mMainPanel = 0;
+ mMainPanel = nullptr;
}
}
@@ -316,17 +331,16 @@ void SdiWindow::Internal::MainWindow::panelDestroyed(QObject * obj)
SdiWindow::Internal::SdiWindowPlugin::SdiWindowPlugin()
: Plugins::iPlugin()
+ , mWindow(new MainWindow)
{
setObjectName(VER_MODULE_NAME_STR);
- mWindow = new MainWindow;
-
EVAF_INFO("%s created", qPrintable(objectName()));
}
SdiWindow::Internal::SdiWindowPlugin::~SdiWindowPlugin()
{
- delete mWindow;
+ mWindow.reset();
EVAF_INFO("%s destroyed", qPrintable(objectName()));
}