Commit a5f1b871 authored by Thorsten Zachmann's avatar Thorsten Zachmann

Revert "Revert "Use the KisColorTransformationConfiguration""

This reverts commit ae00bf64f3e2bf5ced79cf06e3f013c460c854ae and fixes the problem
described in BUG 351009 by creating a transformation per thread as some seem to be
not thread save.
parent 48135195
...@@ -19,19 +19,20 @@ ...@@ -19,19 +19,20 @@
#include "filter/kis_color_transformation_configuration.h" #include "filter/kis_color_transformation_configuration.h"
#include <QMutexLocker> #include <QMutexLocker>
#include <QMap>
#include <QThread>
#include "filter/kis_color_transformation_filter.h" #include "filter/kis_color_transformation_filter.h"
struct KisColorTransformationConfiguration::Private { struct KisColorTransformationConfiguration::Private {
Private() Private()
: colorTransformation(0)
{} {}
~Private() ~Private()
{ {
delete colorTransformation; qDeleteAll(colorTransformation);
} }
KoColorTransformation *colorTransformation; QMap<QThread*, KoColorTransformation*> colorTransformation;
QMutex mutex; QMutex mutex;
}; };
...@@ -48,11 +49,13 @@ KisColorTransformationConfiguration::~KisColorTransformationConfiguration() ...@@ -48,11 +49,13 @@ KisColorTransformationConfiguration::~KisColorTransformationConfiguration()
KoColorTransformation* KisColorTransformationConfiguration::colorTransformation(const KoColorSpace *cs, const KisColorTransformationFilter * filter) const KoColorTransformation* KisColorTransformationConfiguration::colorTransformation(const KoColorSpace *cs, const KisColorTransformationFilter * filter) const
{ {
if (!d->colorTransformation) { qDebug() << QThread::currentThread();
QMutexLocker locker(&d->mutex); QMutexLocker locker(&d->mutex);
if (!d->colorTransformation) { KoColorTransformation *transformation = d->colorTransformation.value(QThread::currentThread(), 0);
d->colorTransformation = filter->createTransformation(cs, this); if (!transformation) {
} transformation = filter->createTransformation(cs, this);
d->colorTransformation.insert(QThread::currentThread(), transformation);
} }
return d->colorTransformation; locker.unlock();
return transformation;
} }
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
*/ */
#include "kis_color_balance_filter.h" #include "kis_color_balance_filter.h"
#include "filter/kis_filter_configuration.h" #include "filter/kis_color_transformation_configuration.h"
#include "kis_selection.h" #include "kis_selection.h"
#include "kis_paint_device.h" #include "kis_paint_device.h"
#include "kis_processing_information.h" #include "kis_processing_information.h"
...@@ -59,7 +59,7 @@ KoColorTransformation * KisColorBalanceFilter::createTransformation(const KoColo ...@@ -59,7 +59,7 @@ KoColorTransformation * KisColorBalanceFilter::createTransformation(const KoColo
KisFilterConfiguration* KisColorBalanceFilter::factoryConfiguration(const KisPaintDeviceSP) const KisFilterConfiguration* KisColorBalanceFilter::factoryConfiguration(const KisPaintDeviceSP) const
{ {
KisFilterConfiguration* config = new KisFilterConfiguration(id().id(), 0); KisColorTransformationConfiguration* config = new KisColorTransformationConfiguration(id().id(), 0);
config->setProperty("cyan_red_midtones", 0); config->setProperty("cyan_red_midtones", 0);
config->setProperty("yellow_green_midtones", 0); config->setProperty("yellow_green_midtones", 0);
config->setProperty("magenta_blue_midtones", 0); config->setProperty("magenta_blue_midtones", 0);
...@@ -149,7 +149,7 @@ KisColorBalanceConfigWidget::~KisColorBalanceConfigWidget() ...@@ -149,7 +149,7 @@ KisColorBalanceConfigWidget::~KisColorBalanceConfigWidget()
KisPropertiesConfiguration * KisColorBalanceConfigWidget::configuration() const KisPropertiesConfiguration * KisColorBalanceConfigWidget::configuration() const
{ {
KisFilterConfiguration* c = new KisFilterConfiguration(KisColorBalanceFilter::id().id(), 0); KisColorTransformationConfiguration* c = new KisColorTransformationConfiguration(KisColorBalanceFilter::id().id(), 0);
c->setProperty("cyan_red_shadows", m_page->cyanRedShadowsSlider->value()); c->setProperty("cyan_red_shadows", m_page->cyanRedShadowsSlider->value());
c->setProperty("magenta_green_shadows", m_page->magentaGreenShadowsSlider->value()); c->setProperty("magenta_green_shadows", m_page->magentaGreenShadowsSlider->value());
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
#include "KoBasicHistogramProducers.h" #include "KoBasicHistogramProducers.h"
#include <KoColorSpace.h> #include <KoColorSpace.h>
#include <KoColorTransformation.h> #include <KoColorTransformation.h>
#include <filter/kis_filter_configuration.h> #include <filter/kis_color_transformation_configuration.h>
#include <kis_paint_device.h> #include <kis_paint_device.h>
#include <kis_processing_information.h> #include <kis_processing_information.h>
#include <KisDocument.h> #include <KisDocument.h>
...@@ -82,7 +82,7 @@ KoColorTransformation* KisDesaturateFilter::createTransformation(const KoColorSp ...@@ -82,7 +82,7 @@ KoColorTransformation* KisDesaturateFilter::createTransformation(const KoColorSp
KisFilterConfiguration *KisDesaturateFilter::factoryConfiguration(const KisPaintDeviceSP) const KisFilterConfiguration *KisDesaturateFilter::factoryConfiguration(const KisPaintDeviceSP) const
{ {
KisFilterConfiguration* config = new KisFilterConfiguration(id().id(), 1); KisColorTransformationConfiguration* config = new KisColorTransformationConfiguration(id().id(), 1);
config->setProperty("type", 0); config->setProperty("type", 0);
return config; return config;
} }
...@@ -109,7 +109,7 @@ KisDesaturateConfigWidget::~KisDesaturateConfigWidget() ...@@ -109,7 +109,7 @@ KisDesaturateConfigWidget::~KisDesaturateConfigWidget()
KisPropertiesConfiguration * KisDesaturateConfigWidget::configuration() const KisPropertiesConfiguration * KisDesaturateConfigWidget::configuration() const
{ {
KisFilterConfiguration* c = new KisFilterConfiguration(KisDesaturateFilter::id().id(), 0); KisColorTransformationConfiguration* c = new KisColorTransformationConfiguration(KisDesaturateFilter::id().id(), 0);
c->setProperty("type", m_group->checkedId()); c->setProperty("type", m_group->checkedId());
return c; return c;
} }
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
#include "kis_hsv_adjustment_filter.h" #include "kis_hsv_adjustment_filter.h"
#include <filter/kis_filter_configuration.h> #include <filter/kis_color_transformation_configuration.h>
#include <kis_selection.h> #include <kis_selection.h>
#include <kis_paint_device.h> #include <kis_paint_device.h>
#include <kis_processing_information.h> #include <kis_processing_information.h>
...@@ -59,7 +59,7 @@ KoColorTransformation* KisHSVAdjustmentFilter::createTransformation(const KoColo ...@@ -59,7 +59,7 @@ KoColorTransformation* KisHSVAdjustmentFilter::createTransformation(const KoColo
KisFilterConfiguration* KisHSVAdjustmentFilter::factoryConfiguration(const KisPaintDeviceSP) const KisFilterConfiguration* KisHSVAdjustmentFilter::factoryConfiguration(const KisPaintDeviceSP) const
{ {
KisFilterConfiguration* config = new KisFilterConfiguration(id().id(), 1); KisColorTransformationConfiguration* config = new KisColorTransformationConfiguration(id().id(), 1);
config->setProperty("h", 0); config->setProperty("h", 0);
config->setProperty("s", 0); config->setProperty("s", 0);
config->setProperty("v", 0); config->setProperty("v", 0);
...@@ -96,7 +96,7 @@ KisHSVConfigWidget::~KisHSVConfigWidget() ...@@ -96,7 +96,7 @@ KisHSVConfigWidget::~KisHSVConfigWidget()
KisPropertiesConfiguration * KisHSVConfigWidget::configuration() const KisPropertiesConfiguration * KisHSVConfigWidget::configuration() const
{ {
KisFilterConfiguration* c = new KisFilterConfiguration(KisHSVAdjustmentFilter::id().id(), 0); KisColorTransformationConfiguration* c = new KisColorTransformationConfiguration(KisHSVAdjustmentFilter::id().id(), 0);
c->setProperty("h", m_page->hue->value()); c->setProperty("h", m_page->hue->value());
c->setProperty("s", m_page->saturation->value()); c->setProperty("s", m_page->saturation->value());
c->setProperty("v", m_page->value->value()); c->setProperty("v", m_page->value->value());
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
*/ */
#include "DodgeBurn.h" #include "DodgeBurn.h"
#include <filter/kis_filter_configuration.h> #include <filter/kis_color_transformation_configuration.h>
#include <kis_paint_device.h> #include <kis_paint_device.h>
#include "ui_DodgeBurnConfigurationBaseWidget.h" #include "ui_DodgeBurnConfigurationBaseWidget.h"
...@@ -74,7 +74,7 @@ KisDodgeBurnConfigWidget::~KisDodgeBurnConfigWidget() ...@@ -74,7 +74,7 @@ KisDodgeBurnConfigWidget::~KisDodgeBurnConfigWidget()
KisPropertiesConfiguration * KisDodgeBurnConfigWidget::configuration() const KisPropertiesConfiguration * KisDodgeBurnConfigWidget::configuration() const
{ {
KisFilterConfiguration* c = new KisFilterConfiguration(m_id, 0); KisColorTransformationConfiguration* c = new KisColorTransformationConfiguration(m_id, 0);
int type = 0; int type = 0;
if(m_page->radioButtonHighlights->isChecked()) if(m_page->radioButtonHighlights->isChecked())
{ {
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
#include <kis_global.h> #include <kis_global.h>
#include <KoColorSpaceMaths.h> #include <KoColorSpaceMaths.h>
#include <KoColorSpaceRegistry.h> #include <KoColorSpaceRegistry.h>
#include <filter/kis_filter_configuration.h> #include <filter/kis_color_transformation_configuration.h>
#include <widgets/kis_multi_integer_filter_widget.h> #include <widgets/kis_multi_integer_filter_widget.h>
#include "kiswdgindexcolors.h" #include "kiswdgindexcolors.h"
...@@ -87,7 +87,7 @@ KisConfigWidget* KisFilterIndexColors::createConfigurationWidget(QWidget* parent ...@@ -87,7 +87,7 @@ KisConfigWidget* KisFilterIndexColors::createConfigurationWidget(QWidget* parent
KisFilterConfiguration* KisFilterIndexColors::factoryConfiguration(const KisPaintDeviceSP) const KisFilterConfiguration* KisFilterIndexColors::factoryConfiguration(const KisPaintDeviceSP) const
{ {
KisFilterConfiguration* config = new KisFilterConfiguration(id().id(), 0); KisColorTransformationConfiguration* config = new KisColorTransformationConfiguration(id().id(), 0);
PaletteGeneratorConfig palCfg; // Default constructor is factory config PaletteGeneratorConfig palCfg; // Default constructor is factory config
config->setProperty("paletteGen", palCfg.toByteArray()); config->setProperty("paletteGen", palCfg.toByteArray());
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
#include <kis_global.h> #include <kis_global.h>
#include <KoColorSpaceMaths.h> #include <KoColorSpaceMaths.h>
#include <filter/kis_filter_configuration.h> #include <filter/kis_color_transformation_configuration.h>
#include <widgets/kis_multi_integer_filter_widget.h> #include <widgets/kis_multi_integer_filter_widget.h>
K_PLUGIN_FACTORY(PosterizeFactory, registerPlugin<Posterize>();) K_PLUGIN_FACTORY(PosterizeFactory, registerPlugin<Posterize>();)
...@@ -80,7 +80,7 @@ KisConfigWidget* KisFilterPosterize::createConfigurationWidget(QWidget* parent, ...@@ -80,7 +80,7 @@ KisConfigWidget* KisFilterPosterize::createConfigurationWidget(QWidget* parent,
KisFilterConfiguration* KisFilterPosterize::factoryConfiguration(const KisPaintDeviceSP) const KisFilterConfiguration* KisFilterPosterize::factoryConfiguration(const KisPaintDeviceSP) const
{ {
KisFilterConfiguration* config = new KisFilterConfiguration(id().id(), 0); KisColorTransformationConfiguration* config = new KisColorTransformationConfiguration(id().id(), 0);
config->setProperty("steps", 16); config->setProperty("steps", 16);
return config; return config;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment