mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-14 13:21:34 +00:00
Fix crash using Flatten Visible when the active layer is a child of a group
This commit is contained in:
parent
54bb39a9d3
commit
53cb226f09
@ -394,13 +394,17 @@ void DocView::onAddLayer(DocEvent& ev)
|
||||
}
|
||||
}
|
||||
|
||||
// TODO why note move this code to Editor::onBeforeRemoveLayer?
|
||||
void DocView::onBeforeRemoveLayer(DocEvent& ev)
|
||||
{
|
||||
Sprite* sprite = ev.sprite();
|
||||
Layer* layer = ev.layer();
|
||||
|
||||
// If the layer that was removed is the selected one
|
||||
if (layer == m_editor->layer()) {
|
||||
// If the layer that was removed is the selected one in the editor,
|
||||
// or is an ancestor of the selected one.
|
||||
if ((m_editor->layer() == layer) ||
|
||||
(m_editor->layer() &&
|
||||
m_editor->layer()->hasAncestor(layer))) {
|
||||
LayerGroup* parent = layer->parent();
|
||||
Layer* layer_select = NULL;
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
// Aseprite Document Library
|
||||
// Copyright (c) 2001-2018 David Capello
|
||||
// Copyright (C) 2020 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
// Read LICENSE.txt for more information.
|
||||
@ -176,6 +177,17 @@ bool Layer::isEditableHierarchy() const
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Layer::hasAncestor(const Layer* ancestor) const
|
||||
{
|
||||
Layer* it = parent();
|
||||
while (it) {
|
||||
if (it == ancestor)
|
||||
return true;
|
||||
it = it->parent();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Cel* Layer::cel(frame_t frame) const
|
||||
{
|
||||
return nullptr;
|
||||
|
@ -1,5 +1,6 @@
|
||||
// Aseprite Document Library
|
||||
// Copyright (c) 2001-2018 David Capello
|
||||
// Copyright (C) 2020 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
// Read LICENSE.txt for more information.
|
||||
@ -88,6 +89,7 @@ namespace doc {
|
||||
|
||||
bool isVisibleHierarchy() const;
|
||||
bool isEditableHierarchy() const;
|
||||
bool hasAncestor(const Layer* ancestor) const;
|
||||
|
||||
void setBackground(bool state) { switchFlags(LayerFlags::Background, state); }
|
||||
void setVisible (bool state) { switchFlags(LayerFlags::Visible, state); }
|
||||
|
Loading…
x
Reference in New Issue
Block a user