Allow executing transactions on contextless docs

This commit is contained in:
Martín Capello 2024-09-16 15:56:47 -03:00
parent e5bf9cb253
commit 8b0b1d8d1e
2 changed files with 8 additions and 1 deletions

View File

@ -14,6 +14,7 @@
#include "app/app.h"
#include "app/context.h"
#include "app/site.h"
#include "app/sprite_position.h"
#include "app/ui/timeline/timeline.h"
namespace app {
@ -118,6 +119,12 @@ size_t CmdTransaction::onMemSize() const
SpritePosition CmdTransaction::calcSpritePosition() const
{
// This check was added to allow executing transactions on documents that are
// not part of any context. For instance, when dragging and dropping a
// document on the timeline, the dragged document doesn't have any context (
// it is not associated with any editor).
if (!context())
return SpritePosition();
Site site = context()->activeSite();
return SpritePosition(site.layer(), site.frame());
}

View File

@ -117,7 +117,7 @@ void Transaction::commit()
else
set_current_palette(nullptr, false);
if (m_ctx->isUIAvailable())
if (m_ctx && m_ctx->isUIAvailable())
ui::Manager::getDefault()->invalidate();
}
}