mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-04 08:46:09 +00:00
The document associated w/SpriteEvents can be nullptr in special cases
SpriteEvents can be re-created just when we're closing the sprite if
we access Sprite.events property in app 'sitechange' event. When this
second instance of SpriteEvents is deleted after the sprite was
closed, the document cannot be found (as it was already destroyed).
Associated test:
02a2f1f933
This commit is contained in:
parent
f4e83371b8
commit
4389788a1d
@ -202,7 +202,12 @@ public:
|
||||
|
||||
~SpriteEvents() {
|
||||
auto doc = this->doc();
|
||||
ASSERT(doc || ui::get_app_state() == ui::AppState::kClosingWithException);
|
||||
// The document can be nullptr in some cases like:
|
||||
// - When closing the App with an exception
|
||||
// (ui::get_app_state() == ui::AppState::kClosingWithException)
|
||||
// - When Sprite.events property was accessed in a app
|
||||
// "sitechange" event just when this same sprite was closed
|
||||
// (so the SpriteEvents is created/destroyed for second time)
|
||||
if (doc) {
|
||||
disconnectFromUndoHistory(doc);
|
||||
doc->remove_observer(this);
|
||||
|
Loading…
Reference in New Issue
Block a user