mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-02 11:59:58 +00:00
Fix crash changing opaque/transparent color on MovingPixelsState state
The MovingPixelsState() ctor was generating a MovingPixelsState::onTransparentColorChange() for the previous state with a m_pixelsMovement==nullptr.
This commit is contained in:
parent
93d59f87e9
commit
54e8a59cbd
@ -52,7 +52,8 @@ namespace app {
|
||||
using namespace ui;
|
||||
|
||||
MovingPixelsState::MovingPixelsState(Editor* editor, MouseMessage* msg, PixelsMovementPtr pixelsMovement, HandleType handle)
|
||||
: m_editor(editor)
|
||||
: m_pixelsMovement(pixelsMovement)
|
||||
, m_editor(editor)
|
||||
, m_observingEditor(false)
|
||||
, m_discarded(false)
|
||||
{
|
||||
@ -63,8 +64,6 @@ MovingPixelsState::MovingPixelsState(Editor* editor, MouseMessage* msg, PixelsMo
|
||||
|
||||
UIContext* context = UIContext::instance();
|
||||
|
||||
m_pixelsMovement = pixelsMovement;
|
||||
|
||||
if (handle != NoHandle) {
|
||||
gfx::Point pt = editor->screenToEditor(msg->position());
|
||||
m_pixelsMovement->catchImage(pt, handle);
|
||||
@ -111,9 +110,9 @@ MovingPixelsState::~MovingPixelsState()
|
||||
contextBar->remove_observer(this);
|
||||
contextBar->updateForActiveTool();
|
||||
|
||||
m_pixelsMovement.reset(NULL);
|
||||
|
||||
removePixelsMovement();
|
||||
removeAsEditorObserver();
|
||||
|
||||
m_editor->manager()->removeMessageFilter(kKeyDownMessage, m_editor);
|
||||
m_editor->manager()->removeMessageFilter(kKeyUpMessage, m_editor);
|
||||
|
||||
@ -176,7 +175,7 @@ EditorState::LeaveAction MovingPixelsState::onLeaveState(Editor* editor, EditorS
|
||||
|
||||
editor->document()->resetTransformation();
|
||||
|
||||
m_pixelsMovement.reset(NULL);
|
||||
removePixelsMovement();
|
||||
|
||||
editor->releaseMouse();
|
||||
|
||||
@ -598,6 +597,8 @@ void MovingPixelsState::onBeforeLayerChanged(Editor* editor)
|
||||
|
||||
void MovingPixelsState::onTransparentColorChange()
|
||||
{
|
||||
ASSERT(m_pixelsMovement);
|
||||
|
||||
bool opaque = Preferences::instance().selection.opaque();
|
||||
setTransparentColor(
|
||||
opaque,
|
||||
@ -677,4 +678,12 @@ void MovingPixelsState::removeAsEditorObserver()
|
||||
}
|
||||
}
|
||||
|
||||
void MovingPixelsState::removePixelsMovement()
|
||||
{
|
||||
m_pixelsMovement.reset(nullptr);
|
||||
m_ctxConn.disconnect();
|
||||
m_opaqueConn.disconnect();
|
||||
m_transparentConn.disconnect();
|
||||
}
|
||||
|
||||
} // namespace app
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2001-2016 David Capello
|
||||
// Copyright (C) 2001-2017 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -72,6 +72,7 @@ namespace app {
|
||||
bool isActiveEditor() const;
|
||||
|
||||
void removeAsEditorObserver();
|
||||
void removePixelsMovement();
|
||||
|
||||
// Helper member to move/translate selection and pixels.
|
||||
PixelsMovementPtr m_pixelsMovement;
|
||||
@ -82,9 +83,9 @@ namespace app {
|
||||
// used to remove the dragged image).
|
||||
bool m_discarded;
|
||||
|
||||
obs::scoped_connection m_ctxConn;
|
||||
obs::scoped_connection m_opaqueConn;
|
||||
obs::scoped_connection m_transparentConn;
|
||||
obs::connection m_ctxConn;
|
||||
obs::connection m_opaqueConn;
|
||||
obs::connection m_transparentConn;
|
||||
};
|
||||
|
||||
} // namespace app
|
||||
|
Loading…
Reference in New Issue
Block a user