mirror of
https://github.com/aseprite/aseprite.git
synced 2025-04-18 11:42:47 +00:00
Fix crash applying a filter w/all layers locked (fix #1610)
The m_transaction field of FilterManagerImpl::commitTransaction() was nullptr because FilterManagerImpl::applyToTarget() was returning without creating the m_transaction.
This commit is contained in:
parent
c80d914e1a
commit
ab51f02711
@ -234,8 +234,11 @@ void FilterManagerImpl::applyToTarget()
|
|||||||
m_site.frame(),
|
m_site.frame(),
|
||||||
(m_target & TARGET_ALL_FRAMES) == TARGET_ALL_FRAMES,
|
(m_target & TARGET_ALL_FRAMES) == TARGET_ALL_FRAMES,
|
||||||
true); // we will write in each image
|
true); // we will write in each image
|
||||||
if (images.empty() && !paletteChange)
|
if (images.empty() && !paletteChange) {
|
||||||
|
// We don't have images/palette changes to do (there will not be a
|
||||||
|
// transaction).
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Initialize writting operation
|
// Initialize writting operation
|
||||||
ContextReader reader(m_context);
|
ContextReader reader(m_context);
|
||||||
@ -280,10 +283,16 @@ void FilterManagerImpl::applyToTarget()
|
|||||||
m_oldPalette.reset(nullptr);
|
m_oldPalette.reset(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool FilterManagerImpl::isTransaction() const
|
||||||
|
{
|
||||||
|
return m_transaction != nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
// This must be executed in the main UI thread.
|
||||||
|
// Check Transaction::commit() comments.
|
||||||
void FilterManagerImpl::commitTransaction()
|
void FilterManagerImpl::commitTransaction()
|
||||||
{
|
{
|
||||||
// This must be executed in the main UI thread.
|
ASSERT(m_transaction);
|
||||||
// Check Transaction::commit() comments.
|
|
||||||
m_transaction->commit();
|
m_transaction->commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,6 +83,7 @@ namespace app {
|
|||||||
void end();
|
void end();
|
||||||
bool applyStep();
|
bool applyStep();
|
||||||
void applyToTarget();
|
void applyToTarget();
|
||||||
|
bool isTransaction() const;
|
||||||
void commitTransaction();
|
void commitTransaction();
|
||||||
|
|
||||||
app::Document* document();
|
app::Document* document();
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
#include "app/modules/editors.h"
|
#include "app/modules/editors.h"
|
||||||
#include "app/modules/gui.h"
|
#include "app/modules/gui.h"
|
||||||
#include "app/ui/editor/editor.h"
|
#include "app/ui/editor/editor.h"
|
||||||
|
#include "app/ui/status_bar.h"
|
||||||
#include "base/mutex.h"
|
#include "base/mutex.h"
|
||||||
#include "base/scoped_lock.h"
|
#include "base/scoped_lock.h"
|
||||||
#include "base/thread.h"
|
#include "base/thread.h"
|
||||||
@ -104,7 +105,7 @@ void FilterWorker::run()
|
|||||||
|
|
||||||
{
|
{
|
||||||
scoped_lock lock(m_mutex);
|
scoped_lock lock(m_mutex);
|
||||||
if (m_done)
|
if (m_done && m_filterMgr->isTransaction())
|
||||||
m_filterMgr->commitTransaction();
|
m_filterMgr->commitTransaction();
|
||||||
else
|
else
|
||||||
m_cancelled = true;
|
m_cancelled = true;
|
||||||
@ -117,6 +118,10 @@ void FilterWorker::run()
|
|||||||
Console console;
|
Console console;
|
||||||
console.printf("A problem has occurred.\n\nDetails:\n%s", m_error.c_str());
|
console.printf("A problem has occurred.\n\nDetails:\n%s", m_error.c_str());
|
||||||
}
|
}
|
||||||
|
else if (m_cancelled && !m_filterMgr->isTransaction()) {
|
||||||
|
StatusBar::instance()
|
||||||
|
->showTip(2500, "No unlocked layers to apply filter");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called by FilterManagerImpl to informate the progress of the filter.
|
// Called by FilterManagerImpl to informate the progress of the filter.
|
||||||
|
@ -228,6 +228,7 @@ const undo::UndoState* DocumentUndo::nextRedo() const
|
|||||||
|
|
||||||
void DocumentUndo::onDeleteUndoState(undo::UndoState* state)
|
void DocumentUndo::onDeleteUndoState(undo::UndoState* state)
|
||||||
{
|
{
|
||||||
|
ASSERT(state);
|
||||||
Cmd* cmd = STATE_CMD(state);
|
Cmd* cmd = STATE_CMD(state);
|
||||||
|
|
||||||
UNDO_TRACE("UNDO: Deleting undo state <%s> of %s from %s\n",
|
UNDO_TRACE("UNDO: Deleting undo state <%s> of %s from %s\n",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user