Fix Project workspace changes lost on save cancel
Fix #9605, close #9609
This commit is contained in:
parent
22e87184aa
commit
a044cefe7c
|
@ -1178,7 +1178,8 @@ Do you want to recover your langs.xml?"/> <!-- HowToReproduce: Close Notepad++.
|
|||
Please remove its root from the panel before you add folder "$STR_REPLACE$"."/> <!-- HowToReproduce: Add a folder like "c:\temp\aFolder\" into "Folder as Workspace" panel, then try to add "c:\temp\". -->
|
||||
|
||||
<ProjectPanelChanged title="$STR_REPLACE$" message="The workspace was modified. Do you want to save it?"/>
|
||||
<ProjectPanelChangedSaveError title="$STR_REPLACE$" message="Your workspace has not been saved."/> <!-- HowToReproduce: this message prevents from system failure. It's hard to reproduce. -->
|
||||
<ProjectPanelSaveError title="$STR_REPLACE$" message="An error occurred while writing your workspace file.
|
||||
Your workspace has not been saved."/> <!-- HowToReproduce: this message prevents from system failure. It's hard to reproduce. -->
|
||||
<ProjectPanelOpenDoSaveDirtyWsOrNot title="Open Workspace" message="The current workspace was modified. Do you want to save the current project?"/>
|
||||
<ProjectPanelNewDoSaveDirtyWsOrNot title="New Workspace" message="The current workspace was modified. Do you want to save the current project?"/>
|
||||
<ProjectPanelOpenFailed title="Open Workspace" message="The workspace could not be opened.
|
||||
|
|
|
@ -191,13 +191,7 @@ bool ProjectPanel::checkIfNeedSave()
|
|||
if (res == IDYES)
|
||||
{
|
||||
if (!saveWorkSpace())
|
||||
pNativeSpeaker->messageBox("ProjectPanelChangedSaveError",
|
||||
_hSelf,
|
||||
TEXT("Your workspace has not been saved."),
|
||||
TEXT("$STR_REPLACE$"),
|
||||
MB_OK | MB_ICONERROR,
|
||||
0,
|
||||
title);
|
||||
return false;
|
||||
}
|
||||
else if (res == IDNO)
|
||||
{
|
||||
|
@ -436,7 +430,9 @@ bool ProjectPanel::saveWorkSpace()
|
|||
}
|
||||
else
|
||||
{
|
||||
writeWorkSpace();
|
||||
if (!writeWorkSpace())
|
||||
return false;
|
||||
|
||||
setWorkSpaceDirty(false);
|
||||
return true;
|
||||
}
|
||||
|
@ -460,9 +456,6 @@ bool ProjectPanel::writeWorkSpace(const TCHAR *projectFileName)
|
|||
if (!tvRoot)
|
||||
return false;
|
||||
|
||||
TCHAR * fileName = PathFindFileName(fn2write);
|
||||
_treeView.renameItem(tvRoot, fileName);
|
||||
|
||||
for (HTREEITEM tvProj = _treeView.getChildFrom(tvRoot);
|
||||
tvProj != NULL;
|
||||
tvProj = _treeView.getNextSibling(tvProj))
|
||||
|
@ -475,7 +468,22 @@ bool ProjectPanel::writeWorkSpace(const TCHAR *projectFileName)
|
|||
projRoot->ToElement()->SetAttribute(TEXT("name"), tvItem.pszText);
|
||||
buildProjectXml(projRoot, tvProj, fn2write);
|
||||
}
|
||||
projDoc.SaveFile();
|
||||
|
||||
if (!projDoc.SaveFile())
|
||||
{
|
||||
const TCHAR * title = _workSpaceFilePath.length() > 0 ? PathFindFileName (_workSpaceFilePath.c_str()) : _panelTitle.c_str();
|
||||
NativeLangSpeaker *pNativeSpeaker = (NppParameters::getInstance()).getNativeLangSpeaker();
|
||||
pNativeSpeaker->messageBox("ProjectPanelSaveError",
|
||||
_hSelf,
|
||||
TEXT("An error occurred while writing your workspace file.\nYour workspace has not been saved."),
|
||||
TEXT("$STR_REPLACE$"),
|
||||
MB_OK | MB_ICONERROR,
|
||||
0,
|
||||
title);
|
||||
return false;
|
||||
}
|
||||
TCHAR * fileName = PathFindFileName(fn2write);
|
||||
_treeView.renameItem(tvRoot, fileName);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1231,17 +1239,18 @@ bool ProjectPanel::saveWorkSpaceAs(bool saveCopyAs)
|
|||
fDlg.setExtIndex(0); // 0 index for "custom extention" type if any else for "All types *.*"
|
||||
|
||||
const generic_string fn = fDlg.doSaveDlg();
|
||||
if (!fn.empty())
|
||||
if (fn.empty())
|
||||
return false;
|
||||
|
||||
if (!writeWorkSpace(fn.c_str()))
|
||||
return false;
|
||||
|
||||
if (!saveCopyAs)
|
||||
{
|
||||
writeWorkSpace(fn.c_str());
|
||||
if (!saveCopyAs)
|
||||
{
|
||||
_workSpaceFilePath = fn;
|
||||
setWorkSpaceDirty(false);
|
||||
}
|
||||
return true;
|
||||
_workSpaceFilePath = fn;
|
||||
setWorkSpaceDirty(false);
|
||||
}
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
void ProjectPanel::setFileExtFilter(CustomFileDialog & fDlg)
|
||||
|
|
Loading…
Reference in New Issue