forked from qt-creator/qt-creator
Fix the "Cannot remove a null widget" warning
After the 867c0b8d8a53974074b1fff5b132f3ae9f150066 got integrated into qtbase, Qt started issuing a warning on Creator shutdown. The reason is that mode's widget might be deleted before the mode's destruction. Deleting the mode's widget removes it automatically from the contained stacked layout of the mode manager. This means that the indices inside the stacked layout and those inside the ModeManager's d->m_modes list are now out of sync. FancyTabWidget::removeTab() can't find the right widget for the passed index now or returns wrong widget for it. The fix is to remove removeMode() method (and in turn some more unused now). The context objects don't need to be removed on shutdown, and the remaining mode's widgets will be deleted by Qt itself when the main windows is destroyed. Fixes: QTCREATORBUG-25925 Change-Id: I70c2773eea2984c5d06ce3bf71a4271b267efbe0 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -275,19 +275,6 @@ void ModeManagerPrivate::enabledStateChanged(IMode *mode)
|
||||
}
|
||||
}
|
||||
|
||||
void ModeManager::removeMode(IMode *mode)
|
||||
{
|
||||
const int index = d->m_modes.indexOf(mode);
|
||||
d->m_modes.remove(index);
|
||||
if (d->m_startingUp)
|
||||
return;
|
||||
|
||||
d->m_modeCommands.remove(index);
|
||||
d->m_modeStack->removeTab(index);
|
||||
|
||||
d->m_mainWindow->removeContextObject(mode);
|
||||
}
|
||||
|
||||
/*!
|
||||
Adds the \a action to the mode selector's tool bar.
|
||||
Actions are sorted by \a priority in descending order.
|
||||
|
||||
Reference in New Issue
Block a user