Fix crash issue while passing argument "-export=functionList"

This regression is due to commit 7399257f56
(7399257f56)
This commit is contained in:
Don HO 2020-11-11 02:23:24 +01:00
parent 5813e4d8e6
commit bbeb66aa56
No known key found for this signature in database
GPG Key ID: 6C429F1D8D84F46E
2 changed files with 46 additions and 25 deletions

View File

@ -5528,28 +5528,27 @@ void NppParameters::feedDockingManager(TiXmlNode *node)
} }
} }
TiXmlElement NppParameters::duplicateDockingManager(TiXmlNode *node) void NppParameters::duplicateDockingManager(TiXmlNode* dockMngNode, TiXmlElement* dockMngElmt2Clone)
{ {
TiXmlElement *element = node->ToElement(); if (!dockMngNode || !dockMngElmt2Clone) return;
TiXmlElement DMNode(TEXT("GUIConfig")); TiXmlElement *dockMngElmt = dockMngNode->ToElement();
DMNode.SetAttribute(TEXT("name"), TEXT("DockingManager"));
int i; int i;
if (element->Attribute(TEXT("leftWidth"), &i)) if (dockMngElmt->Attribute(TEXT("leftWidth"), &i))
DMNode.SetAttribute(TEXT("leftWidth"), i); dockMngElmt2Clone->SetAttribute(TEXT("leftWidth"), i);
if (element->Attribute(TEXT("rightWidth"), &i)) if (dockMngElmt->Attribute(TEXT("rightWidth"), &i))
DMNode.SetAttribute(TEXT("rightWidth"), i); dockMngElmt2Clone->SetAttribute(TEXT("rightWidth"), i);
if (element->Attribute(TEXT("topHeight"), &i)) if (dockMngElmt->Attribute(TEXT("topHeight"), &i))
DMNode.SetAttribute(TEXT("topHeight"), i); dockMngElmt2Clone->SetAttribute(TEXT("topHeight"), i);
if (element->Attribute(TEXT("bottomHeight"), &i)) if (dockMngElmt->Attribute(TEXT("bottomHeight"), &i))
DMNode.SetAttribute(TEXT("bottomHeight"), i); dockMngElmt2Clone->SetAttribute(TEXT("bottomHeight"), i);
for (TiXmlNode *childNode = node->FirstChildElement(TEXT("FloatingWindow")); for (TiXmlNode *childNode = dockMngNode->FirstChildElement(TEXT("FloatingWindow"));
childNode; childNode;
childNode = childNode->NextSibling(TEXT("FloatingWindow"))) childNode = childNode->NextSibling(TEXT("FloatingWindow")))
{ {
@ -5577,11 +5576,11 @@ TiXmlElement NppParameters::duplicateDockingManager(TiXmlNode *node)
floatElement->Attribute(TEXT("height"), &h); floatElement->Attribute(TEXT("height"), &h);
FWNode.SetAttribute(TEXT("height"), h); FWNode.SetAttribute(TEXT("height"), h);
DMNode.InsertEndChild(FWNode); dockMngElmt2Clone->InsertEndChild(FWNode);
} }
} }
for (TiXmlNode *childNode = node->FirstChildElement(TEXT("PluginDlg")); for (TiXmlNode *childNode = dockMngNode->FirstChildElement(TEXT("PluginDlg"));
childNode; childNode;
childNode = childNode->NextSibling(TEXT("PluginDlg"))) childNode = childNode->NextSibling(TEXT("PluginDlg")))
{ {
@ -5612,11 +5611,11 @@ TiXmlElement NppParameters::duplicateDockingManager(TiXmlNode *node)
PDNode.SetAttribute(TEXT("prev"), prev); PDNode.SetAttribute(TEXT("prev"), prev);
PDNode.SetAttribute(TEXT("isVisible"), isVisible ? TEXT("yes") : TEXT("no")); PDNode.SetAttribute(TEXT("isVisible"), isVisible ? TEXT("yes") : TEXT("no"));
DMNode.InsertEndChild(PDNode); dockMngElmt2Clone->InsertEndChild(PDNode);
} }
} }
for (TiXmlNode *childNode = node->FirstChildElement(TEXT("ActiveTabs")); for (TiXmlNode *childNode = dockMngNode->FirstChildElement(TEXT("ActiveTabs"));
childNode; childNode;
childNode = childNode->NextSibling(TEXT("ActiveTabs"))) childNode = childNode->NextSibling(TEXT("ActiveTabs")))
{ {
@ -5631,11 +5630,9 @@ TiXmlElement NppParameters::duplicateDockingManager(TiXmlNode *node)
CTNode.SetAttribute(TEXT("cont"), cont); CTNode.SetAttribute(TEXT("cont"), cont);
CTNode.SetAttribute(TEXT("activeTab"), activeTab); CTNode.SetAttribute(TEXT("activeTab"), activeTab);
DMNode.InsertEndChild(CTNode); dockMngElmt2Clone->InsertEndChild(CTNode);
} }
} }
return DMNode;
} }
bool NppParameters::writeScintillaParams() bool NppParameters::writeScintillaParams()
@ -5710,11 +5707,34 @@ void NppParameters::createXmlTreeFromGUIParams()
} }
TiXmlNode *oldGUIRoot = nppRoot->FirstChildElement(TEXT("GUIConfigs")); TiXmlNode *oldGUIRoot = nppRoot->FirstChildElement(TEXT("GUIConfigs"));
TiXmlElement dockMngNode(TEXT("")); TiXmlElement* dockMngNodeDup = nullptr;
TiXmlNode* dockMngNodeOriginal = nullptr;
if (_nppGUI._isCmdlineNosessionActivated) if (_nppGUI._isCmdlineNosessionActivated)
{ {
for (TiXmlNode *childNode = oldGUIRoot->FirstChildElement(TEXT("GUIConfig"));
childNode;
childNode = childNode->NextSibling(TEXT("GUIConfig")))
{
TiXmlElement* element = childNode->ToElement();
const TCHAR* nm = element->Attribute(TEXT("name"));
if (nullptr == nm)
continue;
if (!lstrcmp(nm, TEXT("DockingManager")))
{
dockMngNodeOriginal = childNode;
break;
}
}
// Copy DockingParamNode // Copy DockingParamNode
dockMngNode = duplicateDockingManager(oldGUIRoot); if (dockMngNodeOriginal)
{
dockMngNodeDup = new TiXmlElement(TEXT("GUIConfig"));
dockMngNodeDup->SetAttribute(TEXT("name"), TEXT("DockingManager"));
duplicateDockingManager(dockMngNodeOriginal, dockMngNodeDup);
}
} }
// Remove the old root nod if it exist // Remove the old root nod if it exist
@ -6171,9 +6191,10 @@ void NppParameters::createXmlTreeFromGUIParams()
// <GUIConfig name="DockingManager" leftWidth="328" rightWidth="359" topHeight="200" bottomHeight="436"> // <GUIConfig name="DockingManager" leftWidth="328" rightWidth="359" topHeight="200" bottomHeight="436">
// ... // ...
if (_nppGUI._isCmdlineNosessionActivated) if (_nppGUI._isCmdlineNosessionActivated && dockMngNodeDup)
{ {
newGUIRoot->InsertEndChild(dockMngNode); newGUIRoot->InsertEndChild(*dockMngNodeDup);
delete dockMngNodeDup;
} }
else else
{ {

View File

@ -1852,7 +1852,7 @@ private:
void feedFileListParameters(TiXmlNode *node); void feedFileListParameters(TiXmlNode *node);
void feedScintillaParam(TiXmlNode *node); void feedScintillaParam(TiXmlNode *node);
void feedDockingManager(TiXmlNode *node); void feedDockingManager(TiXmlNode *node);
TiXmlElement duplicateDockingManager(TiXmlNode *node); void duplicateDockingManager(TiXmlNode *dockMngNode, TiXmlElement* dockMngElmt2Clone);
void feedFindHistoryParameters(TiXmlNode *node); void feedFindHistoryParameters(TiXmlNode *node);
void feedProjectPanelsParameters(TiXmlNode *node); void feedProjectPanelsParameters(TiXmlNode *node);
void feedFileBrowserParameters(TiXmlNode *node); void feedFileBrowserParameters(TiXmlNode *node);