diff --git a/src/plugins/qmlprofiler/qmlprofilerplugin.cpp b/src/plugins/qmlprofiler/qmlprofilerplugin.cpp
index 23dcfaf3f4e6407d3acffb8bbf927b375eae4bed..d8781df9badf1582d25fb65f5b59a3392dd8f6e3 100644
--- a/src/plugins/qmlprofiler/qmlprofilerplugin.cpp
+++ b/src/plugins/qmlprofiler/qmlprofilerplugin.cpp
@@ -89,7 +89,7 @@ bool QmlProfilerPlugin::initialize(const QStringList &arguments, QString *errorS
 
 void QmlProfilerPlugin::extensionsInitialized()
 {
-    (void) new QmlProfilerTool(this);
+    m_profilerTool = new QmlProfilerTool(this);
 
     addAutoReleasedObject(new QmlProfilerOptionsPage);
 
@@ -111,6 +111,8 @@ void QmlProfilerPlugin::extensionsInitialized()
 
 ExtensionSystem::IPlugin::ShutdownFlag QmlProfilerPlugin::aboutToShutdown()
 {
+    delete m_profilerTool;
+
     // Save settings.
     // Disconnect from signals that are not needed during shutdown
     // Hide UI (if you add UI that is not in the main window directly)
diff --git a/src/plugins/qmlprofiler/qmlprofilerplugin.h b/src/plugins/qmlprofiler/qmlprofilerplugin.h
index 3175fa917a6128dea706854c970e0457b7ce2bce..bd38d6964fd3bd0870dd3837300a2b836d49ddd6 100644
--- a/src/plugins/qmlprofiler/qmlprofilerplugin.h
+++ b/src/plugins/qmlprofiler/qmlprofilerplugin.h
@@ -34,6 +34,8 @@
 namespace QmlProfiler {
 namespace Internal {
 
+class QmlProfilerTool;
+
 class QmlProfilerPlugin : public ExtensionSystem::IPlugin
 {
     Q_OBJECT
@@ -47,6 +49,9 @@ public:
     static QmlProfilerSettings *globalSettings();
 
     QList<QObject *> createTestObjects() const override;
+
+private:
+    QmlProfilerTool *m_profilerTool;
 };
 
 } // namespace Internal
diff --git a/src/plugins/qmlprofiler/qmlprofilerruncontrol.cpp b/src/plugins/qmlprofiler/qmlprofilerruncontrol.cpp
index 90608cbb1f2aa48bda8df9b94c9c702216a5c22d..949eab3176a75b369c99a395398f956af24dc382 100644
--- a/src/plugins/qmlprofiler/qmlprofilerruncontrol.cpp
+++ b/src/plugins/qmlprofiler/qmlprofilerruncontrol.cpp
@@ -64,7 +64,7 @@ static QString QmlServerUrl = "QmlServerUrl";
 class QmlProfilerRunner::QmlProfilerRunnerPrivate
 {
 public:
-    QmlProfilerStateManager *m_profilerState = 0;
+    QPointer<QmlProfilerStateManager> m_profilerState;
 };
 
 //