[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-kimageshop
Subject:    Re: [calligra] krita: Remove paintop factories that cannot produce
From:       Lukast dev <lukast.dev () gmail ! com>
Date:       2011-12-25 21:29:17
Message-ID: CAKdU0rPO=8wo_mhozPNAOiPhUudj6MVQ16kJ=Ykx_AyVW8ZkFg () mail ! gmail ! com
[Download RAW message or body]

Hello,

This is dangerous commit -- not sure if I get it correctly.

I suppose it will prevent the developer to add new
paintops easily. For new paintop you now added dependency
for default preset,is that right?

But you can't create default preset without editor in Krita easily.
You can create manually the xml file and manually add it to PNG file as text.
That is painful task.

2011/12/24 Boudewijn Rempt <boud@valdyas.org>:
> Git commit 33909cb9b71a965418e27c71c3be301c26b96236 by Boudewijn Rempt.
> Committed on 24/12/2011 at 12:43.
> Pushed by rempt into branch 'master'.
> 
> Remove paintop factories that cannot produce settings on startup
> 
> BUG:287453 must be caused by some paintop factory that cannot create a
> settings object. Be much stricter about that and check whether factories
> can create a default settings object on startup.
> 
> M  +4    -1    krita/image/brushengine/kis_paintop_preset.cpp
> M  +22   -2    krita/image/brushengine/kis_paintop_registry.cc
> M  +9    -4    krita/ui/kis_paintop_box.cc
> 
> http://commits.kde.org/calligra/33909cb9b71a965418e27c71c3be301c26b96236
> 
> diff --git a/krita/image/brushengine/kis_paintop_preset.cpp \
> b/krita/image/brushengine/kis_paintop_preset.cpp index 9f99eb5..c205934 100644
> --- a/krita/image/brushengine/kis_paintop_preset.cpp
> +++ b/krita/image/brushengine/kis_paintop_preset.cpp
> @@ -39,6 +39,10 @@
> #include "kis_image.h"
> 
> struct KisPaintOpPreset::Private {
> +    Private()
> +        : settings(0)
> +    {}
> +
> KisPaintOpSettingsSP settings;
> QImage image;
> };
> @@ -48,7 +52,6 @@ KisPaintOpPreset::KisPaintOpPreset()
> > KoResource(QString())
> , m_d(new Private)
> {
> -    m_d->settings = 0;
> }
> 
> KisPaintOpPreset::KisPaintOpPreset(const QString & fileName)
> diff --git a/krita/image/brushengine/kis_paintop_registry.cc \
> b/krita/image/brushengine/kis_paintop_registry.cc index 52bec5c..b251931 100644
> --- a/krita/image/brushengine/kis_paintop_registry.cc
> +++ b/krita/image/brushengine/kis_paintop_registry.cc
> @@ -30,6 +30,7 @@
> #include <KoGenericRegistry.h>
> #include <KoPluginLoader.h>
> #include <KoColorSpace.h>
> +#include <KoColorSpaceRegistry.h>
> #include <KoCompositeOp.h>
> #include <KoID.h>
> 
> @@ -60,8 +61,23 @@ KisPaintOpRegistry* KisPaintOpRegistry::instance()
> K_GLOBAL_STATIC(KisPaintOpRegistry, s_instance);
> if (!s_instance.exists()) {
> KoPluginLoader::instance()->load("Krita/Paintop", "(Type == 'Service') and \
> ([X-Krita-Version] == 5)"); +
> +
> +        KisImageSP img = new KisImage(0, 0, 0, 0, 0, \
> KoColorSpaceRegistry::instance()->alpha8()); +        QStringList toBeRemoved;
> +
> foreach(const QString id, s_instance->keys()) {
> -            s_instance->get(id)->processAfterLoading();
> +            KisPaintOpFactory *factory = s_instance->get(id);
> +            if (!factory->settings(img)) {
> +                toBeRemoved << id;
> +            }
> +            else {
> +                factory->processAfterLoading();
> +            }
> +        }
> +        kWarning() << "The following brush engines do not provide a default brush \
> and are removed" << toBeRemoved; +        foreach(const QString id, toBeRemoved) {
> +            s_instance->remove(id);
> }
> }
> return s_instance;
> @@ -103,7 +119,7 @@ KisPaintOp * KisPaintOpRegistry::paintOp(const \
> KisPaintOpPresetSP preset, KisPai 
> KisPaintOpSettingsSP KisPaintOpRegistry::settings(const KoID& id, KisImageWSP \
> image) const {
> -    KisPaintOpFactory* f = value(id.id());
> +    KisPaintOpFactory *f = value(id.id());
> Q_ASSERT(f);
> if (f) {
> KisPaintOpSettingsSP settings = f->settings(image);
> @@ -120,6 +136,10 @@ KisPaintOpPresetSP KisPaintOpRegistry::defaultPreset(const \
> KoID& id, KisImageWSP 
> KisPaintOpSettingsSP s = settings(id, image);
> 
> +    if (s.isNull()) {
> +        return 0;
> +    }
> +
> preset->setSettings(s);
> preset->setPaintOp(id);
> Q_ASSERT(!preset->paintOp().id().isEmpty());
> diff --git a/krita/ui/kis_paintop_box.cc b/krita/ui/kis_paintop_box.cc
> index da97ae6..b92237d 100644
> --- a/krita/ui/kis_paintop_box.cc
> +++ b/krita/ui/kis_paintop_box.cc
> @@ -366,20 +366,25 @@ KoID KisPaintopBox::defaultPaintOp()
> KisPaintOpPresetSP KisPaintopBox::defaultPreset(const KoID& paintOp)
> {
> QString defaultName = paintOp.id() + ".kpp";
> -    QString path        = \
> KGlobal::mainComponent().dirs()->findResource("kis_defaultpresets", defaultName); + \
> QString path = KGlobal::mainComponent().dirs()->findResource("kis_defaultpresets", \
> defaultName); 
> KisPaintOpPresetSP preset = new KisPaintOpPreset(path);
> 
> -    if(!preset->load())
> -        return KisPaintOpRegistry::instance()->defaultPreset(paintOp, \
> m_view->image()); +    if (!preset->load()) {
> +        preset = KisPaintOpRegistry::instance()->defaultPreset(paintOp, \
> m_view->image()); +    }
> +
> +    Q_ASSERT(preset);
> +    Q_ASSERT(preset->valid());
> 
> return preset;
> }
> 
> KisPaintOpPresetSP KisPaintopBox::activePreset(const KoID& paintOp)
> {
> -    if(m_paintOpPresetMap[paintOp] == 0)
> +    if (m_paintOpPresetMap[paintOp] == 0) {
> m_paintOpPresetMap[paintOp] = defaultPreset(paintOp);
> +    }
> 
> return m_paintOpPresetMap[paintOp];
> }
_______________________________________________
kimageshop mailing list
kimageshop@kde.org
https://mail.kde.org/mailman/listinfo/kimageshop


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic