Commit fb115db9 authored by Dmitry Kazakov's avatar Dmitry Kazakov

Fix crash when trying to D&D or import a layer into Krita

That ancient KisImageWSP find-replace refactoring was really
not right.

BUG:372247
parent ee173232
......@@ -829,7 +829,7 @@ KisImageBuilder_Result KisPNGConverter::buildImage(const QString &filename)
}
KisImageWSP KisPNGConverter::image()
KisImageSP KisPNGConverter::image()
{
return m_image;
}
......
......@@ -112,7 +112,7 @@ public:
/**
* Retrieve the constructed image
*/
KisImageWSP image();
KisImageSP image();
static bool saveDeviceToStore(const QString &filename, const QRect &imageRect, const qreal xRes, const qreal yRes, KisPaintDeviceSP dev, KoStore *store, KisMetaData::Store* metaData = 0);
......@@ -124,7 +124,7 @@ private:
void progress(png_structp png_ptr, png_uint_32 row_number, int pass);
private:
png_uint_32 m_max_row;
KisImageWSP m_image;
KisImageSP m_image;
KisDocument *m_doc;
bool m_stop;
bool m_batchMode;
......
......@@ -87,7 +87,7 @@ KisImportExportFilter::ConversionStatus KisBrushImport::convert(KisDocument *doc
colorSpace = KoColorSpaceRegistry::instance()->colorSpace(GrayAColorModelID.id(), Integer8BitsColorDepthID.id(), "");
}
KisImageWSP image = new KisImage(document->createUndoStore(), brush->width(), brush->height(), colorSpace, brush->name());
KisImageSP image = new KisImage(document->createUndoStore(), brush->width(), brush->height(), colorSpace, brush->name());
image->setProperty("brushspacing", brush->spacing());
KisImagePipeBrush *pipeBrush = dynamic_cast<KisImagePipeBrush*>(brush);
......
......@@ -475,7 +475,7 @@ KisImageBuilder_Result CSVLoader::buildAnimation(QIODevice *io, const QString &f
return decode(io, filename);
}
KisImageWSP CSVLoader::image()
KisImageSP CSVLoader::image()
{
return m_image;
}
......
......@@ -40,7 +40,7 @@ public:
KisImageBuilder_Result buildAnimation(QIODevice *io, const QString &filename);
KisImageWSP image();
KisImageSP image();
private:
KisImageBuilder_Result decode(QIODevice *io, const QString &filename);
......@@ -53,7 +53,7 @@ private Q_SLOTS:
void cancel();
private:
KisImageWSP m_image;
KisImageSP m_image;
KisDocument* m_doc;
bool m_batchMode;
bool m_stop;
......
......@@ -63,7 +63,7 @@ CSVSaver::~CSVSaver()
{
}
KisImageWSP CSVSaver::image()
KisImageSP CSVSaver::image()
{
return m_image;
}
......@@ -386,7 +386,7 @@ QString CSVSaver::convertToBlending(const QString &opid)
KisImageBuilder_Result CSVSaver::getLayer(CSVLayerRecord* layer, KisDocument* exportDoc, KisKeyframeSP keyframe, const QString &path, int frame, int idx)
{
//render to the temp layer
KisImageWSP image = exportDoc->image();
KisImageSP image = exportDoc->image();
KisPaintDeviceSP device = image->rootLayer()->firstChild()->projection();
if (!keyframe.isNull()) {
......@@ -448,7 +448,7 @@ void CSVSaver::createTempImage(KisDocument* exportDoc)
exportDoc->setOutputMimeType("image/png");
exportDoc->setFileBatchMode(true);
KisImageWSP exportImage = new KisImage(exportDoc->createUndoStore(),
KisImageSP exportImage = new KisImage(exportDoc->createUndoStore(),
m_image->width(), m_image->height(), m_image->colorSpace(),
QString());
......
......@@ -40,7 +40,7 @@ public:
virtual ~CSVSaver();
KisImageBuilder_Result buildAnimation(QIODevice *io);
KisImageWSP image();
KisImageSP image();
private:
KisImageBuilder_Result encode(QIODevice *io);
......@@ -52,7 +52,7 @@ private Q_SLOTS:
void cancel();
private:
KisImageWSP m_image;
KisImageSP m_image;
KisDocument* m_doc;
bool m_batchMode;
bool m_stop;
......
......@@ -878,7 +878,7 @@ KisImageBuilder_Result EXRConverter::buildImage(const QString &filename)
}
KisImageWSP EXRConverter::image()
KisImageSP EXRConverter::image()
{
return d->image;
}
......@@ -1018,7 +1018,7 @@ KisImageBuilder_Result EXRConverter::buildFile(const QString &filename, KisPaint
if (!layer)
return KisImageBuilder_RESULT_INVALID_ARG;
KisImageWSP image = layer->image();
KisImageSP image = layer->image();
if (!image)
return KisImageBuilder_RESULT_EMPTY;
......@@ -1264,7 +1264,7 @@ KisImageBuilder_Result EXRConverter::buildFile(const QString &filename, KisGroup
if (!layer)
return KisImageBuilder_RESULT_INVALID_ARG;
KisImageWSP image = layer->image();
KisImageSP image = layer->image();
if (!image)
return KisImageBuilder_RESULT_EMPTY;
......
......@@ -41,7 +41,7 @@ public:
/**
* Retrieve the constructed image
*/
KisImageWSP image();
KisImageSP image();
QString errorMessage() const;
private:
KisImageBuilder_Result decode(const QString &filename);
......
......@@ -76,7 +76,7 @@ KisConfigWidget *EXRExport::createConfigurationWidget(QWidget *parent, const QBy
KisImportExportFilter::ConversionStatus EXRExport::convert(KisDocument *document, QIODevice */*io*/, KisPropertiesConfigurationSP configuration)
{
KisImageWSP image = document->image();
KisImageSP image = document->image();
EXRConverter exrConverter(document, !batchMode());
......
......@@ -29,11 +29,11 @@
struct KisExrLayersSorter::Private
{
Private(const QDomDocument &_extraData, KisImageWSP _image)
Private(const QDomDocument &_extraData, KisImageSP _image)
: extraData(_extraData), image(_image) {}
const QDomDocument &extraData;
KisImageWSP image;
KisImageSP image;
QMap<QString, QDomElement> pathToElementMap;
QMap<QString, int> pathToOrderingMap;
......@@ -161,7 +161,7 @@ void KisExrLayersSorter::Private::sortLayers(KisNodeSP root)
}
}
KisExrLayersSorter::KisExrLayersSorter(const QDomDocument &extraData, KisImageWSP image)
KisExrLayersSorter::KisExrLayersSorter(const QDomDocument &extraData, KisImageSP image)
: m_d(new Private(extraData, image))
{
KIS_ASSERT_RECOVER_RETURN(!extraData.isNull());
......
......@@ -28,7 +28,7 @@ class QDomDocument;
class KisExrLayersSorter
{
public:
KisExrLayersSorter(const QDomDocument &extraData, KisImageWSP image);
KisExrLayersSorter(const QDomDocument &extraData, KisImageSP image);
~KisExrLayersSorter();
private:
......
......@@ -91,7 +91,7 @@ void KisHeightMapExport::initializeCapabilities()
KisImportExportFilter::ConversionStatus KisHeightMapExport::convert(KisDocument *document, QIODevice *io, KisPropertiesConfigurationSP configuration)
{
KisImageWSP image = document->image();
KisImageSP image = document->image();
if (document->image()->width() != document->image()->height()) {
document->setErrorMessage(i18n("Cannot export this image to a heightmap: it is not square"));
......
......@@ -461,7 +461,7 @@ KisImageBuilder_Result KisJPEGConverter::buildFile(QIODevice *io, KisPaintLayerS
if (!layer)
return KisImageBuilder_RESULT_INVALID_ARG;
KisImageWSP image = KisImageWSP(layer->image());
KisImageSP image = KisImageSP(layer->image());
if (!image)
return KisImageBuilder_RESULT_EMPTY;
......
......@@ -65,7 +65,7 @@ KisJPEGExport::~KisJPEGExport()
KisImportExportFilter::ConversionStatus KisJPEGExport::convert(KisDocument *document, QIODevice *io, KisPropertiesConfigurationSP configuration)
{
KisImageWSP image = document->image();
KisImageSP image = document->image();
Q_CHECK_PTR(image);
// An extra option to pass to the config widget to set the state correctly, this isn't saved
......
......@@ -55,7 +55,7 @@ KraExport::~KraExport()
KisImportExportFilter::ConversionStatus KraExport::convert(KisDocument *document, QIODevice *io, KisPropertiesConfigurationSP /*configuration*/)
{
KisImageWSP image = document->image();
KisImageSP image = document->image();
Q_CHECK_PTR(image);
KisPaintDeviceSP pd = image->projection();
......
......@@ -82,7 +82,7 @@ QString expandEncodedDirectory(const QString& _intern)
}
KisKraLoadVisitor::KisKraLoadVisitor(KisImageWSP image,
KisKraLoadVisitor::KisKraLoadVisitor(KisImageSP image,
KoStore *store,
QMap<KisNode *, QString> &layerFilenames,
QMap<KisNode *, QString> &keyframeFilenames,
......
......@@ -37,7 +37,7 @@ class KRITALIBKRA_EXPORT KisKraLoadVisitor : public KisNodeVisitor
public:
KisKraLoadVisitor(KisImageWSP image,
KisKraLoadVisitor(KisImageSP image,
KoStore *store,
QMap<KisNode *, QString> &layerFilenames,
QMap<KisNode *, QString> &keyframeFilenames,
......@@ -81,7 +81,7 @@ private:
void loadNodeKeyframes(KisNode *node);
private:
KisImageWSP m_image;
KisImageSP m_image;
KoStore *m_store;
bool m_external;
QString m_uri;
......
......@@ -86,7 +86,7 @@ KisKraSaver::~KisKraSaver()
delete m_d;
}
QDomElement KisKraSaver::saveXML(QDomDocument& doc, KisImageWSP image)
QDomElement KisKraSaver::saveXML(QDomDocument& doc, KisImageSP image)
{
QDomElement imageElement = doc.createElement("IMAGE"); // Legacy!
......@@ -179,7 +179,7 @@ bool KisKraSaver::saveNodeKeyframes(KoStore *store, QString location, const KisN
return true;
}
bool KisKraSaver::saveBinaryData(KoStore* store, KisImageWSP image, const QString &uri, bool external, bool autosave)
bool KisKraSaver::saveBinaryData(KoStore* store, KisImageSP image, const QString &uri, bool external, bool autosave)
{
QString location;
......@@ -293,7 +293,7 @@ QStringList KisKraSaver::errorMessages() const
return m_d->errorMessages;
}
void KisKraSaver::saveBackgroundColor(QDomDocument& doc, QDomElement& element, KisImageWSP image)
void KisKraSaver::saveBackgroundColor(QDomDocument& doc, QDomElement& element, KisImageSP image)
{
QDomElement e = doc.createElement(CANVASPROJECTIONCOLOR);
KoColor color = image->defaultProjectionColor();
......@@ -302,7 +302,7 @@ void KisKraSaver::saveBackgroundColor(QDomDocument& doc, QDomElement& element, K
element.appendChild(e);
}
void KisKraSaver::saveWarningColor(QDomDocument& doc, QDomElement& element, KisImageWSP image)
void KisKraSaver::saveWarningColor(QDomDocument& doc, QDomElement& element, KisImageSP image)
{
if (image->proofingConfiguration()) {
QDomElement e = doc.createElement(PROOFINGWARNINGCOLOR);
......@@ -314,7 +314,7 @@ void KisKraSaver::saveWarningColor(QDomDocument& doc, QDomElement& element, KisI
}
}
void KisKraSaver::saveCompositions(QDomDocument& doc, QDomElement& element, KisImageWSP image)
void KisKraSaver::saveCompositions(QDomDocument& doc, QDomElement& element, KisImageSP image)
{
if (!image->compositions().isEmpty()) {
QDomElement e = doc.createElement("compositions");
......
......@@ -38,19 +38,19 @@ public:
~KisKraSaver();
QDomElement saveXML(QDomDocument& doc, KisImageWSP image);
QDomElement saveXML(QDomDocument& doc, KisImageSP image);
bool saveKeyframes(KoStore *store, const QString &uri, bool external);
bool saveBinaryData(KoStore* store, KisImageWSP image, const QString & uri, bool external, bool includeMerge);
bool saveBinaryData(KoStore* store, KisImageSP image, const QString & uri, bool external, bool includeMerge);
/// @return a list with everthing that went wrong while saving
QStringList errorMessages() const;
private:
void saveBackgroundColor(QDomDocument& doc, QDomElement& element, KisImageWSP image);
void saveWarningColor(QDomDocument& doc, QDomElement& element, KisImageWSP image);
void saveCompositions(QDomDocument& doc, QDomElement& element, KisImageWSP image);
void saveBackgroundColor(QDomDocument& doc, QDomElement& element, KisImageSP image);
void saveWarningColor(QDomDocument& doc, QDomElement& element, KisImageSP image);
void saveCompositions(QDomDocument& doc, QDomElement& element, KisImageSP image);
bool saveAssistants(KoStore *store,QString uri, bool external);
bool saveAssistantsList(QDomDocument& doc, QDomElement& element);
bool saveGrid(QDomDocument& doc, QDomElement& element);
......
......@@ -48,7 +48,7 @@ void KisKraLoaderTest::testLoading()
{
KisDocument *doc = KisPart::instance()->createDocument();
doc->loadNativeFormat(QString(FILES_DATA_DIR) + QDir::separator() + "load_test.kra");
KisImageWSP image = doc->image();
KisImageSP image = doc->image();
image->lock();
QCOMPARE(image->nlayers(), 12);
QCOMPARE(doc->documentInfo()->aboutInfo("title"), QString("test image for loading"));
......@@ -81,7 +81,7 @@ void testObligeSingleChildImpl(bool transpDefaultPixel)
KisDocument *doc = KisPart::instance()->createDocument();
doc->loadNativeFormat(fileName);
KisImageWSP image = doc->image();
KisImageSP image = doc->image();
QVERIFY(image);
QCOMPARE(image->nlayers(), 2);
......@@ -116,7 +116,7 @@ void KisKraLoaderTest::testLoadAnimated()
{
KisDocument *doc = KisPart::instance()->createDocument();
doc->loadNativeFormat(QString(FILES_DATA_DIR) + QDir::separator() + "load_test_animation.kra");
KisImageWSP image = doc->image();
KisImageSP image = doc->image();
KisNodeSP node1 = image->root()->firstChild();
KisNodeSP node2 = node1->nextSibling();
......
......@@ -65,7 +65,7 @@ KisSelectionSP createPixelSelection(KisPaintDeviceSP paintDevice)
return pixelSelection;
}
KisSelectionSP createVectorSelection(KisPaintDeviceSP paintDevice, KisImageWSP image)
KisSelectionSP createVectorSelection(KisPaintDeviceSP paintDevice, KisImageSP image)
{
KisSelectionSP vectorSelection = new KisSelection(new KisSelectionDefaultBounds(paintDevice));
KoPathShape* path = new KoPathShape();
......@@ -89,7 +89,7 @@ QTransform createTestingTransform() {
KisDocument* createCompleteDocument()
{
KisImageWSP image = new KisImage(0, 1024, 1024, KoColorSpaceRegistry::instance()->rgb8(), "test for roundtrip");
KisImageSP image = new KisImage(0, 1024, 1024, KoColorSpaceRegistry::instance()->rgb8(), "test for roundtrip");
KisDocument *doc = qobject_cast<KisDocument*>(KisPart::instance()->createDocument());
......@@ -212,7 +212,7 @@ KisDocument* createCompleteDocument()
KisDocument *createEmptyDocument()
{
KisImageWSP image = new KisImage(0, 1024, 1024, KoColorSpaceRegistry::instance()->rgb8(), "test for roundtrip");
KisImageSP image = new KisImage(0, 1024, 1024, KoColorSpaceRegistry::instance()->rgb8(), "test for roundtrip");
KisDocument *doc = qobject_cast<KisDocument*>(KisPart::instance()->createDocument());
......
......@@ -116,7 +116,7 @@ KisImportExportFilter::ConversionStatus KisODGImport::convert(KisDocument *docum
KoShapeLoadingContext shapeContext(context, document->shapeController()->resourceManager());
const KoColorSpace* cs = KoColorSpaceRegistry::instance()->rgb8();
KisImageWSP image = new KisImage(document->createUndoStore(), width, height, cs, "built image");
KisImageSP image = new KisImage(document->createUndoStore(), width, height, cs, "built image");
document->setCurrentImage(image);
KoXmlElement layerElement;
......
......@@ -28,7 +28,7 @@ class KisOpenRasterLoadContext
{
public:
virtual ~KisOpenRasterLoadContext() {}
virtual KisImageWSP loadDeviceData(const QString & fileName) = 0;
virtual KisImageSP loadDeviceData(const QString & fileName) = 0;
virtual QDomDocument loadStack() = 0;
};
......
......@@ -42,7 +42,7 @@
#include "kis_open_raster_load_context.h"
struct KisOpenRasterStackLoadVisitor::Private {
KisImageWSP image;
KisImageSP image;
vKisNodeSP activeNodes;
KisUndoStore* undoStore;
KisOpenRasterLoadContext* loadContext;
......@@ -62,7 +62,7 @@ KisOpenRasterStackLoadVisitor::~KisOpenRasterStackLoadVisitor()
delete d;
}
KisImageWSP KisOpenRasterStackLoadVisitor::image()
KisImageSP KisOpenRasterStackLoadVisitor::image()
{
return d->image;
}
......@@ -218,7 +218,7 @@ void KisOpenRasterStackLoadVisitor::loadGroupLayer(const QDomElement& elem, KisG
if (!filename.isNull()) {
double opacity = 1.0;
opacity = KisDomUtils::toDouble(subelem.attribute("opacity", "1.0"));
KisImageWSP pngImage = d->loadContext->loadDeviceData(filename);
KisImageSP pngImage = d->loadContext->loadDeviceData(filename);
if (pngImage) {
// If ORA doesn't have resolution info, load the default value(75 ppi) else fetch from stack.xml
d->image->setResolution(d->xRes, d->yRes);
......
......@@ -37,7 +37,7 @@ public:
void loadPaintLayer(const QDomElement& elem, KisPaintLayerSP pL);
void loadAdjustmentLayer(const QDomElement& elem, KisAdjustmentLayerSP pL);
void loadGroupLayer(const QDomElement& elem, KisGroupLayerSP gL);
KisImageWSP image();
KisImageSP image();
vKisNodeSP activeNodes();
private:
void loadLayerInfo(const QDomElement& elem, KisLayerSP layer);
......
......@@ -62,7 +62,7 @@ KisImageBuilder_Result OraConverter::buildImage(QIODevice *io)
return KisImageBuilder_RESULT_OK;
}
KisImageWSP OraConverter::image()
KisImageSP OraConverter::image()
{
return m_image;
}
......@@ -72,7 +72,7 @@ vKisNodeSP OraConverter::activeNodes()
return m_activeNodes;
}
KisImageBuilder_Result OraConverter::buildFile(QIODevice *io, KisImageWSP image, vKisNodeSP activeNodes)
KisImageBuilder_Result OraConverter::buildFile(QIODevice *io, KisImageSP image, vKisNodeSP activeNodes)
{
// Open file for writing
......
......@@ -35,16 +35,16 @@ public:
virtual ~OraConverter();
public:
KisImageBuilder_Result buildImage(QIODevice *io);
KisImageBuilder_Result buildFile(QIODevice *io, KisImageWSP image, vKisNodeSP activeNodes);
KisImageBuilder_Result buildFile(QIODevice *io, KisImageSP image, vKisNodeSP activeNodes);
/**
* Retrieve the constructed image
*/
KisImageWSP image();
KisImageSP image();
vKisNodeSP activeNodes();
public Q_SLOTS:
virtual void cancel();
private:
KisImageWSP m_image;
KisImageSP m_image;
KisDocument *m_doc;
vKisNodeSP m_activeNodes;
bool m_stop;
......
......@@ -73,7 +73,7 @@ bool hasShapeLayerChild(KisNodeSP node)
KisImportExportFilter::ConversionStatus OraExport::convert(KisDocument *document, QIODevice *io, KisPropertiesConfigurationSP /*configuration*/)
{
KisImageWSP image = document->image();
KisImageSP image = document->image();
Q_CHECK_PTR(image);
......
......@@ -36,7 +36,7 @@ OraLoadContext::~OraLoadContext()
{
}
KisImageWSP OraLoadContext::loadDeviceData(const QString & filename)
KisImageSP OraLoadContext::loadDeviceData(const QString & filename)
{
if (m_store->open(filename)) {
KoStoreDevice io(m_store);
......
......@@ -27,7 +27,7 @@ class OraLoadContext : public KisOpenRasterLoadContext
public:
OraLoadContext(KoStore* _store);
virtual ~OraLoadContext();
virtual KisImageWSP loadDeviceData(const QString & fileName);
virtual KisImageSP loadDeviceData(const QString & fileName);
virtual QDomDocument loadStack();
......
......@@ -110,7 +110,7 @@ KisPDFImport::ConversionStatus KisPDFImport::convert(KisDocument *document, QIOD
const KoColorSpace* cs = KoColorSpaceRegistry::instance()->rgb8();
int width = wdg->intWidth->value();
int height = wdg->intHeight->value();
KisImageWSP image = new KisImage(document->createUndoStore(), width, height, cs, "built image");
KisImageSP image = new KisImage(document->createUndoStore(), width, height, cs, "built image");
image->setResolution(wdg->intResolution->value() / 72.0, wdg->intResolution->value() / 72.0);
// create a layer
......
......@@ -71,7 +71,7 @@ bool hasVisibleWidgets()
KisImportExportFilter::ConversionStatus KisPNGExport::convert(KisDocument *document, QIODevice *io, KisPropertiesConfigurationSP configuration)
{
KisImageWSP image = document->image();
KisImageSP image = document->image();
KisPNGOptions options;
......
......@@ -141,7 +141,7 @@ KisImportExportFilter::ConversionStatus KisPPMExport::convert(KisDocument *docum
bool bitmap = (mimeType() == "image/x-portable-bitmap");
KisImageWSP image = document->image();
KisImageSP image = document->image();
Q_CHECK_PTR(image);
// the image must be locked at the higher levels
KIS_SAFE_ASSERT_RECOVER_NOOP(document->image()->locked());
......
......@@ -358,7 +358,7 @@ KisImageBuilder_Result PSDLoader::buildImage(QIODevice *io)
}
KisImageWSP PSDLoader::image()
KisImageSP PSDLoader::image()
{
return m_image;
}
......
......@@ -39,7 +39,7 @@ public:
KisImageBuilder_Result buildImage(QIODevice *io);
KisImageWSP image();
KisImageSP image();
public Q_SLOTS:
......@@ -51,7 +51,7 @@ private:
private:
KisImageWSP m_image;
KisImageSP m_image;
KisDocument *m_doc;
bool m_stop;
};
......
......@@ -95,7 +95,7 @@ PSDSaver::~PSDSaver()
{
}
KisImageWSP PSDSaver::image()
KisImageSP PSDSaver::image()
{
return m_image;
}
......
......@@ -41,7 +41,7 @@ public:
KisImageBuilder_Result buildFile(QIODevice *io);
KisImageWSP image();
KisImageSP image();
public Q_SLOTS:
......@@ -49,7 +49,7 @@ public Q_SLOTS:
private:
KisImageWSP m_image;
KisImageSP m_image;
KisDocument *m_doc;
bool m_stop;
};
......