From 32c6a0b3939516514e911ec5a9449f58427df2af Mon Sep 17 00:00:00 2001 From: Don Ho Date: Sat, 29 Jun 2013 18:53:01 +0000 Subject: [PATCH] [BUG_FIXD] Fix a crash bug of dockable dialog due to optimization of loop. [ENHANCEMENT] functionList.xml will be copied in the %appdata%\notepad++\ if doLocalConf.xml is not present. git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@1063 f5eea248-9336-0410-98b8-ebc06183d4e3 --- .../WinControls/DockingWnd/DockingCont.cpp | 3 +- .../FunctionList/functionListPanel.cpp | 37 +++++++++++++++++-- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/PowerEditor/src/WinControls/DockingWnd/DockingCont.cpp b/PowerEditor/src/WinControls/DockingWnd/DockingCont.cpp index cb15ac631..a35e9b4f2 100644 --- a/PowerEditor/src/WinControls/DockingWnd/DockingCont.cpp +++ b/PowerEditor/src/WinControls/DockingWnd/DockingCont.cpp @@ -154,7 +154,8 @@ tTbData* DockingCont::createToolbar(tTbData data) void DockingCont::removeToolbar(tTbData TbData) { // remove from list - for (size_t iTb = 0, len = _vTbData.size(); iTb < len; iTb++) + // items in _vTbData are removed in the loop so _vTbData.size() should be checked in every iteration + for (size_t iTb = 0 ; iTb < _vTbData.size(); iTb++) { if (_vTbData[iTb]->hClient == TbData.hClient) { diff --git a/PowerEditor/src/WinControls/FunctionList/functionListPanel.cpp b/PowerEditor/src/WinControls/FunctionList/functionListPanel.cpp index c34a4ffa4..b8aff77ad 100644 --- a/PowerEditor/src/WinControls/FunctionList/functionListPanel.cpp +++ b/PowerEditor/src/WinControls/FunctionList/functionListPanel.cpp @@ -241,11 +241,42 @@ void FunctionListPanel::reload() void FunctionListPanel::init(HINSTANCE hInst, HWND hPere, ScintillaEditView **ppEditView) { - DockingDlgInterface::init(hInst, hPere); - _ppEditView = ppEditView; + DockingDlgInterface::init(hInst, hPere); + _ppEditView = ppEditView; + bool isOK = false; + bool doLocalConf = (NppParameters::getInstance())->isLocal(); + + if (!doLocalConf) + { generic_string funcListXmlPath = (NppParameters::getInstance())->getUserPath(); PathAppend(funcListXmlPath, TEXT("functionList.xml")); - _funcParserMgr.init(funcListXmlPath, ppEditView); + + if (!PathFileExists(funcListXmlPath.c_str())) + { + generic_string funcListDefaultXmlPath = (NppParameters::getInstance())->getNppPath(); + PathAppend(funcListDefaultXmlPath, TEXT("functionList.xml")); + if (PathFileExists(funcListDefaultXmlPath.c_str())) + { + ::CopyFile(funcListDefaultXmlPath.c_str(), funcListXmlPath.c_str(), TRUE); + isOK = _funcParserMgr.init(funcListXmlPath, ppEditView); + } + } + else + { + isOK = _funcParserMgr.init(funcListXmlPath, ppEditView); + } + } + else + { + generic_string funcListDefaultXmlPath = (NppParameters::getInstance())->getNppPath(); + PathAppend(funcListDefaultXmlPath, TEXT("functionList.xml")); + if (PathFileExists(funcListDefaultXmlPath.c_str())) + { + isOK = _funcParserMgr.init(funcListDefaultXmlPath, ppEditView); + } + } + + //return isOK; } bool FunctionListPanel::openSelection()