Commit 06450d56 authored by Dmitry Kazakov's avatar Dmitry Kazakov

Proper fix for https://bugs.kde.org/show_bug.cgi?id=385521 which I came across

while trying to fix gradient brushtip previews.  Just changed it to pass the
resource manager to KisPresetLivePreviewView, so it can pass it to KisResourcesSnapshot.

Both the gradient brushtip and gradient colorsource display correctly in the live
preview now.

# Conflicts:
#	libs/ui/tool/kis_resources_snapshot.cpp
parent 92678b93
......@@ -386,6 +386,10 @@ QTransform KisResourcesSnapshot::fillTransform() const
return m_d->fillTransform;
}
KoAbstractGradientSP KisResourcesSnapshot::currentGradient() const
{
return m_d->currentGradient;
}
QBitArray KisResourcesSnapshot::channelLockFlags() const
{
......
......@@ -83,6 +83,7 @@ public:
KoColor currentFgColor() const;
KoColor currentBgColor() const;
KisPaintOpPresetSP currentPaintOpPreset() const;
KoAbstractGradientSP currentGradient() const;
QTransform fillTransform() const;
......
......@@ -314,7 +314,7 @@ KisPaintOpPresetsPopup::KisPaintOpPresetsPopup(KisCanvasResourceProvider * resou
updateThemedIcons();
// setup things like the scene construct images, layers, etc that is a one-time thing
m_d->uiWdgPaintOpPresetSettings.liveBrushPreviewView->setup();
m_d->uiWdgPaintOpPresetSettings.liveBrushPreviewView->setup(resourceProvider->resourceManager());
}
......
......@@ -27,6 +27,7 @@
#include <kis_brush.h>
#include <KisGlobalResourcesInterface.h>
#include "kis_transaction.h"
#include <KoCanvasResourceProvider.h>
KisPresetLivePreviewView::KisPresetLivePreviewView(QWidget *parent)
: QGraphicsView(parent),
......@@ -41,8 +42,10 @@ KisPresetLivePreviewView::~KisPresetLivePreviewView()
delete m_brushPreviewScene;
}
void KisPresetLivePreviewView::setup()
void KisPresetLivePreviewView::setup(KoCanvasResourceProvider* resourceManager)
{
m_resourceManager = resourceManager;
// initializing to 0 helps check later if they actually have something in them
m_noPreviewText = 0;
m_sceneImageItem = 0;
......@@ -280,22 +283,12 @@ void KisPresetLivePreviewView::setupAndPaintStroke()
}
}
// Preset preview cannot display gradient color source: there is
// no resource manager for KisResourcesSnapshot, therefore gradient is nullptr.
// BUG: 385521 (Selecting "Gradient" in brush editor crashes krita)
if (proxy_preset->paintOp().id() == "paintbrush") {
QString colorSourceType = settings->getString("ColorSource/Type", "plain");
if (colorSourceType == "gradient") {
settings->setProperty("ColorSource/Type", "plain");
}
}
proxy_preset->setSettings(settings);
KisResourcesSnapshotSP resources =
new KisResourcesSnapshot(m_image,
m_layer);
m_layer, m_resourceManager);
resources->setOpacity(settings->paintOpOpacity());
resources->setBrush(proxy_preset);
......
......@@ -36,6 +36,8 @@
#include <KoColor.h>
#include "kis_signal_compressor.h"
class KoCanvasResourceProvider;
/**
* Widget for displaying a live brush preview of your
* selected brush. It listens for signalsetting changes
......@@ -58,7 +60,7 @@ public:
* This live preview might be in a UI file, so make sure to
* call this before starting to use it
*/
void setup();
void setup(KoCanvasResourceProvider* resourceManager);
/**
* @brief set the current preset from resource manager for the live preview to use.
......@@ -74,6 +76,9 @@ private Q_SLOTS:
private:
///internally sets the Resource Provider for brush preview (allowing gradients in preview)
KoCanvasResourceProvider* m_resourceManager;
/// internally sets the image area for brush preview
KisImageSP m_image;
......
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