mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-29 12:32:52 +00:00
Fix crash applying filters (fix #4928)
The program was crashing when applying a filter that as a result removed the current cel
This commit is contained in:
parent
dd654ca2aa
commit
d15b585d03
@ -1,5 +1,5 @@
|
|||||||
// Aseprite
|
// Aseprite
|
||||||
// Copyright (C) 2019-2023 Igara Studio S.A.
|
// Copyright (C) 2019-2025 Igara Studio S.A.
|
||||||
// Copyright (C) 2001-2018 David Capello
|
// Copyright (C) 2001-2018 David Capello
|
||||||
//
|
//
|
||||||
// This program is distributed under the terms of
|
// This program is distributed under the terms of
|
||||||
@ -251,7 +251,8 @@ void FilterManagerImpl::apply()
|
|||||||
|
|
||||||
ASSERT(m_reader.context());
|
ASSERT(m_reader.context());
|
||||||
m_reader.context()->setCommandResult(result);
|
m_reader.context()->setCommandResult(result);
|
||||||
init(m_site.cel());
|
if (m_site.cel())
|
||||||
|
init(m_site.cel());
|
||||||
}
|
}
|
||||||
|
|
||||||
void FilterManagerImpl::applyToTarget()
|
void FilterManagerImpl::applyToTarget()
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Aseprite
|
// Aseprite
|
||||||
// Copyright (C) 2019-2023 Igara Studio S.A.
|
// Copyright (C) 2019-2025 Igara Studio S.A.
|
||||||
// Copyright (C) 2001-2018 David Capello
|
// Copyright (C) 2001-2018 David Capello
|
||||||
//
|
//
|
||||||
// This program is distributed under the terms of
|
// This program is distributed under the terms of
|
||||||
@ -100,6 +100,7 @@ public:
|
|||||||
doc::Sprite* sprite() { return m_site.sprite(); }
|
doc::Sprite* sprite() { return m_site.sprite(); }
|
||||||
doc::Layer* layer() { return m_site.layer(); }
|
doc::Layer* layer() { return m_site.layer(); }
|
||||||
doc::frame_t frame() { return m_site.frame(); }
|
doc::frame_t frame() { return m_site.frame(); }
|
||||||
|
doc::Cel* cel() { return m_site.cel(); }
|
||||||
doc::Image* destinationImage() const { return m_dst.get(); }
|
doc::Image* destinationImage() const { return m_dst.get(); }
|
||||||
gfx::Point position() const { return gfx::Point(0, 0); }
|
gfx::Point position() const { return gfx::Point(0, 0); }
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Aseprite
|
// Aseprite
|
||||||
// Copyright (C) 2020-2023 Igara Studio S.A.
|
// Copyright (C) 2020-2025 Igara Studio S.A.
|
||||||
// Copyright (C) 2001-2018 David Capello
|
// Copyright (C) 2001-2018 David Capello
|
||||||
//
|
//
|
||||||
// This program is distributed under the terms of
|
// This program is distributed under the terms of
|
||||||
@ -166,6 +166,13 @@ void FilterWindow::onApply()
|
|||||||
update_screen_for_document(m_filterMgr->document());
|
update_screen_for_document(m_filterMgr->document());
|
||||||
|
|
||||||
restartPreview();
|
restartPreview();
|
||||||
|
|
||||||
|
// If there is no cel after applying the filter, then close the window because we cannot
|
||||||
|
// continue applying it over an empty cel.
|
||||||
|
if (!m_filterMgr->cel()) {
|
||||||
|
onCancel();
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FilterWindow::onOk()
|
void FilterWindow::onOk()
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Aseprite
|
// Aseprite
|
||||||
// Copyright (C) 2018-2024 Igara Studio S.A.
|
// Copyright (C) 2018-2025 Igara Studio S.A.
|
||||||
// Copyright (C) 2001-2018 David Capello
|
// Copyright (C) 2001-2018 David Capello
|
||||||
//
|
//
|
||||||
// This program is distributed under the terms of
|
// This program is distributed under the terms of
|
||||||
@ -1958,7 +1958,7 @@ void Timeline::onAddCel(DocEvent& ev)
|
|||||||
|
|
||||||
void Timeline::onAfterRemoveCel(DocEvent& ev)
|
void Timeline::onAfterRemoveCel(DocEvent& ev)
|
||||||
{
|
{
|
||||||
invalidateLayer(ev.layer());
|
ui::execute_now_or_enqueue([this, ev] { invalidateLayer(ev.layer()); });
|
||||||
}
|
}
|
||||||
|
|
||||||
void Timeline::onLayerNameChange(DocEvent& ev)
|
void Timeline::onLayerNameChange(DocEvent& ev)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Aseprite UI Library
|
// Aseprite UI Library
|
||||||
// Copyright (C) 2018-2024 Igara Studio S.A.
|
// Copyright (C) 2018-2025 Igara Studio S.A.
|
||||||
// Copyright (C) 2001-2018 David Capello
|
// Copyright (C) 2001-2018 David Capello
|
||||||
//
|
//
|
||||||
// This file is released under the terms of the MIT license.
|
// This file is released under the terms of the MIT license.
|
||||||
@ -280,6 +280,14 @@ void execute_from_ui_thread(std::function<void()>&& func)
|
|||||||
os::queue_event(ev);
|
os::queue_event(ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void execute_now_or_enqueue(std::function<void()>&& func)
|
||||||
|
{
|
||||||
|
if (is_ui_thread())
|
||||||
|
func();
|
||||||
|
else
|
||||||
|
execute_from_ui_thread(std::move(func));
|
||||||
|
}
|
||||||
|
|
||||||
bool is_ui_thread()
|
bool is_ui_thread()
|
||||||
{
|
{
|
||||||
return (main_gui_thread == std::this_thread::get_id());
|
return (main_gui_thread == std::this_thread::get_id());
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Aseprite UI Library
|
// Aseprite UI Library
|
||||||
// Copyright (C) 2019-2024 Igara Studio S.A.
|
// Copyright (C) 2019-2025 Igara Studio S.A.
|
||||||
// Copyright (C) 2001-2018 David Capello
|
// Copyright (C) 2001-2018 David Capello
|
||||||
//
|
//
|
||||||
// This file is released under the terms of the MIT license.
|
// This file is released under the terms of the MIT license.
|
||||||
@ -62,6 +62,9 @@ gfx::Point get_mouse_position();
|
|||||||
void set_mouse_position(const gfx::Point& newPos, Display* display);
|
void set_mouse_position(const gfx::Point& newPos, Display* display);
|
||||||
|
|
||||||
void execute_from_ui_thread(std::function<void()>&& func);
|
void execute_from_ui_thread(std::function<void()>&& func);
|
||||||
|
// If it is called from the UI thread just executes the function, if it is
|
||||||
|
// called from a different thread, then call execute_from_ui_thread.
|
||||||
|
void execute_now_or_enqueue(std::function<void()>&& func);
|
||||||
bool is_ui_thread();
|
bool is_ui_thread();
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
void assert_ui_thread();
|
void assert_ui_thread();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user