From b5547251f525333a701009a1bc131ca947ddeadd Mon Sep 17 00:00:00 2001 From: David Capello Date: Fri, 26 Jul 2019 12:06:21 -0300 Subject: [PATCH] We cannot create a ContextReader in the filter background thread This is because ContextReader gets the activeSite, which (in case of the UIContext) asks to the UI thread this information (app::Editor). --- src/app/commands/filters/filter_manager_impl.cpp | 7 +++---- src/app/commands/filters/filter_manager_impl.h | 5 +++-- src/app/commands/filters/filter_worker.cpp | 1 + 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/app/commands/filters/filter_manager_impl.cpp b/src/app/commands/filters/filter_manager_impl.cpp index 170e95694..0056a02e6 100644 --- a/src/app/commands/filters/filter_manager_impl.cpp +++ b/src/app/commands/filters/filter_manager_impl.cpp @@ -50,8 +50,8 @@ using namespace std; using namespace ui; FilterManagerImpl::FilterManagerImpl(Context* context, Filter* filter) - : m_context(context) - , m_site(context->activeSite()) + : m_reader(context) + , m_site(*const_cast(m_reader.site())) , m_filter(filter) , m_cel(nullptr) , m_src(nullptr) @@ -281,8 +281,7 @@ void FilterManagerImpl::applyToTarget() } // Initialize writting operation - ContextReader reader(m_context); - ContextWriter writer(reader); + ContextWriter writer(m_reader); m_tx.reset(new Tx(writer.context(), m_filter->getName(), ModifyDocument)); m_progressBase = 0.0f; diff --git a/src/app/commands/filters/filter_manager_impl.h b/src/app/commands/filters/filter_manager_impl.h index 28bd2de55..40a098f70 100644 --- a/src/app/commands/filters/filter_manager_impl.h +++ b/src/app/commands/filters/filter_manager_impl.h @@ -10,6 +10,7 @@ #pragma once #include "app/commands/filters/cels_target.h" +#include "app/context_access.h" #include "app/site.h" #include "app/tx.h" #include "base/exception.h" @@ -139,8 +140,8 @@ namespace app { void redrawColorPalette(); #endif - Context* m_context; - Site m_site; + ContextReader m_reader; + Site& m_site; Filter* m_filter; doc::Cel* m_cel; doc::ImageRef m_src; diff --git a/src/app/commands/filters/filter_worker.cpp b/src/app/commands/filters/filter_worker.cpp index c9a6806ff..2f0ac58fc 100644 --- a/src/app/commands/filters/filter_worker.cpp +++ b/src/app/commands/filters/filter_worker.cpp @@ -12,6 +12,7 @@ #include "app/app.h" #include "app/commands/filters/filter_manager_impl.h" #include "app/console.h" +#include "app/context_access.h" #include "app/i18n/strings.h" #include "app/ini_file.h" #include "app/modules/editors.h"