summaryrefslogtreecommitdiffstats
path: root/Source/QtDialog
diff options
context:
space:
mode:
authorMarc Chevrier <marc.chevrier@gmail.com>2020-03-02 09:41:17 (GMT)
committerBrad King <brad.king@kitware.com>2020-03-05 12:34:01 (GMT)
commit9de0355d4f8f56a71f3d18b1b2c3d50dc8624aae (patch)
treeec6050654d073ec970e81fe51d95cf0110d02efd /Source/QtDialog
parent07a7bc0e3fc370eaa5593cffcd07c0ea739cfc9c (diff)
downloadCMake-9de0355d4f8f56a71f3d18b1b2c3d50dc8624aae.zip
CMake-9de0355d4f8f56a71f3d18b1b2c3d50dc8624aae.tar.gz
CMake-9de0355d4f8f56a71f3d18b1b2c3d50dc8624aae.tar.bz2
Modernize memory management
Update internals of various classes.
Diffstat (limited to 'Source/QtDialog')
-rw-r--r--Source/QtDialog/CMakeSetupDialog.cxx13
-rw-r--r--Source/QtDialog/CMakeSetupDialog.h4
-rw-r--r--Source/QtDialog/QCMake.cxx11
-rw-r--r--Source/QtDialog/QCMake.h3
4 files changed, 16 insertions, 15 deletions
diff --git a/Source/QtDialog/CMakeSetupDialog.cxx b/Source/QtDialog/CMakeSetupDialog.cxx
index 436a904..276bf64 100644
--- a/Source/QtDialog/CMakeSetupDialog.cxx
+++ b/Source/QtDialog/CMakeSetupDialog.cxx
@@ -2,6 +2,8 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "CMakeSetupDialog.h"
+#include <cm/memory>
+
#include <QCloseEvent>
#include <QCoreApplication>
#include <QDesktopServices>
@@ -39,23 +41,21 @@
QCMakeThread::QCMakeThread(QObject* p)
: QThread(p)
- , CMakeInstance(nullptr)
{
}
QCMake* QCMakeThread::cmakeInstance() const
{
- return this->CMakeInstance;
+ return this->CMakeInstance.get();
}
void QCMakeThread::run()
{
- this->CMakeInstance = new QCMake;
+ this->CMakeInstance = cm::make_unique<QCMake>();
// emit that this cmake thread is ready for use
emit this->cmakeInitialized();
this->exec();
- delete this->CMakeInstance;
- this->CMakeInstance = nullptr;
+ this->CMakeInstance.reset();
}
CMakeSetupDialog::CMakeSetupDialog()
@@ -1206,7 +1206,7 @@ void CMakeSetupDialog::setSearchFilter(const QString& str)
void CMakeSetupDialog::doOutputContextMenu(QPoint pt)
{
- QMenu* menu = this->Output->createStandardContextMenu();
+ std::unique_ptr<QMenu> menu(this->Output->createStandardContextMenu());
menu->addSeparator();
menu->addAction(tr("Find..."), this, SLOT(doOutputFindDialog()),
@@ -1220,7 +1220,6 @@ void CMakeSetupDialog::doOutputContextMenu(QPoint pt)
QKeySequence(Qt::Key_F8));
menu->exec(this->Output->mapToGlobal(pt));
- delete menu;
}
void CMakeSetupDialog::doOutputFindDialog()
diff --git a/Source/QtDialog/CMakeSetupDialog.h b/Source/QtDialog/CMakeSetupDialog.h
index f23aee6..d1e2035 100644
--- a/Source/QtDialog/CMakeSetupDialog.h
+++ b/Source/QtDialog/CMakeSetupDialog.h
@@ -3,6 +3,8 @@
#ifndef CMakeSetupDialog_h
#define CMakeSetupDialog_h
+#include <memory>
+
#include "QCMake.h"
#include <QEventLoop>
#include <QMainWindow>
@@ -143,7 +145,7 @@ signals:
protected:
virtual void run();
- QCMake* CMakeInstance;
+ std::unique_ptr<QCMake> CMakeInstance;
};
#endif // CMakeSetupDialog_h
diff --git a/Source/QtDialog/QCMake.cxx b/Source/QtDialog/QCMake.cxx
index 3b5dc04..c3e9c84 100644
--- a/Source/QtDialog/QCMake.cxx
+++ b/Source/QtDialog/QCMake.cxx
@@ -2,6 +2,8 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "QCMake.h"
+#include <cm/memory>
+
#include <QCoreApplication>
#include <QDir>
@@ -35,7 +37,8 @@ QCMake::QCMake(QObject* p)
cmSystemTools::SetStderrCallback(
[this](std::string const& msg) { this->stderrCallback(msg); });
- this->CMakeInstance = new cmake(cmake::RoleProject, cmState::Project);
+ this->CMakeInstance =
+ cm::make_unique<cmake>(cmake::RoleProject, cmState::Project);
this->CMakeInstance->SetCMakeEditCommand(
cmSystemTools::GetCMakeGUICommand());
this->CMakeInstance->SetProgressCallback(
@@ -55,11 +58,7 @@ QCMake::QCMake(QObject* p)
}
}
-QCMake::~QCMake()
-{
- delete this->CMakeInstance;
- // cmDynamicLoader::FlushCache();
-}
+QCMake::~QCMake() = default;
void QCMake::loadCache(const QString& dir)
{
diff --git a/Source/QtDialog/QCMake.h b/Source/QtDialog/QCMake.h
index fa4451b..110a971 100644
--- a/Source/QtDialog/QCMake.h
+++ b/Source/QtDialog/QCMake.h
@@ -12,6 +12,7 @@
# pragma warning(disable : 4512)
#endif
+#include <memory>
#include <vector>
#include <QAtomicInt>
@@ -165,7 +166,7 @@ signals:
void openPossible(bool possible);
protected:
- cmake* CMakeInstance;
+ std::unique_ptr<cmake> CMakeInstance;
bool interruptCallback();
void progressCallback(std::string const& msg, float percent);