Commit 46283124 authored by Boudewijn Rempt's avatar Boudewijn Rempt Committed by Scott Petrovic

Port the save-saving patch from 3.1

BUG:370193 Save a copy of the image not the original

This restores the delayed saving dialog, which is now even weirder,
with a cancel running operating button which mostly doesn't work,
a do not save button, and a don't care, save a broken copy button.

See also

https://phabricator.kde.org/D3258
https://phabricator.kde.org/T4220
https://bugs.kde.org/show_bug.cgi?id=370566
https://bugs.kde.org/show_bug.cgi?id=369368
https://bugs.kde.org/show_bug.cgi?id=370193
parent cecce7a4
...@@ -268,7 +268,8 @@ public: ...@@ -268,7 +268,8 @@ public:
macroNestDepth(0), macroNestDepth(0),
imageIdleWatcher(2000 /*ms*/), imageIdleWatcher(2000 /*ms*/),
suppressProgress(false), suppressProgress(false),
fileProgressProxy(0) fileProgressProxy(0),
savingLock(&savingMutex)
{ {
if (QLocale().measurementSystem() == QLocale::ImperialSystem) { if (QLocale().measurementSystem() == QLocale::ImperialSystem) {
unit = KoUnit::Inch; unit = KoUnit::Inch;
...@@ -333,6 +334,8 @@ public: ...@@ -333,6 +334,8 @@ public:
qint32 macroNestDepth; qint32 macroNestDepth;
KisImageSP image; KisImageSP image;
KisImageSP savingImage;
KisNodeSP preActivatedNode; KisNodeSP preActivatedNode;
KisShapeController* shapeController; KisShapeController* shapeController;
KoShapeController* koShapeController; KoShapeController* koShapeController;
...@@ -345,6 +348,8 @@ public: ...@@ -345,6 +348,8 @@ public:
QList<KisPaintingAssistantSP> assistants; QList<KisPaintingAssistantSP> assistants;
KisGridConfig gridConfig; KisGridConfig gridConfig;
StdLockableWrapper<QMutex> savingLock;
void setImageAndInitIdleWatcher(KisImageSP _image) { void setImageAndInitIdleWatcher(KisImageSP _image) {
image = _image; image = _image;
...@@ -365,10 +370,9 @@ class KisDocument::Private::SafeSavingLocker { ...@@ -365,10 +370,9 @@ class KisDocument::Private::SafeSavingLocker {
public: public:
SafeSavingLocker(KisDocument::Private *_d, KisDocument *document) SafeSavingLocker(KisDocument::Private *_d, KisDocument *document)
: d(_d) : d(_d)
, m_document(document)
, m_locked(false) , m_locked(false)
, m_imageLock(d->image, true) , m_imageLock(d->image, true)
, m_savingLock(&d->savingMutex)
, m_document(document)
{ {
const int realAutoSaveInterval = KisConfig().autoSaveInterval(); const int realAutoSaveInterval = KisConfig().autoSaveInterval();
const int emergencyAutoSaveInterval = 10; // sec const int emergencyAutoSaveInterval = 10; // sec
...@@ -382,20 +386,20 @@ public: ...@@ -382,20 +386,20 @@ public:
* Since we are trying to lock multiple objects, so we should * Since we are trying to lock multiple objects, so we should
* do it in a safe manner. * do it in a safe manner.
*/ */
m_locked = std::try_lock(m_imageLock, m_savingLock) < 0; m_locked = std::try_lock(m_imageLock, d->savingLock) < 0;
if (!m_locked) { if (!m_locked) {
if (d->isAutosaving) { if (d->isAutosaving) {
d->disregardAutosaveFailure = true; d->disregardAutosaveFailure = true;
if (realAutoSaveInterval) { if (realAutoSaveInterval) {
document->setAutoSaveDelay(emergencyAutoSaveInterval); m_document->setAutoSaveDelay(emergencyAutoSaveInterval);
} }
} else { } else {
d->image->requestStrokeEnd(); d->image->requestStrokeEnd();
QApplication::processEvents(); QApplication::processEvents();
// one more try... // one more try...
m_locked = std::try_lock(m_imageLock, m_savingLock) < 0; m_locked = std::try_lock(m_imageLock, d->savingLock) < 0;
} }
} }
...@@ -407,7 +411,7 @@ public: ...@@ -407,7 +411,7 @@ public:
~SafeSavingLocker() { ~SafeSavingLocker() {
if (m_locked) { if (m_locked) {
m_imageLock.unlock(); m_imageLock.unlock();
m_savingLock.unlock(); d->savingLock.unlock();
const int realAutoSaveInterval = KisConfig().autoSaveInterval(); const int realAutoSaveInterval = KisConfig().autoSaveInterval();
m_document->setAutoSaveDelay(realAutoSaveInterval); m_document->setAutoSaveDelay(realAutoSaveInterval);
...@@ -420,11 +424,10 @@ public: ...@@ -420,11 +424,10 @@ public:
private: private:
KisDocument::Private *d; KisDocument::Private *d;
KisDocument *m_document;
bool m_locked; bool m_locked;
KisImageBarrierLockAdapter m_imageLock; KisImageBarrierLockAdapter m_imageLock;
StdLockableWrapper<QMutex> m_savingLock;
KisDocument *m_document;
}; };
KisDocument::KisDocument() KisDocument::KisDocument()
...@@ -630,9 +633,7 @@ bool KisDocument::save(KisPropertiesConfigurationSP exportConfiguration) ...@@ -630,9 +633,7 @@ bool KisDocument::save(KisPropertiesConfigurationSP exportConfiguration)
bool KisDocument::saveFile(const QString &filePath, KisPropertiesConfigurationSP exportConfiguration) bool KisDocument::saveFile(const QString &filePath, KisPropertiesConfigurationSP exportConfiguration)
{ {
Private::SafeSavingLocker locker(d, this); if (!prepareLocksForSaving()) {
if (!locker.successfullyLocked()) {
qWarning() << "Could not lock image for saving, it's still busy";
return false; return false;
} }
...@@ -780,6 +781,7 @@ bool KisDocument::saveFile(const QString &filePath, KisPropertiesConfigurationSP ...@@ -780,6 +781,7 @@ bool KisDocument::saveFile(const QString &filePath, KisPropertiesConfigurationSP
emit sigSavingFinished(); emit sigSavingFinished();
clearFileProgressUpdater(); clearFileProgressUpdater();
unlockAfterSaving();
return ret; return ret;
} }
...@@ -1616,6 +1618,11 @@ KisImageWSP KisDocument::image() const ...@@ -1616,6 +1618,11 @@ KisImageWSP KisDocument::image() const
return d->image; return d->image;
} }
KisImageSP KisDocument::savingImage() const
{
return d->savingImage;
}
void KisDocument::setCurrentImage(KisImageSP image) void KisDocument::setCurrentImage(KisImageSP image)
{ {
...@@ -1651,3 +1658,36 @@ bool KisDocument::isAutosaving() const ...@@ -1651,3 +1658,36 @@ bool KisDocument::isAutosaving() const
{ {
return d->isAutosaving; return d->isAutosaving;
} }
bool KisDocument::prepareLocksForSaving()
{
{
Private::SafeSavingLocker locker(d, this);
if (locker.successfullyLocked()) {
d->savingImage = d->image->clone(true);
}
else {
d->lastErrorMessage = i18n("The image was still busy while saving. Your saved image might be incomplete.");
d->image->lock();
d->savingImage = d->image->clone(true);
d->image->unlock();
}
}
if (!d->savingMutex.tryLock()) {
qWarning() << "Could not lock for saving!";
d->lastErrorMessage = i18n("Could not lock the image for saving.");
d->savingImage = 0;
return false;
}
Q_ASSERT(d->savingImage);
return true;
}
void KisDocument::unlockAfterSaving()
{
d->savingImage = 0;
d->savingMutex.unlock();
}
...@@ -508,6 +508,16 @@ public: ...@@ -508,6 +508,16 @@ public:
KisImageWSP image() const; KisImageWSP image() const;
/**
* @brief savingImage provides a detached, shallow copy of the original image that must be used when saving.
* Any strokes in progress will not be applied to this image, so the result might be missing some data. On
* the other hand, it won't block.
*
* @return a shallow copy of the original image, or 0 is saving is not in progress
*/
KisImageSP savingImage() const;
/** /**
* Adds progressproxy for file operations * Adds progressproxy for file operations
*/ */
...@@ -580,6 +590,10 @@ private Q_SLOTS: ...@@ -580,6 +590,10 @@ private Q_SLOTS:
private: private:
bool prepareLocksForSaving();
void unlockAfterSaving();
QString prettyPathOrUrl() const; QString prettyPathOrUrl() const;
bool openUrlInternal(const QUrl &url); bool openUrlInternal(const QUrl &url);
......
...@@ -43,7 +43,10 @@ KisDelayedSaveDialog::KisDelayedSaveDialog(KisImageSP image, QWidget *parent) ...@@ -43,7 +43,10 @@ KisDelayedSaveDialog::KisDelayedSaveDialog(KisImageSP image, QWidget *parent)
ui->setupUi(this); ui->setupUi(this);
connect(ui->btnCancel, SIGNAL(clicked()), SLOT(slotCancelRequested())); connect(ui->bnDontWait, SIGNAL(clicked()), SLOT(accept()));
connect(ui->bnDontSave, SIGNAL(clicked()), SLOT(reject()));
connect(ui->bnCancel, SIGNAL(clicked()), SLOT(slotCancelRequested()));
connect(&m_d->updateTimer, SIGNAL(timeout()), SLOT(slotTimerTimeout())); connect(&m_d->updateTimer, SIGNAL(timeout()), SLOT(slotTimerTimeout()));
m_d->image->compositeProgressProxy()->addProxy(ui->progressBar); m_d->image->compositeProgressProxy()->addProxy(ui->progressBar);
......
...@@ -9,8 +9,8 @@ ...@@ -9,8 +9,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>374</width> <width>449</width>
<height>157</height> <height>147</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
<property name="modal"> <property name="modal">
<bool>true</bool> <bool>true</bool>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout" stretch="2,1,3,1"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
<widget class="QLabel" name="lblMessage"> <widget class="QLabel" name="lblMessage">
<property name="text"> <property name="text">
...@@ -54,11 +54,29 @@ ...@@ -54,11 +54,29 @@
</spacer> </spacer>
</item> </item>
<item> <item>
<widget class="QPushButton" name="btnCancel"> <layout class="QHBoxLayout" name="horizontalLayout">
<property name="text"> <item>
<string>Cancel Operation and Save</string> <widget class="QPushButton" name="bnDontWait">
</property> <property name="text">
</widget> <string>Save without waiting</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="bnCancel">
<property name="text">
<string>Cancel Operation and Save</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="bnDontSave">
<property name="text">
<string>Close, do not save</string>
</property>
</widget>
</item>
</layout>
</item> </item>
</layout> </layout>
</widget> </widget>
......
...@@ -45,8 +45,8 @@ KisBMPExport::~KisBMPExport() ...@@ -45,8 +45,8 @@ KisBMPExport::~KisBMPExport()
KisImportExportFilter::ConversionStatus KisBMPExport::convert(KisDocument *document, QIODevice *io, KisPropertiesConfigurationSP /*configuration*/) KisImportExportFilter::ConversionStatus KisBMPExport::convert(KisDocument *document, QIODevice *io, KisPropertiesConfigurationSP /*configuration*/)
{ {
QRect rc = document->image()->bounds(); QRect rc = document->savingImage()->bounds();
QImage image = document->image()->projection()->convertToQImage(0, 0, 0, rc.width(), rc.height(), KoColorConversionTransformation::internalRenderingIntent(), KoColorConversionTransformation::internalConversionFlags()); QImage image = document->savingImage()->projection()->convertToQImage(0, 0, 0, rc.width(), rc.height(), KoColorConversionTransformation::internalRenderingIntent(), KoColorConversionTransformation::internalConversionFlags());
image.save(io, QFileInfo(filename()).suffix().toLatin1()); image.save(io, QFileInfo(filename()).suffix().toLatin1());
return KisImportExportFilter::OK; return KisImportExportFilter::OK;
} }
......
...@@ -64,7 +64,7 @@ KisImportExportFilter::ConversionStatus KisBrushExport::convert(KisDocument *doc ...@@ -64,7 +64,7 @@ KisImportExportFilter::ConversionStatus KisBrushExport::convert(KisDocument *doc
{ {
// XXX: Loading the parasite itself was commented out -- needs investigation // XXX: Loading the parasite itself was commented out -- needs investigation
// KisAnnotationSP annotation = document->image()->annotation("ImagePipe Parasite"); // KisAnnotationSP annotation = document->savingImage()->annotation("ImagePipe Parasite");
// KisPipeBrushParasite parasite; // KisPipeBrushParasite parasite;
// if (annotation) { // if (annotation) {
// QBuffer buf(const_cast<QByteArray*>(&annotation->annotation())); // QBuffer buf(const_cast<QByteArray*>(&annotation->annotation()));
...@@ -74,8 +74,8 @@ KisImportExportFilter::ConversionStatus KisBrushExport::convert(KisDocument *doc ...@@ -74,8 +74,8 @@ KisImportExportFilter::ConversionStatus KisBrushExport::convert(KisDocument *doc
// } // }
KisBrushExportOptions exportOptions; KisBrushExportOptions exportOptions;
if (document->image()->dynamicPropertyNames().contains("brushspacing")) { if (document->savingImage()->dynamicPropertyNames().contains("brushspacing")) {
exportOptions.spacing = document->image()->property("brushspacing").toFloat(); exportOptions.spacing = document->savingImage()->property("brushspacing").toFloat();
} }
else { else {
exportOptions.spacing = configuration->getInt("spacing"); exportOptions.spacing = configuration->getInt("spacing");
...@@ -84,7 +84,7 @@ KisImportExportFilter::ConversionStatus KisBrushExport::convert(KisDocument *doc ...@@ -84,7 +84,7 @@ KisImportExportFilter::ConversionStatus KisBrushExport::convert(KisDocument *doc
exportOptions.name = configuration->getString("name"); exportOptions.name = configuration->getString("name");
} }
else { else {
exportOptions.name = document->image()->objectName(); exportOptions.name = document->savingImage()->objectName();
} }
exportOptions.mask = configuration->getBool("mask"); exportOptions.mask = configuration->getBool("mask");
exportOptions.selectionMode = configuration->getInt("selectionMode"); exportOptions.selectionMode = configuration->getInt("selectionMode");
...@@ -103,17 +103,14 @@ KisImportExportFilter::ConversionStatus KisBrushExport::convert(KisDocument *doc ...@@ -103,17 +103,14 @@ KisImportExportFilter::ConversionStatus KisBrushExport::convert(KisDocument *doc
qApp->processEvents(); // For vector layers to be updated qApp->processEvents(); // For vector layers to be updated
// the image must be locked at the higher levels QRect rc = document->savingImage()->bounds();
KIS_SAFE_ASSERT_RECOVER_NOOP(document->image()->locked());
QRect rc = document->image()->bounds();
brush->setName(exportOptions.name); brush->setName(exportOptions.name);
brush->setSpacing(exportOptions.spacing); brush->setSpacing(exportOptions.spacing);
brush->setUseColorAsMask(exportOptions.mask); brush->setUseColorAsMask(exportOptions.mask);
int w = document->image()->width(); int w = document->savingImage()->width();
int h = document->image()->height(); int h = document->savingImage()->height();
KisImagePipeBrush *pipeBrush = dynamic_cast<KisImagePipeBrush*>(brush); KisImagePipeBrush *pipeBrush = dynamic_cast<KisImagePipeBrush*>(brush);
if (pipeBrush) { if (pipeBrush) {
...@@ -123,7 +120,7 @@ KisImportExportFilter::ConversionStatus KisBrushExport::convert(KisDocument *doc ...@@ -123,7 +120,7 @@ KisImportExportFilter::ConversionStatus KisBrushExport::convert(KisDocument *doc
KoProperties properties; KoProperties properties;
properties.setProperty("visible", true); properties.setProperty("visible", true);
QList<KisNodeSP> layers = document->image()->root()->childNodes(QStringList("KisLayer"), properties); QList<KisNodeSP> layers = document->savingImage()->root()->childNodes(QStringList("KisLayer"), properties);
Q_FOREACH (KisNodeSP node, layers) { Q_FOREACH (KisNodeSP node, layers) {
devices[0].push_back(node->projection().data()); devices[0].push_back(node->projection().data());
...@@ -153,7 +150,7 @@ KisImportExportFilter::ConversionStatus KisBrushExport::convert(KisDocument *doc ...@@ -153,7 +150,7 @@ KisImportExportFilter::ConversionStatus KisBrushExport::convert(KisDocument *doc
pipeBrush->setDevices(devices, w, h); pipeBrush->setDevices(devices, w, h);
} }
else { else {
QImage image = document->image()->projection()->convertToQImage(0, 0, 0, rc.width(), rc.height(), KoColorConversionTransformation::internalRenderingIntent(), KoColorConversionTransformation::internalConversionFlags()); QImage image = document->savingImage()->projection()->convertToQImage(0, 0, 0, rc.width(), rc.height(), KoColorConversionTransformation::internalRenderingIntent(), KoColorConversionTransformation::internalConversionFlags());
brush->setImage(image); brush->setImage(image);
} }
......
...@@ -52,7 +52,7 @@ ...@@ -52,7 +52,7 @@
#include "csv_layer_record.h" #include "csv_layer_record.h"
CSVSaver::CSVSaver(KisDocument *doc, bool batchMode) CSVSaver::CSVSaver(KisDocument *doc, bool batchMode)
: m_image(doc->image()) : m_image(doc->savingImage())
, m_doc(doc) , m_doc(doc)
, m_batchMode(batchMode) , m_batchMode(batchMode)
, m_stop(false) , m_stop(false)
...@@ -386,7 +386,7 @@ QString CSVSaver::convertToBlending(const QString &opid) ...@@ -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) KisImageBuilder_Result CSVSaver::getLayer(CSVLayerRecord* layer, KisDocument* exportDoc, KisKeyframeSP keyframe, const QString &path, int frame, int idx)
{ {
//render to the temp layer //render to the temp layer
KisImageSP image = exportDoc->image(); KisImageSP image = exportDoc->savingImage();
KisPaintDeviceSP device = image->rootLayer()->firstChild()->projection(); KisPaintDeviceSP device = image->rootLayer()->firstChild()->projection();
if (!keyframe.isNull()) { if (!keyframe.isNull()) {
......
...@@ -76,24 +76,19 @@ KisConfigWidget *EXRExport::createConfigurationWidget(QWidget *parent, const QBy ...@@ -76,24 +76,19 @@ KisConfigWidget *EXRExport::createConfigurationWidget(QWidget *parent, const QBy
KisImportExportFilter::ConversionStatus EXRExport::convert(KisDocument *document, QIODevice */*io*/, KisPropertiesConfigurationSP configuration) KisImportExportFilter::ConversionStatus EXRExport::convert(KisDocument *document, QIODevice */*io*/, KisPropertiesConfigurationSP configuration)
{ {
KisImageSP image = document->image(); KisImageSP image = document->savingImage();
EXRConverter exrConverter(document, !batchMode()); EXRConverter exrConverter(document, !batchMode());
KisImageBuilder_Result res; KisImageBuilder_Result res;
if (configuration->getBool("flatten")) { if (configuration->getBool("flatten")) {
// the image must be locked at the higher levels
KIS_SAFE_ASSERT_RECOVER_NOOP(document->image()->locked());
KisPaintDeviceSP pd = new KisPaintDevice(*image->projection()); KisPaintDeviceSP pd = new KisPaintDevice(*image->projection());
KisPaintLayerSP l = new KisPaintLayer(image, "projection", OPACITY_OPAQUE_U8, pd); KisPaintLayerSP l = new KisPaintLayer(image, "projection", OPACITY_OPAQUE_U8, pd);
res = exrConverter.buildFile(filename(), l); res = exrConverter.buildFile(filename(), l);
} }
else { else {
// the image must be locked at the higher levels
KIS_SAFE_ASSERT_RECOVER_NOOP(document->image()->locked());
res = exrConverter.buildFile(filename(), image->rootLayer()); res = exrConverter.buildFile(filename(), image->rootLayer());
} }
......
...@@ -91,9 +91,9 @@ void KisHeightMapExport::initializeCapabilities() ...@@ -91,9 +91,9 @@ void KisHeightMapExport::initializeCapabilities()
KisImportExportFilter::ConversionStatus KisHeightMapExport::convert(KisDocument *document, QIODevice *io, KisPropertiesConfigurationSP configuration) KisImportExportFilter::ConversionStatus KisHeightMapExport::convert(KisDocument *document, QIODevice *io, KisPropertiesConfigurationSP configuration)
{ {
KisImageSP image = document->image(); KisImageSP image = document->savingImage();
if (document->image()->width() != document->image()->height()) { if (image->width() != image->height()) {
document->setErrorMessage(i18n("Cannot export this image to a heightmap: it is not square")); document->setErrorMessage(i18n("Cannot export this image to a heightmap: it is not square"));
return KisImportExportFilter::WrongFormat; return KisImportExportFilter::WrongFormat;
} }
...@@ -104,8 +104,6 @@ KisImportExportFilter::ConversionStatus KisHeightMapExport::convert(KisDocument ...@@ -104,8 +104,6 @@ KisImportExportFilter::ConversionStatus KisHeightMapExport::convert(KisDocument
bool downscale = false; bool downscale = false;
// the image must be locked at the higher levels
KIS_SAFE_ASSERT_RECOVER_NOOP(image->locked());
KisPaintDeviceSP pd = new KisPaintDevice(*image->projection()); KisPaintDeviceSP pd = new KisPaintDevice(*image->projection());
QDataStream s(io); QDataStream s(io);
......
...@@ -65,7 +65,7 @@ KisJPEGExport::~KisJPEGExport() ...@@ -65,7 +65,7 @@ KisJPEGExport::~KisJPEGExport()
KisImportExportFilter::ConversionStatus KisJPEGExport::convert(KisDocument *document, QIODevice *io, KisPropertiesConfigurationSP configuration) KisImportExportFilter::ConversionStatus KisJPEGExport::convert(KisDocument *document, QIODevice *io, KisPropertiesConfigurationSP configuration)
{ {
KisImageSP image = document->image(); KisImageSP image = document->savingImage();
Q_CHECK_PTR(image); Q_CHECK_PTR(image);
// An extra option to pass to the config widget to set the state correctly, this isn't saved // An extra option to pass to the config widget to set the state correctly, this isn't saved
...@@ -90,8 +90,6 @@ KisImportExportFilter::ConversionStatus KisJPEGExport::convert(KisDocument *docu ...@@ -90,8 +90,6 @@ KisImportExportFilter::ConversionStatus KisJPEGExport::convert(KisDocument *docu
m.setEnabledFilters(configuration->getString("filters").split(",")); m.setEnabledFilters(configuration->getString("filters").split(","));
options.filters = m.enabledFilters(); options.filters = m.enabledFilters();
// the image must be locked at the higher levels
KIS_SAFE_ASSERT_RECOVER_NOOP(document->image()->locked());
KisPaintDeviceSP pd = new KisPaintDevice(*image->projection()); KisPaintDeviceSP pd = new KisPaintDevice(*image->projection());
KisJPEGConverter kpc(document, batchMode()); KisJPEGConverter kpc(document, batchMode());
......
...@@ -42,7 +42,7 @@ static const char CURRENT_DTD_VERSION[] = "2.0"; ...@@ -42,7 +42,7 @@ static const char CURRENT_DTD_VERSION[] = "2.0";
KraConverter::KraConverter(KisDocument *doc) KraConverter::KraConverter(KisDocument *doc)
: m_doc(doc) : m_doc(doc)
, m_image(doc->image()) , m_image(doc->savingImage())
{ {
} }
...@@ -217,7 +217,7 @@ bool KraConverter::savePreview(KoStore *store) ...@@ -217,7 +217,7 @@ bool KraConverter::savePreview(KoStore *store)
QPixmap pix = m_doc->generatePreview(QSize(256, 256)); QPixmap pix = m_doc->generatePreview(QSize(256, 256));
QImage preview(pix.toImage().convertToFormat(QImage::Format_ARGB32, Qt::ColorOnly)); QImage preview(pix.toImage().convertToFormat(QImage::Format_ARGB32, Qt::ColorOnly));
if (preview.size() == QSize(0,0)) { if (preview.size() == QSize(0,0)) {
QSize newSize = m_doc->image()->bounds().size(); QSize newSize = m_doc->savingImage()->bounds().size();
newSize.scale(QSize(256, 256), Qt::KeepAspectRatio); newSize.scale(QSize(256, 256), Qt::KeepAspectRatio);
preview = QImage(newSize, QImage::Format_ARGB32); preview = QImage(newSize, QImage::Format_ARGB32);
preview.fill(QColor(0, 0, 0, 0)); preview.fill(QColor(0, 0, 0, 0));
......
...@@ -55,10 +55,9 @@ KraExport::~KraExport() ...@@ -55,10 +55,9 @@ KraExport::~KraExport()
KisImportExportFilter::ConversionStatus KraExport::convert(KisDocument *document, QIODevice *io, KisPropertiesConfigurationSP /*configuration*/) KisImportExportFilter::ConversionStatus KraExport::convert(KisDocument *document, QIODevice *io, KisPropertiesConfigurationSP /*configuration*/)
{ {
KisImageSP image = document->image(); KisImageSP image = document->savingImage();
Q_CHECK_PTR(image); Q_CHECK_PTR(image);
KisPaintDeviceSP pd = image->projection();
KraConverter kraConverter(document); KraConverter kraConverter(document);
KisImageBuilder_Result res = kraConverter.buildFile(io); KisImageBuilder_Result res = kraConverter.buildFile(io);
......
...@@ -73,7 +73,7 @@ bool hasShapeLayerChild(KisNodeSP node) ...@@ -73,7 +73,7 @@ bool hasShapeLayerChild(KisNodeSP node)