ProjectExplorer: Fix some problems with plugin unloading

It was not possible to return false from
ProjectExplorerPlugin::initialize() without triggering crashes.

Change-Id: I96b2f80c835e69769f64f9b9c61f473e9ff88623
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Christian Kandeler
2019-10-15 14:08:02 +02:00
parent 42fba8ee3b
commit e90a48e639
6 changed files with 17 additions and 2 deletions

View File

@@ -176,7 +176,7 @@ void FancyToolButton::paintEvent(QPaintEvent *event)
: QIcon::Disabled; : QIcon::Disabled;
QRect iconRect(0, 0, Constants::MODEBAR_ICON_SIZE, Constants::MODEBAR_ICON_SIZE); QRect iconRect(0, 0, Constants::MODEBAR_ICON_SIZE, Constants::MODEBAR_ICON_SIZE);
const bool isTitledAction = defaultAction()->property("titledAction").toBool(); const bool isTitledAction = defaultAction() && defaultAction()->property("titledAction").toBool();
// draw popup texts // draw popup texts
if (isTitledAction && !m_iconsOnly) { if (isTitledAction && !m_iconsOnly) {
QFont normalFont(painter.font()); QFont normalFont(painter.font());
@@ -286,7 +286,7 @@ QSize FancyToolButton::sizeHint() const
} }
QSizeF buttonSize = iconSize().expandedTo(QSize(64, 38)); QSizeF buttonSize = iconSize().expandedTo(QSize(64, 38));
if (defaultAction()->property("titledAction").toBool()) { if (defaultAction() && defaultAction()->property("titledAction").toBool()) {
QFont boldFont(font()); QFont boldFont(font());
boldFont.setPointSizeF(StyleHelper::sidebarFontSize()); boldFont.setPointSizeF(StyleHelper::sidebarFontSize());
boldFont.setBold(true); boldFont.setBold(true);

View File

@@ -238,6 +238,9 @@ void ModeManager::removeMode(IMode *mode)
{ {
const int index = d->m_modes.indexOf(mode); const int index = d->m_modes.indexOf(mode);
d->m_modes.remove(index); d->m_modes.remove(index);
if (d->m_startingUp)
return;
d->m_modeCommands.remove(index); d->m_modeCommands.remove(index);
d->m_modeStack->removeTab(index); d->m_modeStack->removeTab(index);

View File

@@ -115,6 +115,7 @@ IOutputPane::~IOutputPane()
const int i = Utils::indexOf(g_outputPanes, Utils::equal(&OutputPaneData::pane, this)); const int i = Utils::indexOf(g_outputPanes, Utils::equal(&OutputPaneData::pane, this));
QTC_ASSERT(i >= 0, return); QTC_ASSERT(i >= 0, return);
delete g_outputPanes.at(i).button; delete g_outputPanes.at(i).button;
g_outputPanes.removeAt(i);
delete m_zoomInButton; delete m_zoomInButton;
delete m_zoomOutButton; delete m_zoomOutButton;

View File

@@ -2772,6 +2772,8 @@ QPair<bool, QString> ProjectExplorerPluginPrivate::buildSettingsEnabledForSessio
bool ProjectExplorerPlugin::coreAboutToClose() bool ProjectExplorerPlugin::coreAboutToClose()
{ {
if (!m_instance)
return true;
if (BuildManager::isBuilding()) { if (BuildManager::isBuilding()) {
QMessageBox box; QMessageBox box;
QPushButton *closeAnyway = box.addButton(tr("Cancel Build && Close"), QMessageBox::AcceptRole); QPushButton *closeAnyway = box.addButton(tr("Cancel Build && Close"), QMessageBox::AcceptRole);

View File

@@ -156,6 +156,8 @@ SessionManager::SessionManager(QObject *parent) : QObject(parent)
SessionManager::~SessionManager() SessionManager::~SessionManager()
{ {
EditorManager::setWindowTitleAdditionHandler({});
EditorManager::setSessionTitleHandler({});
emit m_instance->aboutToUnloadSession(d->m_sessionName); emit m_instance->aboutToUnloadSession(d->m_sessionName);
delete d->m_writer; delete d->m_writer;
delete d; delete d;

View File

@@ -429,6 +429,13 @@ void WelcomeMode::addPage(IWelcomePage *page)
stackPage->setAutoFillBackground(true); stackPage->setAutoFillBackground(true);
m_pageStack->insertWidget(idx, stackPage); m_pageStack->insertWidget(idx, stackPage);
connect(page, &QObject::destroyed, this, [this, page, stackPage, pageButton] {
m_pluginList.removeOne(page);
m_pageButtons.removeOne(pageButton);
delete pageButton;
delete stackPage;
});
auto onClicked = [this, pageId, stackPage] { auto onClicked = [this, pageId, stackPage] {
m_activePage = pageId; m_activePage = pageId;
m_pageStack->setCurrentWidget(stackPage); m_pageStack->setCurrentWidget(stackPage);