Plugins: Fix nullptr access

Some plugins access their private "d" member in their destructor.
If Plugin initialization failed, these might not have been created.

This would lead to a crash.

Change-Id: Ifd916daf90ebac9a8933dd5489ec1ac0a38254a0
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Marcus Tillmanns
2022-09-01 09:18:16 +02:00
parent dc3eae230f
commit b17cf5f117
3 changed files with 6 additions and 0 deletions

View File

@@ -788,6 +788,8 @@ ProjectExplorerPlugin::ProjectExplorerPlugin()
ProjectExplorerPlugin::~ProjectExplorerPlugin() ProjectExplorerPlugin::~ProjectExplorerPlugin()
{ {
QTC_ASSERT(dd, return);
delete dd->m_proWindow; // Needs access to the kit manager. delete dd->m_proWindow; // Needs access to the kit manager.
JsonWizardFactory::destroyAllFactories(); JsonWizardFactory::destroyAllFactories();

View File

@@ -100,6 +100,8 @@ public:
QmlProjectPlugin::~QmlProjectPlugin() QmlProjectPlugin::~QmlProjectPlugin()
{ {
QTC_ASSERT(d, return);
if (d->lastMessageBox) if (d->lastMessageBox)
d->lastMessageBox->deleteLater(); d->lastMessageBox->deleteLater();
if (d->landingPage) if (d->landingPage)

View File

@@ -24,6 +24,7 @@
#include <utils/futuresynchronizer.h> #include <utils/futuresynchronizer.h>
#include <utils/macroexpander.h> #include <utils/macroexpander.h>
#include <utils/qtcassert.h>
#include <QDebug> #include <QDebug>
@@ -51,6 +52,7 @@ VcsPlugin::VcsPlugin()
VcsPlugin::~VcsPlugin() VcsPlugin::~VcsPlugin()
{ {
QTC_ASSERT(d, return);
d->m_synchronizer.waitForFinished(); d->m_synchronizer.waitForFinished();
VcsOutputWindow::destroy(); VcsOutputWindow::destroy();
m_instance = nullptr; m_instance = nullptr;