Remove PlayState as Context observer when ~PlayState is called (fix #682)

To do this we just use a ScopedConnection (which automatically disconnect
the connection in its destructor).
This commit is contained in:
David Capello 2015-06-02 11:03:04 -03:00
parent df29126353
commit cd922fc4c2
2 changed files with 9 additions and 1 deletions

View File

@ -21,6 +21,8 @@
#include "ui/message.h"
#include "ui/system.h"
#include "ui/manager.h"
namespace app {
using namespace ui;
@ -148,6 +150,11 @@ void PlayState::onPlaybackTick()
// Before executing any command, we stop the animation
void PlayState::onBeforeCommandExecution(Command* command)
{
// This check just in case we stay connected to context signals when
// the editor is already deleted.
ASSERT(m_editor);
ASSERT(m_editor->getManager() == ui::Manager::getDefault());
// If the command is for other editor, we don't stop the animation.
if (!m_editor->isActive())
return;

View File

@ -10,6 +10,7 @@
#pragma once
#include "app/ui/editor/state_with_wheel_behavior.h"
#include "base/connection.h"
#include "doc/frame.h"
#include "ui/timer.h"
@ -49,7 +50,7 @@ namespace app {
bool m_pingPongForward;
doc::frame_t m_refFrame;
Connection m_ctxConn;
ScopedConnection m_ctxConn;
};
} // namespace app