mirror of
https://github.com/aseprite/aseprite.git
synced 2025-04-17 08:43:11 +00:00
Fix crash deleting layers while using "Change Layer" w/scroll wheel (fix #4114)
E.g. If we configure Shift+scroll wheel to "Change Layer" action, and Shift+J to delete a layer, we can press Shift key and move through layers with the mouse whell while we press the Shift key, and if we press J (without releasing the Shift) start deleting layers. At some point a crash will happen.
This commit is contained in:
parent
ca8c970c5d
commit
67d5314f0c
@ -2375,6 +2375,9 @@ void Editor::onBeforeRemoveLayer(DocEvent& ev)
|
||||
Layer* layerToSelect = candidate_if_layer_is_deleted(layer(), ev.layer());
|
||||
if (layer() != layerToSelect)
|
||||
setLayer(layerToSelect);
|
||||
|
||||
if (m_state)
|
||||
m_state->onBeforeRemoveLayer(this);
|
||||
}
|
||||
|
||||
void Editor::onBeforeRemoveCel(DocEvent& ev)
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2019-2020 Igara Studio S.A.
|
||||
// Copyright (C) 2019-2023 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2016 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -140,6 +140,11 @@ namespace app {
|
||||
// by states like DrawingState + ExpandCelCanvas.
|
||||
virtual bool getGridBounds(Editor* editor, gfx::Rect& gridBounds) { return false; }
|
||||
|
||||
// Called when a layer is going to be removed, e.g. useful in case
|
||||
// that the state cached a layer pointer in an internal
|
||||
// collection.
|
||||
virtual void onBeforeRemoveLayer(Editor* editor) { }
|
||||
|
||||
private:
|
||||
DISABLE_COPYING(EditorState);
|
||||
};
|
||||
|
@ -593,6 +593,12 @@ bool StateWithWheelBehavior::onSetCursor(Editor* editor, const gfx::Point& mouse
|
||||
return true;
|
||||
}
|
||||
|
||||
void StateWithWheelBehavior::onBeforeRemoveLayer(Editor* editor)
|
||||
{
|
||||
// Clear the cached list of layers
|
||||
m_browsableLayers.clear();
|
||||
}
|
||||
|
||||
void StateWithWheelBehavior::setZoom(Editor* editor,
|
||||
const render::Zoom& zoom,
|
||||
const gfx::Point& mousePos)
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2022 Igara Studio S.A.
|
||||
// Copyright (C) 2022-2023 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2016 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -43,6 +43,7 @@ namespace app {
|
||||
bool onMouseWheel(Editor* editor, ui::MouseMessage* msg) override;
|
||||
bool onTouchMagnify(Editor* editor, ui::TouchMessage* msg) override;
|
||||
bool onSetCursor(Editor* editor, const gfx::Point& mouseScreenPos) override;
|
||||
void onBeforeRemoveLayer(Editor* editor) override;
|
||||
|
||||
protected:
|
||||
void processWheelAction(Editor* editor,
|
||||
|
Loading…
x
Reference in New Issue
Block a user