diff --git a/toonz/sources/tnztools/tooloptions.cpp b/toonz/sources/tnztools/tooloptions.cpp index 10ab2db..c9f2dd4 100644 --- a/toonz/sources/tnztools/tooloptions.cpp +++ b/toonz/sources/tnztools/tooloptions.cpp @@ -2803,27 +2803,34 @@ ToolOptions::~ToolOptions() {} void ToolOptions::showEvent(QShowEvent *) { TTool::Application *app = TTool::getApplication(); - ToolHandle *currTool = app->getCurrentTool(); - if (currTool) { + + if (ToolHandle *currTool = app->getCurrentTool()) + currTool->disconnect(this); + if (TObjectHandle *currObject = app->getCurrentObject()) + currObject->disconnect(this); + if (TXshLevelHandle *currLevel = app->getCurrentLevel()) + currLevel->disconnect(this); + + if (ToolHandle *currTool = app->getCurrentTool()) { + currTool->disconnect(this); onToolSwitched(); connect(currTool, SIGNAL(toolSwitched()), SLOT(onToolSwitched())); connect(currTool, SIGNAL(toolOptionsBoxChanged()), SLOT(onToolOptionsBoxChanged())); connect(currTool, SIGNAL(toolChanged()), SLOT(onToolChanged())); } - TObjectHandle *currObject = app->getCurrentObject(); - if (currObject) { + if (TObjectHandle *currObject = app->getCurrentObject()) { + currObject->disconnect(this); onStageObjectChange(); connect(currObject, SIGNAL(objectSwitched()), SLOT(onStageObjectChange())); connect(currObject, SIGNAL(objectChanged(bool)), SLOT(onStageObjectChange())); } - TXshLevelHandle *currLevel = app->getCurrentLevel(); - - if (currLevel) + if (TXshLevelHandle *currLevel = app->getCurrentLevel()) { connect(currLevel, SIGNAL(xshLevelSwitched(TXshLevel *)), this, SLOT(onStageObjectChange())); + } } //-----------------------------------------------------------------------------