+ duplicate string array for Python commands

This commit is contained in:
wmayer 2015-09-20 14:11:53 +02:00
parent 1dad42c2f6
commit ec91085765
2 changed files with 33 additions and 6 deletions

View File

@ -694,6 +694,12 @@ MacroCommand::MacroCommand(const char* name)
eType = 0;
}
MacroCommand::~MacroCommand()
{
free(const_cast<char*>(sName));
sName = 0;
}
void MacroCommand::activated(int iMsg)
{
std::string cMacroPath = App::GetApplication().GetParameterGroupByPath
@ -795,7 +801,12 @@ void MacroCommand::save()
//===========================================================================
PythonCommand::PythonCommand(const char* name, PyObject * pcPyCommand, const char* pActivationString)
: Command(name),_pcPyCommand(pcPyCommand)
#if defined (_MSC_VER)
: Command( _strdup(name) )
#else
: Command( strdup(name) )
#endif
,_pcPyCommand(pcPyCommand)
{
if (pActivationString)
Activation = pActivationString;
@ -828,6 +839,14 @@ PythonCommand::PythonCommand(const char* name, PyObject * pcPyCommand, const cha
}
}
PythonCommand::~PythonCommand()
{
Base::PyGILStateLocker lock;
Py_DECREF(_pcPyCommand);
free(const_cast<char*>(sName));
sName = 0;
}
const char* PythonCommand::getResource(const char* sName) const
{
PyObject* pcTemp;
@ -998,7 +1017,12 @@ bool PythonCommand::isChecked() const
//===========================================================================
PythonGroupCommand::PythonGroupCommand(const char* name, PyObject * pcPyCommand)
: Command(name),_pcPyCommand(pcPyCommand)
#if defined (_MSC_VER)
: Command( _strdup(name) )
#else
: Command( strdup(name) )
#endif
,_pcPyCommand(pcPyCommand)
{
sGroup = "Python";
@ -1032,6 +1056,8 @@ PythonGroupCommand::~PythonGroupCommand()
{
Base::PyGILStateLocker lock;
Py_DECREF(_pcPyCommand);
free(const_cast<char*>(sName));
sName = 0;
}
void PythonGroupCommand::activated(int iMsg)

View File

@ -69,11 +69,12 @@ void CreateTestCommands(void);
*/
class GuiExport CommandBase
{
public:
protected:
CommandBase(const char* sMenu, const char* sToolTip=0, const char* sWhat=0,
const char* sStatus=0, const char* sPixmap=0, const char* sAccel=0);
virtual ~CommandBase();
public:
/**
* Returns the Action object of this command, or 0 if it doesn't exist.
*/
@ -148,7 +149,7 @@ protected:
*/
class GuiExport Command : public CommandBase
{
public:
protected:
Command(const char* name);
virtual ~Command();
@ -323,7 +324,7 @@ class PythonCommand: public Command
{
public:
PythonCommand(const char* name, PyObject * pcPyCommand, const char* pActivationString);
virtual ~PythonCommand() {}
virtual ~PythonCommand();
protected:
/** @name Methods reimplemented for Command Framework */
@ -429,7 +430,7 @@ class MacroCommand: public Command
{
public:
MacroCommand(const char* name);
virtual ~MacroCommand() {}
virtual ~MacroCommand();
protected:
/** @name methods reimplemented for Command Framework */