From 7b043ba1d7a8c5bfc1eb4b3b65f03bd74d4dbd88 Mon Sep 17 00:00:00 2001 From: Tobias Hunger <tobias.hunger@nokia.com> Date: Thu, 21 Oct 2010 11:54:11 +0200 Subject: [PATCH] Stop navigationwidget from going haywire Stop navigationwidget from going haywire when faced with old configuration data. This issue could lead to different effects: * A crash * Creator not being able to exit anymore * The sidebar being messed up Task-number: QTCREATORBUG-2780 Reviewed-by: con --- src/plugins/coreplugin/navigationwidget.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/plugins/coreplugin/navigationwidget.cpp b/src/plugins/coreplugin/navigationwidget.cpp index 1766774d81a..30bcf48c098 100644 --- a/src/plugins/coreplugin/navigationwidget.cpp +++ b/src/plugins/coreplugin/navigationwidget.cpp @@ -165,7 +165,6 @@ NavigationWidget::NavigationWidget(QAction *toggleSideBarAction) : { d->m_factoryModel->setSortRole(FactoryPriorityRole); setOrientation(Qt::Vertical); - insertSubItem(0, -1); // we don't have any entry to show yet d->m_instance = this; } @@ -327,17 +326,22 @@ void NavigationWidget::restoreSettings(QSettings *settings) settings->setValue("Navigation/Version", 2); } - for (int i=0; i<viewIds.count(); ++i) { - const QString &view = viewIds.at(i); - int index = factoryIndex(view); - - if (i >= d->m_subWidgets.size()) { - insertSubItem(i, index); + int position = 0; + foreach (const QString &id, viewIds) { + int index = factoryIndex(id); + if (index >= 0) { + // Only add if the id was actually found! + insertSubItem(position, index); + ++position; } else { - d->m_subWidgets.at(i)->setFactoryIndex(index); + restoreSplitterState = false; } } + if (d->m_subWidgets.isEmpty()) + // Make sure we have at least the projects widget + insertSubItem(0, qMax(0, factoryIndex(QLatin1String("Projects")))); + if (settings->contains("Navigation/Visible")) { setShown(settings->value("Navigation/Visible").toBool()); } else { -- GitLab