The import function was written early on in the rewrite as a multithreaded background task that was considered somewhat flawed. While it worked for the most part, there were possibilities of race conditions that could have potentially been fatal, particularly since media could theoretically be deleted while the import/probe tasks were running in the background. With the save/load functions coming in, it became even more complicated as projects may include metadata about the footage that can't be implemented easily when the footage is imported/probed in the background. Making importing a modal task fixes all of these issues, it's still done in a background thread to not hang the GUI thread, but the GUI thread can be briefly "paused" in a user friendly way so that all these functions can be safer.
47 lines
836 B
C++
47 lines
836 B
C++
#ifndef PROJECTFILEMANAGERBASE_H
|
|
#define PROJECTFILEMANAGERBASE_H
|
|
|
|
#include <QObject>
|
|
|
|
#include "project.h"
|
|
|
|
class ProjectFileManagerBase : public QObject
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
ProjectFileManagerBase();
|
|
|
|
public slots:
|
|
/**
|
|
* @brief Start the save process
|
|
*
|
|
* It's recommended to invoke this through Qt signals/slots/QueuedConnection after moving this object to a separate
|
|
* thread.
|
|
*/
|
|
void Start();
|
|
|
|
/**
|
|
* @brief Cancel the current save
|
|
*
|
|
* Always connect to this with a DirectConnection. Otherwise, it'll be queued AFTER the save function is already
|
|
* complete.
|
|
*/
|
|
void Cancel();
|
|
|
|
protected:
|
|
virtual void Action() = 0;
|
|
|
|
const QAtomicInt& IsCancelled() const;
|
|
|
|
signals:
|
|
void ProgressChanged(int);
|
|
|
|
void Finished();
|
|
|
|
private:
|
|
QAtomicInt cancelled_;
|
|
|
|
};
|
|
|
|
#endif // PROJECTFILEMANAGERBASE_H
|