forked from qt-creator/qt-creator
ProjectExplorer: Fix crash on renaming
Nested event loops rearing its ugly head. Avoid all the trouble by opening the message box on the next iteration of the event loop. Task-number: QTCREATORBUG-13428 Change-Id: I3c06d649464c34875da9601fb2e13227a0397836 Reviewed-by: Robert Loehning <robert.loehning@theqtcompany.com> Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
This commit is contained in:
@@ -294,6 +294,7 @@ public:
|
||||
bool m_ignoreDocumentManagerChangedFile;
|
||||
QStringList m_arguments;
|
||||
QList<ProjectPanelFactory *> m_panelFactories;
|
||||
QString m_renameFileError;
|
||||
};
|
||||
|
||||
ProjectExplorerPluginPrivate::ProjectExplorerPluginPrivate() :
|
||||
@@ -3265,11 +3266,12 @@ void ProjectExplorerPlugin::renameFile(Node *node, const QString &to)
|
||||
FolderNode *folderNode = node->parentFolderNode();
|
||||
QString projectDisplayName = folderNode->projectNode()->displayName();
|
||||
if (!folderNode->renameFile(orgFilePath, newFilePath)) {
|
||||
QMessageBox::warning(ICore::mainWindow(), tr("Project Editing Failed"),
|
||||
tr("The file %1 was renamed to %2, but the project file %3 could not be automatically changed.")
|
||||
dd->m_renameFileError = tr("The file %1 was renamed to %2, but the project file %3 could not be automatically changed.")
|
||||
.arg(orgFilePath)
|
||||
.arg(newFilePath)
|
||||
.arg(projectDisplayName));
|
||||
.arg(projectDisplayName);
|
||||
|
||||
QTimer::singleShot(0, m_instance, SLOT(showRenameFileError()));
|
||||
} else {
|
||||
dd->setCurrent(SessionManager::projectForFile(newFilePath), newFilePath, 0);
|
||||
}
|
||||
@@ -3281,6 +3283,11 @@ void ProjectExplorerPlugin::setStartupProject()
|
||||
setStartupProject(dd->m_currentProject);
|
||||
}
|
||||
|
||||
void ProjectExplorerPlugin::showRenameFileError()
|
||||
{
|
||||
QMessageBox::warning(ICore::mainWindow(), tr("Project Editing Failed"), dd->m_renameFileError);
|
||||
}
|
||||
|
||||
void ProjectExplorerPlugin::populateOpenWithMenu()
|
||||
{
|
||||
DocumentManager::populateOpenWithMenu(dd->m_openWithMenu, currentNode()->path());
|
||||
|
@@ -230,6 +230,7 @@ private slots:
|
||||
void updateActions();
|
||||
void updateContext();
|
||||
void runConfigurationConfigurationFinished();
|
||||
void showRenameFileError();
|
||||
|
||||
#ifdef WITH_TESTS
|
||||
void testAnsiFilterOutputParser_data();
|
||||
|
Reference in New Issue
Block a user