Commit a2f0275b authored by Dmitry Kazakov's avatar Dmitry Kazakov

Implement progress reporting for asynchronous saving

This patch refactors KoProgresssUpdater a bit:

1) Multiple subtasks are handled correctly now
2) Subtasks names can be nested
3) KisViewManager creates not KoProgressUpdater, but KoUpdater class,
   which is a part of the global progress queue. Therefore, there
   in no concurrent access to the progress bar now.
parent 20e980c4
......@@ -44,7 +44,7 @@ void KisProjectionBenchmark::benchmarkProjection()
KisDocument *doc = KisPart::instance()->createDocument();
doc->loadNativeFormat(QString(FILES_DATA_DIR) + QDir::separator() + "load_test.kra");
doc->image()->refreshGraph();
doc->exportDocument(QUrl::fromLocalFile(QString(FILES_OUTPUT_DIR) + QDir::separator() + "save_test.kra"), doc->mimeType());
doc->exportDocumentSync(QUrl::fromLocalFile(QString(FILES_OUTPUT_DIR) + QDir::separator() + "save_test.kra"), doc->mimeType());
delete doc;
}
}
......
......@@ -64,3 +64,10 @@ void KisCompositeProgressProxy::setFormat(const QString &format)
}
}
void KisCompositeProgressProxy::setAutoNestedName(const QString &name)
{
Q_FOREACH (KoProgressProxy *proxy, m_uniqueProxies) {
proxy->setAutoNestedName(name);
}
}
......@@ -30,10 +30,11 @@ public:
void addProxy(KoProgressProxy *proxy);
void removeProxy(KoProgressProxy *proxy);
int maximum() const;
void setValue(int value);
void setRange(int minimum, int maximum);
void setFormat(const QString &format);
int maximum() const override;
void setValue(int value) override;
void setRange(int minimum, int maximum) override;
void setFormat(const QString &format) override;
void setAutoNestedName(const QString &name) override;
private:
QList<KoProgressProxy*> m_proxies;
......
......@@ -42,10 +42,10 @@ class KRITAIMAGE_EXPORT KisNodeProgressProxy : public QObject, public KoProgress
~KisNodeProgressProxy();
public:
virtual int maximum() const ;
virtual void setValue(int value);
virtual void setRange(int minimum, int maximum);
virtual void setFormat(const QString & format);
int maximum() const override;
void setValue(int value) override;
void setRange(int minimum, int maximum) override;
void setFormat(const QString & format) override;
/**
* @return the current percentage (return -1 if no progress)
*/
......
......@@ -123,7 +123,13 @@ void KisQueuesProgressUpdater::timerTicked()
{
QMutexLocker locker(&m_d->mutex);
m_d->progressProxy->setRange(0, m_d->initialQueueSizeMetric);
m_d->progressProxy->setValue(m_d->initialQueueSizeMetric - m_d->queueSizeMetric);
m_d->progressProxy->setFormat(m_d->jobName);
if (!m_d->initialQueueSizeMetric) {
m_d->progressProxy->setRange(0, 100);
m_d->progressProxy->setValue(100);
m_d->progressProxy->setFormat("%p%");
} else {
m_d->progressProxy->setRange(0, m_d->initialQueueSizeMetric);
m_d->progressProxy->setValue(m_d->initialQueueSizeMetric - m_d->queueSizeMetric);
m_d->progressProxy->setFormat(m_d->jobName);
}
}
......@@ -460,7 +460,7 @@ bool Node::save(const QString &filename, double xRes, double yRes)
dst->addNode(paintLayer, dst->rootLayer(), KisLayerSP(0));
dst->initialRefreshGraph();
bool r = doc->exportDocument(QUrl::fromLocalFile(filename), mimeType.toLatin1());
bool r = doc->exportDocumentSync(QUrl::fromLocalFile(filename), mimeType.toLatin1());
if (!r) {
qWarning() << doc->errorMessage();
}
......
......@@ -467,7 +467,7 @@ bool KisApplication::start(const KisApplicationArguments &args)
qApp->processEvents(); // For vector layers to be updated
doc->setFileBatchMode(true);
if (!doc->exportDocument(QUrl::fromLocalFile(exportFileName), outputMimetype.toLatin1())) {
if (!doc->exportDocumentSync(QUrl::fromLocalFile(exportFileName), outputMimetype.toLatin1())) {
dbgKrita << "Could not export " << fileName << "to" << exportFileName << ":" << doc->errorMessage();
}
nPrinted++;
......
This diff is collapsed.
......@@ -52,8 +52,6 @@ class KoShapeLayer;
class KoStore;
class KoOdfReadStore;
class KoDocumentInfo;
class KoProgressUpdater;
class KoProgressProxy;
class KoDocumentInfoDlg;
class KisImportExportManager;
class KisUndoStore;
......@@ -113,6 +111,13 @@ public:
*/
bool reload();
/**
* @brief try to clone the image. This method handles all the locking for you. If locking
* has failed, no cloning happens
* @return cloned document on success, null otherwise
*/
KisDocument *safeCreateClone();
/**
* @brief openUrl Open an URL
* @param url The URL to open
......@@ -141,6 +146,8 @@ public:
*/
bool exportDocument(const QUrl &url, const QByteArray &mimeType, bool showWarnings = false, KisPropertiesConfigurationSP exportConfiguration = 0);
bool exportDocumentSync(const QUrl &url, const QByteArray &mimeType, KisPropertiesConfigurationSP exportConfiguration = 0);
bool exportDocumentImpl(const KritaUtils::ExportFileJob &job, KisPropertiesConfigurationSP exportConfiguration);
/**
......@@ -277,23 +284,6 @@ public:
*/
KoDocumentInfo *documentInfo() const;
/**
* @return the object to report progress to.
*
* This is only not zero if loading or saving is in progress.
*
* One can add more KoUpdaters to it to make the progress reporting more
* accurate. If no active progress reporter is present, 0 is returned.
**/
KoProgressUpdater *progressUpdater() const;
/**
* Set a custom progress proxy to use to report loading
* progress to.
*/
void setProgressProxy(KoProgressProxy *progressProxy);
KoProgressProxy* progressProxy() const;
/**
* Performs a cleanup of unneeded backup files
*/
......@@ -458,12 +448,12 @@ private:
friend class KisPart;
friend class SafeSavingLocker;
bool initiateSavingInBackground(const QString statusMessage,
bool initiateSavingInBackground(const QString actionName,
const QObject *receiverObject, const char *receiverMethod,
const KritaUtils::ExportFileJob &job,
KisPropertiesConfigurationSP exportConfiguration);
bool startExportInBackground(const QString &location,
bool startExportInBackground(const QString &actionName, const QString &location,
const QString &realLocation,
const QByteArray &mimeType,
bool showWarnings,
......@@ -533,26 +523,6 @@ public:
*/
KisImageSP savingImage() const;
/**
* Adds progressproxy for file operations
*/
void setFileProgressProxy();
/**
* Clears progressproxy for file operations
*/
void clearFileProgressProxy();
/**
* Adds progressupdater for file operations
*/
void setFileProgressUpdater(const QString &text);
/**
* Clears progressupdater for file operations
*/
void clearFileProgressUpdater();
/**
* Set the current image to the specified image and turn undo on.
*/
......@@ -606,8 +576,6 @@ private Q_SLOTS:
private:
KisDocument *safeCreateClone();
QString exportErrorToUserMessage(KisImportExportFilter::ConversionStatus status, const QString &errorMessage);
QString prettyPathOrUrl() const;
......
......@@ -71,7 +71,7 @@ class Q_DECL_HIDDEN KisImportExportManager::Private
{
public:
bool batchMode {false};
QPointer<KoProgressUpdater> progressUpdater {0};
KoUpdaterPtr updater;
};
struct KisImportExportManager::ConversionResult {
......@@ -242,9 +242,9 @@ bool KisImportExportManager::batchMode(void) const
return d->batchMode;
}
void KisImportExportManager::setProgresUpdater(KoProgressUpdater *updater)
void KisImportExportManager::setUpdater(KoUpdaterPtr updater)
{
d->progressUpdater = updater;
d->updater = updater;
}
QString KisImportExportManager::askForAudioFileName(const QString &defaultDir, QWidget *parent)
......@@ -289,8 +289,11 @@ KisImportExportManager::ConversionResult KisImportExportManager::convert(KisImpo
filter->setBatchMode(batchMode());
filter->setMimeType(typeName);
if (d->progressUpdater) {
filter->setUpdater(d->progressUpdater->startSubtask());
if (!d->updater.isNull()) {
// WARNING: The updater is not guaranteed to be persistent! If you ever want
// to add progress reporting to "Save also as .kra", make sure you create
// a separate KoProgressUpdater for that!
filter->setUpdater(d->updater);
}
QByteArray from, to;
......
......@@ -122,7 +122,7 @@ public:
*/
bool batchMode(void) const;
void setProgresUpdater(KoProgressUpdater *updater);
void setUpdater(KoUpdaterPtr updater);
static QString askForAudioFileName(const QString &defaultDir, QWidget *parent);
......
......@@ -94,6 +94,7 @@
#include <KoDockRegistry.h>
#include <KoPluginLoader.h>
#include <KoColorSpaceEngine.h>
#include <KoUpdater.h>
#include <KisMimeDatabase.h>
#include <brushengine/kis_paintop_settings.h>
......@@ -1659,12 +1660,10 @@ void KisMainWindow::importAnimation()
int firstFrame = dlg.firstFrame();
int step = dlg.step();
document->setFileProgressProxy();
document->setFileProgressUpdater(i18n("Import frames"));
KisAnimationImporter importer(document);
KoUpdaterPtr updater =
!document->fileBatchMode() ? viewManager()->createUpdater(i18n("Import frames"), false) : 0;
KisAnimationImporter importer(document->image(), updater);
KisImportExportFilter::ConversionStatus status = importer.import(files, firstFrame, step);
document->clearFileProgressUpdater();
document->clearFileProgressProxy();
if (status != KisImportExportFilter::OK && status != KisImportExportFilter::InternalError) {
QString msg = KisImportExportFilter::conversionStatusString(status);
......
......@@ -373,24 +373,12 @@ KisAnimationCachePopulator* KisPart::cachePopulator() const
void KisPart::openExistingFile(const QUrl &url)
{
Q_ASSERT(url.isLocalFile());
qApp->setOverrideCursor(Qt::BusyCursor);
KisDocument *document = createDocument();
if (!document->openUrl(url)) {
delete document;
return;
}
if (!document->image()) {
delete document;
return;
}
document->setModified(false);
addDocument(document);
// TODO: refactor out this method!
KisMainWindow *mw = currentMainwindow();
mw->addViewAndNotifyLoadingCompleted(document);
KIS_SAFE_ASSERT_RECOVER_RETURN(mw);
qApp->restoreOverrideCursor();
mw->openDocument(url, KisMainWindow::None);
}
void KisPart::updateShortcuts()
......
......@@ -121,7 +121,7 @@ bool KisSaveGroupVisitor::visit(KisGroupLayer *layer)
QUrl url = QUrl::fromLocalFile(path);
exportDocument->setFileBatchMode(true);
exportDocument->exportDocument(url, m_mimeFilter.toLatin1());
exportDocument->exportDocumentSync(url, m_mimeFilter.toLatin1());
if (!m_saveTopLevelOnly) {
KisGroupLayerSP child = dynamic_cast<KisGroupLayer*>(layer->firstChild().data());
......
......@@ -207,7 +207,7 @@ void KisTemplateCreateDia::createTemplate(const QString &templatesResourcePath,
}
fileName = tempFile.fileName();
}
bool retval = document->exportDocument(QUrl::fromLocalFile(fileName), document->mimeType());
bool retval = document->exportDocumentSync(QUrl::fromLocalFile(fileName), document->mimeType());
if (!retval) {
qWarning("Could not save template");
return;
......
......@@ -81,10 +81,8 @@
#include "KisUndoStackAction.h"
#include "KisViewManager.h"
#include "kis_zoom_manager.h"
#include "kis_composite_progress_proxy.h"
#include "kis_statusbar.h"
#include "kis_painting_assistants_decoration.h"
#include "kis_progress_widget.h"
#include "kis_signal_compressor.h"
#include "kis_filter_manager.h"
#include "kis_file_layer.h"
......@@ -261,10 +259,6 @@ KisView::KisView(KisDocument *document, KoCanvasResourceManager *resourceManager
KisView::~KisView()
{
if (d->viewManager) {
KoProgressProxy *proxy = d->viewManager->statusBar()->progress()->progressProxy();
KIS_ASSERT_RECOVER_NOOP(proxy);
image()->compositeProgressProxy()->removeProxy(proxy);
if (d->viewManager->filterManager()->isStrokeRunning()) {
d->viewManager->filterManager()->cancel();
}
......@@ -358,15 +352,6 @@ void KisView::setViewManager(KisViewManager *view)
SLOT(slotContinueRemoveNode(KisNodeSP)),
Qt::AutoConnection);
/*
* WARNING: Currently we access the global progress bar in two ways:
* connecting to composite progress proxy (strokes) and creating
* progress updaters. The latter way should be deprecated in favour
* of displaying the status of the global strokes queue
*/
image()->compositeProgressProxy()->addProxy(d->viewManager->statusBar()->progress()->progressProxy());
connect(d->viewManager->statusBar()->progress(), SIGNAL(sigCancellationRequested()), image(), SLOT(requestStrokeCancellation()));
d->viewManager->updateGUI();
KoToolManager::instance()->switchToolRequested("KritaShape/KisToolBrush");
......@@ -681,7 +666,7 @@ void KisView::closeEvent(QCloseEvent *event)
}
if (queryClose()) {
d->viewManager->removeStatusBarItem(zoomManager()->zoomActionWidget());
d->viewManager->statusBar()->setView(0);
event->accept();
return;
}
......
......@@ -83,6 +83,7 @@
#include "kis_canvas_controls_manager.h"
#include "kis_canvas_resource_provider.h"
#include "kis_composite_progress_proxy.h"
#include <KoProgressUpdater.h>
#include "kis_config.h"
#include "kis_config_notifier.h"
#include "kis_control_frame.h"
......@@ -107,7 +108,7 @@
#include <brushengine/kis_paintop_preset.h>
#include "KisPart.h"
#include "KisPrintJob.h"
#include "kis_progress_widget.h"
#include <KoUpdater.h>
#include "kis_resource_server_provider.h"
#include "kis_selection.h"
#include "kis_selection_manager.h"
......@@ -128,6 +129,7 @@
#include "kis_guides_manager.h"
#include "kis_derived_resources.h"
#include "dialogs/kis_delayed_save_dialog.h"
#include <kis_image.h>
class BlockingUserInputEventFilter : public QObject
......@@ -221,6 +223,7 @@ public:
KisSelectionManager selectionManager;
KisGuidesManager guidesManager;
KisStatusBar statusBar;
QPointer<KoUpdater> persistentImageProgressUpdater;
KisControlFrame controlFrame;
KisNodeManager nodeManager;
......@@ -264,6 +267,13 @@ KisViewManager::KisViewManager(QWidget *parent, KActionCollection *_actionCollec
// These initialization functions must wait until KisViewManager ctor is complete.
d->statusBar.setup();
d->persistentImageProgressUpdater =
d->statusBar.progressUpdater()->startSubtask(1, "", true);
// reset state to nil
d->persistentImageProgressUpdater->setRange(0,100);
d->persistentImageProgressUpdater->setValue(100);
d->controlFrame.setup(parent);
//Check to draw scrollbars after "Canvas only mode" toggle is created.
......@@ -347,6 +357,7 @@ void KisViewManager::setCurrentView(KisView *view)
first = false;
KisDocument* doc = d->currentImageView->document();
if (doc) {
doc->image()->compositeProgressProxy()->removeProxy(d->persistentImageProgressUpdater);
doc->disconnect(this);
}
d->currentImageView->canvasController()->proxyObject->disconnect(&d->statusBar);
......@@ -413,6 +424,10 @@ void KisViewManager::setCurrentView(KisView *view)
d->viewConnections.addUniqueConnection(d->softProof, SIGNAL(toggled(bool)), view, SLOT(slotSoftProofing(bool)) );
d->viewConnections.addUniqueConnection(d->gamutCheck, SIGNAL(toggled(bool)), view, SLOT(slotGamutCheck(bool)) );
// set up progrress reporting
doc->image()->compositeProgressProxy()->addProxy(d->persistentImageProgressUpdater);
d->viewConnections.addUniqueConnection(&d->statusBar, SIGNAL(sigCancellationRequested()), doc->image(), SLOT(requestStrokeCancellation()));
imageView->zoomManager()->setShowRulers(d->showRulersAction->isChecked());
imageView->zoomManager()->setRulersTrackMouse(d->rulersTrackMouseAction->isChecked());
......@@ -521,9 +536,14 @@ KisPaintopBox* KisViewManager::paintOpBox() const
return d->controlFrame.paintopBox();
}
KoProgressUpdater* KisViewManager::createProgressUpdater(KoProgressUpdater::Mode mode)
QPointer<KoUpdater> KisViewManager::createUpdater(const QString &name, bool isPersistent)
{
return new KisProgressUpdater(d->statusBar.progress(), document()->progressProxy(), mode);
return d->statusBar.progressUpdater()->startSubtask(1, name, isPersistent);
}
void KisViewManager::removePersistentUpdater(QPointer<KoUpdater> updater)
{
return d->statusBar.progressUpdater()->removePersistentSubtask(updater);
}
KisSelectionManager * KisViewManager::selectionManager()
......@@ -787,19 +807,19 @@ void KisViewManager::slotCreateTemplate()
void KisViewManager::slotCreateCopy()
{
if (!document()) return;
KisDocument *doc = KisPart::instance()->createDocument();
KisDocument *srcDoc = document();
if (!srcDoc) return;
KisDocument *doc = srcDoc->safeCreateClone();
if (!doc) return;
QString name = document()->documentInfo()->aboutInfo("name");
QString name = srcDoc->documentInfo()->aboutInfo("name");
if (name.isEmpty()) {
name = document()->url().toLocalFile();
}
name = i18n("%1 (Copy)", name);
doc->documentInfo()->setAboutInfo("title", name);
KisImageWSP image = document()->image();
KisImageSP newImage = new KisImage(doc->createUndoStore(), image->width(), image->height(), image->colorSpace(), name);
newImage->setRootLayer(dynamic_cast<KisGroupLayer*>(image->rootLayer()->clone().data()));
doc->setCurrentImage(newImage);
KisPart::instance()->addDocument(doc);
KisMainWindow *mw = qobject_cast<KisMainWindow*>(d->mainWindow);
mw->addViewAndNotifyLoadingCompleted(doc);
......
......@@ -24,7 +24,6 @@
#include <QPointer>
#include <KisMainWindow.h>
#include <KoProgressUpdater.h>
#include <KoToolManager.h>
#include <kritaui_export.h>
......@@ -53,6 +52,8 @@ class KisPaintopBox;
class KisActionManager;
class KisScriptManager;
class KisInputManager;
class KoUpdater;
class KoProgressUpdater;
/**
* Krita view class
......@@ -118,7 +119,8 @@ public: // Krita specific interfaces
KisPaintopBox* paintOpBox() const;
/// create a new progress updater
KoProgressUpdater *createProgressUpdater(KoProgressUpdater::Mode mode = KoProgressUpdater::Threaded);
QPointer<KoUpdater> createUpdater(const QString &name, bool isPersistent);
void removePersistentUpdater(QPointer<KoUpdater> updater);
/// The selection manager handles everything action related to
/// selections.
......
......@@ -26,6 +26,7 @@
#include "KoFileDialog.h"
#include "KisDocument.h"
#include <KoUpdater.h>
#include "kis_image.h"
#include "KisImportExportManager.h"
#include "kis_image_animation_interface.h"
......@@ -65,20 +66,21 @@ KisAnimationExporterUI::~KisAnimationExporterUI()
struct KisAnimationExporter::Private
{
Private(KisDocument *document, int fromTime, int toTime)
: document(document)
, image(document->image())
Private(KisImageSP _image, int fromTime, int toTime, KoUpdaterPtr _updater)
: updater(_updater)
, image(_image)
, firstFrame(fromTime)
, lastFrame(toTime)
, currentFrame(-1)
, batchMode(document->fileBatchMode())
, batchMode(!updater)
, isCancelled(false)
, status(KisImportExportFilter::OK)
, tmpDevice(new KisPaintDevice(image->colorSpace()))
{
KIS_SAFE_ASSERT_RECOVER_NOOP(bool(updater) == !batchMode);
}
KisDocument *document;
KoUpdaterPtr updater;
KisImageWSP image;
int firstFrame;
......@@ -99,8 +101,8 @@ struct KisAnimationExporter::Private
};
KisAnimationExporter::KisAnimationExporter(KisDocument *document, int fromTime, int toTime)
: m_d(new Private(document, fromTime, toTime))
KisAnimationExporter::KisAnimationExporter(KisImageWSP image, int fromTime, int toTime, KoUpdaterPtr updater)
: m_d(new Private(image, fromTime, toTime, updater))
{
connect(m_d->image->animationInterface(), SIGNAL(sigFrameReady(int)),
this, SLOT(frameReadyToCopy(int)), Qt::DirectConnection);
......@@ -137,10 +139,10 @@ KisImportExportFilter::ConversionStatus KisAnimationExporter::exportAnimation()
m_d->progress.setValue(0);
m_d->progress.setMinimum(0);
m_d->progress.setMaximum(100);
}
emit m_d->document->statusBarMessage(message);
emit m_d->document->sigProgress(0);
connect(m_d->document, SIGNAL(sigProgressCanceled()), this, SLOT(cancel()));
if (m_d->updater) {
m_d->updater->setProgress(0);
}
/**
......@@ -165,12 +167,13 @@ KisImportExportFilter::ConversionStatus KisAnimationExporter::exportAnimation()
loop.exec();
if (!m_d->batchMode) {
disconnect(m_d->document, SIGNAL(sigProgressCanceled()), this, SLOT(cancel()));
emit m_d->document->sigProgress(100);
emit m_d->document->clearStatusBarMessage();
m_d->progress.reset();
}
if (m_d->updater) {
m_d->updater->setProgress(100);
}
return m_d->status;
}
......@@ -197,7 +200,8 @@ void KisAnimationExporter::frameReadyToSave()
return;
}
if (m_d->isCancelled) {
// TODO: refactor to a signal!
if (m_d->isCancelled || (m_d->updater && m_d->updater->interrupted())) {
m_d->status = KisImportExportFilter::UserCancelled;
emit sigFinished();
return;
......@@ -209,13 +213,12 @@ void KisAnimationExporter::frameReadyToSave()
result = m_d->saveFrameCallback(time, m_d->tmpDevice, m_d->exportConfiguration);
if (!m_d->batchMode) {
int length = m_d->lastFrame - m_d->firstFrame + 1;
emit m_d->document->sigProgress((time - m_d->firstFrame) * 100 / length);
if (m_d->updater) {
int length = m_d->lastFrame - m_d->firstFrame;
m_d->updater->setProgress((time - m_d->firstFrame) * 100 / length);
}
qDebug() << result << time << m_d->lastFrame;
// TODO: make translatable!!
QString dialogText = QString("Exporting Frame ").append(QString::number(time)).append(" of ").append(QString::number(m_d->lastFrame));
int percentageProcessed = (float(time) / float(m_d->lastFrame) * 100);
......@@ -232,18 +235,19 @@ void KisAnimationExporter::frameReadyToSave()
struct KisAnimationExportSaver::Private
{
Private(KisDocument *document, int fromTime, int toTime, int _sequenceNumberingOffset)
: document(document)
, image(document->image())
Private(KisDocument *_document, int fromTime, int toTime, int _sequenceNumberingOffset, KoUpdaterPtr _updater)
: document(_document)
, image(_document->image())
, firstFrame(fromTime)
, lastFrame(toTime)
, sequenceNumberingOffset(_sequenceNumberingOffset)
, updater(_updater)
, tmpDoc(KisPart::instance()->createDocument())
, exporter(document, fromTime, toTime)
, exporter(_document->image(), fromTime, toTime, _updater)
{
tmpDoc->setAutoSaveDelay(0);
tmpImage = new KisImage(tmpDoc->createUndoStore(),
KisImageSP tmpImage = new KisImage(tmpDoc->createUndoStore(),
image->bounds().width(),
image->bounds().height(),
image->colorSpace(),
......@@ -263,9 +267,9 @@ struct KisAnimationExportSaver::Private
int firstFrame;
int lastFrame;
int sequenceNumberingOffset;
KoUpdaterPtr updater;
QScopedPointer<KisDocument> tmpDoc;
KisImageSP tmpImage;
KisPaintDeviceSP tmpDevice;
QByteArray outputMimeType;
......@@ -275,8 +279,8 @@ struct KisAnimationExportSaver::Private
QString filenameSuffix;
};
KisAnimationExportSaver::KisAnimationExportSaver(KisDocument *document, const QString &baseFilename, int fromTime, int toTime, int sequenceNumberingOffset)
: m_d(new Private(document, fromTime, toTime, sequenceNumberingOffset))
KisAnimationExportSaver::KisAnimationExportSaver(KisDocument *document, const QString &baseFilename, int fromTime, int toTime, int sequenceNumberingOffset, KoUpdaterPtr updater)
: m_d(new Private(document, fromTime, toTime, sequenceNumberingOffset, updater))
{
int baseLength = baseFilename.lastIndexOf(".");
if (baseLength > -1) {
......@@ -291,9 +295,6 @@ KisAnimationExportSaver::KisAnimationExportSaver(KisDocument *document, const QS
using namespace std::placeholders; // For _1 placeholder
m_d->exporter.setSaveFrameCallback(std::bind(&KisAnimationExportSaver::saveFrameCallback, this, _1, _2, _3));
}
KisAnimationExportSaver::~KisAnimationExportSaver()
......@@ -308,7 +309,8 @@ KisImportExportFilter::ConversionStatus KisAnimationExportSaver::exportAnimation
QStringList filesList = dir.entryList({ info.fileName() });
if (!filesList.isEmpty()) {
if (m_d->document->fileBatchMode()) {
// we are in batch mode!
if (!m_d->updater) {
return KisImportExportFilter::CreationError;
}
......@@ -365,7 +367,8 @@ KisImportExportFilter::ConversionStatus KisAnimationExportSaver::saveFrameCallba
QRect rc = m_d->image->bounds();
KisPainter::copyAreaOptimized(rc.topLeft(), frame, m_d->tmpDevice, rc);
if (!m_d->tmpDoc->exportDocument(QUrl::fromLocalFile(filename), m_d->outputMimeType, exportConfiguration)) {
if (!m_d->tmpDoc->exportDocumentSync(QUrl::fromLocalFile(filename), m_d->outputMimeType, exportConfiguration)) {
status = KisImportExportFilter::InternalError;
}
......
......@@ -54,7 +54,7 @@ class KRITAUI_EXPORT KisAnimationExporter : public QObject
public:
typedef std::function<KisImportExportFilter::ConversionStatus (int , KisPaintDeviceSP, KisPropertiesConfigurationSP)> SaveFrameCallback;
public:
KisAnimationExporter(KisDocument *document, int fromTime, int toTime);
KisAnimationExporter(KisImageWSP image, int fromTime, int toTime, KoUpdaterPtr updater);
~KisAnimationExporter();
void setExportConfiguration(KisPropertiesConfigurationSP exportConfiguration);
......@@ -84,7 +84,7 @@ class KRITAUI_EXPORT KisAnimationExportSaver : public QObject
{
Q_OBJECT
public:
KisAnimationExportSaver(KisDocument *document, const QString &baseFilename, int fromTime, int toTime, int sequenceNumberingOffset = 0);
KisAnimationExportSaver(KisDocument *document, const QString &baseFilename, int fromTime, int toTime, int sequenceNumberingOffset = 0, KoUpdaterPtr updater = 0);
~KisAnimationExportSaver();
KisImportExportFilter::ConversionStatus exportAnimation(KisPropertiesConfigurationSP cfg = 0);
......
......@@ -21,6 +21,8 @@
#include <QStatusBar>
#include "KoColorSpace.h"
#include <KoUpdater.h>
#include <QApplication>
#include "KisPart.h"
#include "KisDocument.h"
#include "kis_image.h"
......@@ -35,14 +37,16 @@ struct KisAnimationImporter::Private
KisImageSP image;