Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.
C++
Prevent writers from quiting while a job is pending
Luna Lovecraft0ece3d797416
diff --git a/plugins/dockers/recorder/recorder_writer.cpp b/plugins/dockers/recorder/recorder_writer.cppindex ac2b70ad7e..9246daf08a 100644--- a/plugins/dockers/recorder/recorder_writer.cpp+++ b/plugins/dockers/recorder/recorder_writer.cpp@@ -135,6 +135,7 @@ public:QImage frame;int frameResolution = -1;int partIndex = 0; // Consecutive file number+ bool isActive = false;const RecorderWriterSettings* settings;const QDir* outputDir;@@ -302,6 +303,8 @@ void RecorderWriter::onCaptureImage(int writerId, int index, KisPaintDeviceSP deif (static_cast<int>(id) != writerId)return;+ d->isActive = true;+d->captureImage(device);// downscale image buffer@@ -312,9 +315,14 @@ void RecorderWriter::onCaptureImage(int writerId, int index, KisPaintDeviceSP debool isFrameWritten = d->writeFrame(index);+ d->isActive = false;Q_EMIT capturingDone(id, isFrameWritten);}+bool RecorderWriter::isActive()+{+ return d->isActive;+}struct WriterPoolEl{@@ -394,8 +402,23 @@ public:bool result = true;bool alreadyWarn = false;bool alreadyErr = false;- for(auto& el: writerPool)- {++ for (auto &el : writerPool) {+ if (el.inUse && !el.writer->isActive()) {+ // There's a pending job, but the writer didn't recieve the signal yet++ // Wait until all the jobs processes+ canvas->image()->waitForDone();++ // Make sure the signals are delivered+ QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);++ //we can exit the loop, all the signals have been delivered and we don't need to check further+ break;+ }+ }++ for (auto &el : writerPool) {el.thread->quit();el.thread->wait(RecorderConst::waitThreadTimeoutMs);disconnect(q, SIGNAL(startCapturing(int, int, KisPaintDeviceSP)), el.writer.get(), SLOT(onCaptureImage(int, int, KisPaintDeviceSP)));@@ -563,6 +586,7 @@ void RecorderWriterManager::start(bool toggleEnabled)bool RecorderWriterManager::stop(bool toggleEnabled){+ //Check if the timer is active, so that we don't try to clear the writer pool multiple timesif (!d->timer.isActive())return true;diff --git a/plugins/dockers/recorder/recorder_writer.h b/plugins/dockers/recorder/recorder_writer.hindex 13091ac461..57fb891706 100644--- a/plugins/dockers/recorder/recorder_writer.h+++ b/plugins/dockers/recorder/recorder_writer.h@@ -83,6 +83,8 @@ public:RecorderWriter& operator=(const RecorderWriter&) = delete;RecorderWriter& operator=(RecorderWriter&&) = delete;+ bool isActive();+Q_SIGNALS:void capturingDone(int writerId, bool success);