Skip to content

Commit

Permalink
Do not remove target directories
Browse files Browse the repository at this point in the history
When the `_DO_NOT_KEEP_TEMP` compile flag was set, the target directory
for videos would get erased after rendering. When not specified
correctly, this would remove existing directories recursively, like a
home directory.

Closes slowmoVideo#130, slowmoVideo#168
  • Loading branch information
Granjow committed Apr 18, 2020
1 parent 27a5d0d commit caef2b0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 35 deletions.
6 changes: 5 additions & 1 deletion docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Changelog

# v0.6 – 2020-04-12
## Upcoming

* Fixed: Do not delete directories anymore when rendering (#130)

## v0.6 – 2020-04-12

First release of slowmoVideo as AppImage.

Expand Down
38 changes: 5 additions & 33 deletions src/project/exportVideoRenderTarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,38 +8,18 @@ the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
*/

#include "exportVideoRenderTarget.h"

#include <QtCore/QDebug>
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
#include <QTemporaryDir>
#endif

#include "renderTask_sV.h"
#include <QtCore/QObject>

#include "exportVideoRenderTarget.h"
#include "renderTask_sV.h"
#include "../lib/video_enc.h"


exportVideoRenderTarget::exportVideoRenderTarget(RenderTask_sV *parentRenderTask) :
AbstractRenderTarget_sV(parentRenderTask)
{
#if _NO_INSIDE_TMPDIR_
//TODO: should use projectdir to create render dir
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
//QTemporaryDir tempDir("slowmovideo");
QTemporaryDir tempDir;; // use default
if (tempDir.isValid())
m_targetDir = QDir(tempDir.path());
else
#endif
m_targetDir = QDir::temp();
#else
m_targetDir = parentRenderTask->getRenderDirectory();
#endif

qDebug() << " target dir " << m_targetDir;

m_targetDir = parentRenderTask->getRenderDirectory();
m_filenamePattern = "rendered-%1.png";

use_qt = 1;
Expand All @@ -48,15 +28,7 @@ qDebug() << " target dir " << m_targetDir;

exportVideoRenderTarget::~exportVideoRenderTarget()
{
#ifdef _DO_NOT_KEEP_TEMP
// QT bug ?
qDebug() << "should remove dir : " << m_targetDir;
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
m_targetDir.removeRecursively();
#else
#warning removeRecursively not define in QT4
#endif
#endif
qDebug() << "Closing exporter. Not deleting temporary files under " << m_targetDir.absolutePath() << ".";
}

void exportVideoRenderTarget::setTargetFile(const QString &filename)
Expand Down Expand Up @@ -92,7 +64,7 @@ void exportVideoRenderTarget::slotConsumeFrame(const QImage &image, const int fr

void exportVideoRenderTarget::closeRenderTarget() noexcept(false)
{
VideoWriter* writer;;
VideoWriter* writer;

qDebug() << "exporting temporary frame to Video" << m_filename << " using codec " << m_vcodec << "starting at " << first;
if (m_vcodec.isEmpty())
Expand Down
1 change: 0 additions & 1 deletion src/project/project_sV.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ Project_sV::~Project_sV()
}

delete m_renderTask;
qDebug() << "delete pref";
delete m_preferences;
delete m_frameSource;
delete m_flowSource;
Expand Down

0 comments on commit caef2b0

Please sign in to comment.