Skip to content

Commit 172be66

Browse files
committed
Crash bug fixed on using runMenuCommand and runPluginCommand
- Proof that multiple returns are BAD! I'm ashamed this was me. And untested since the threading was added.
1 parent 6db08ec commit 172be66

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

PythonScript/src/NotepadPlusWrapper.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,8 @@ boost::python::str NotepadPlusWrapper::getCurrentFilename()
753753

754754
bool NotepadPlusWrapper::runPluginCommand(boost::python::str pluginName, boost::python::str menuOption)
755755
{
756-
756+
bool retVal = false;
757+
757758
MenuManager *menuManager = MenuManager::getInstance();
758759
if (!pluginName.is_none() && !menuOption.is_none())
759760
{
@@ -764,16 +765,17 @@ bool NotepadPlusWrapper::runPluginCommand(boost::python::str pluginName, boost::
764765
if (commandID)
765766
{
766767
::SendMessage(m_nppHandle, WM_COMMAND, commandID, 0);
767-
return true;
768+
retVal = true;
768769
}
769770
Py_END_ALLOW_THREADS
770771
}
771-
return false;
772+
return retVal;
772773

773774
}
774775

775776
bool NotepadPlusWrapper::runMenuCommand(boost::python::str menuName, boost::python::str menuOption)
776777
{
778+
bool retVal = false;
777779
MenuManager *menuManager = MenuManager::getInstance();
778780
if (!menuName.is_none() && !menuOption.is_none())
779781
{
@@ -784,10 +786,10 @@ bool NotepadPlusWrapper::runMenuCommand(boost::python::str menuName, boost::pyth
784786
if (commandID)
785787
{
786788
::SendMessage(m_nppHandle, WM_COMMAND, commandID, 0);
787-
return true;
789+
retVal = true;
788790
}
789791
Py_END_ALLOW_THREADS
790792
}
791-
return false;
793+
return retVal;
792794

793795
}

0 commit comments

Comments
 (0)