1
0
mirror of https://github.com/aseprite/aseprite.git synced 2025-03-29 01:20:17 +00:00

Fix crash applying a filter w/all layers locked (fix )

The m_transaction field of FilterManagerImpl::commitTransaction() was
nullptr because FilterManagerImpl::applyToTarget() was returning without
creating the m_transaction.
This commit is contained in:
David Capello 2017-11-22 11:11:31 -03:00
parent c80d914e1a
commit ab51f02711
4 changed files with 20 additions and 4 deletions

@ -234,8 +234,11 @@ void FilterManagerImpl::applyToTarget()
m_site.frame(),
(m_target & TARGET_ALL_FRAMES) == TARGET_ALL_FRAMES,
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;
}
// Initialize writting operation
ContextReader reader(m_context);
@ -280,10 +283,16 @@ void FilterManagerImpl::applyToTarget()
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()
{
// This must be executed in the main UI thread.
// Check Transaction::commit() comments.
ASSERT(m_transaction);
m_transaction->commit();
}

@ -83,6 +83,7 @@ namespace app {
void end();
bool applyStep();
void applyToTarget();
bool isTransaction() const;
void commitTransaction();
app::Document* document();

@ -16,6 +16,7 @@
#include "app/modules/editors.h"
#include "app/modules/gui.h"
#include "app/ui/editor/editor.h"
#include "app/ui/status_bar.h"
#include "base/mutex.h"
#include "base/scoped_lock.h"
#include "base/thread.h"
@ -104,7 +105,7 @@ void FilterWorker::run()
{
scoped_lock lock(m_mutex);
if (m_done)
if (m_done && m_filterMgr->isTransaction())
m_filterMgr->commitTransaction();
else
m_cancelled = true;
@ -117,6 +118,10 @@ void FilterWorker::run()
Console console;
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.

@ -228,6 +228,7 @@ const undo::UndoState* DocumentUndo::nextRedo() const
void DocumentUndo::onDeleteUndoState(undo::UndoState* state)
{
ASSERT(state);
Cmd* cmd = STATE_CMD(state);
UNDO_TRACE("UNDO: Deleting undo state <%s> of %s from %s\n",