several conversions to smart pointers
This commit is contained in:
+4
-15
@@ -25,21 +25,10 @@
|
||||
#include "project/transition.h"
|
||||
|
||||
int clipboard_type = CLIPBOARD_TYPE_CLIP;
|
||||
QVector<void*> clipboard;
|
||||
QVector<Transition*> clipboard_transitions;
|
||||
QVector<VoidPtr> clipboard;
|
||||
QVector<TransitionPtr> clipboard_transitions;
|
||||
|
||||
void clear_clipboard() {
|
||||
int clipboard_size = clipboard.size();
|
||||
for (int i=0;i<clipboard_size;i++) {
|
||||
if (clipboard_type == CLIPBOARD_TYPE_CLIP) {
|
||||
delete static_cast<Clip*>(clipboard.at(i));
|
||||
} else if (clipboard_type == CLIPBOARD_TYPE_EFFECT) {
|
||||
delete static_cast<Effect*>(clipboard.at(i));
|
||||
}
|
||||
}
|
||||
clipboard_size = clipboard_transitions.size();
|
||||
for (int i=0;i<clipboard_size;i++) {
|
||||
delete clipboard_transitions.at(i);
|
||||
}
|
||||
clipboard.clear();
|
||||
clipboard.clear();
|
||||
clipboard_transitions.clear();
|
||||
}
|
||||
|
||||
+4
-2
@@ -28,9 +28,11 @@
|
||||
#define CLIPBOARD_TYPE_CLIP 0
|
||||
#define CLIPBOARD_TYPE_EFFECT 1
|
||||
|
||||
using VoidPtr = std::shared_ptr<void>;
|
||||
|
||||
extern int clipboard_type;
|
||||
extern QVector<Transition*> clipboard_transitions;
|
||||
extern QVector<void*> clipboard;
|
||||
extern QVector<TransitionPtr> clipboard_transitions;
|
||||
extern QVector<VoidPtr> clipboard;
|
||||
void clear_clipboard();
|
||||
|
||||
#endif // CLIPBOARD_H
|
||||
|
||||
+16
-16
@@ -41,12 +41,12 @@ LoadThread::LoadThread(bool a) : autorecovery(a), cancelled(false) {
|
||||
connect(this, SIGNAL(finished()), this, SLOT(deleteLater()));
|
||||
connect(this, SIGNAL(success()), this, SLOT(success_func()));
|
||||
connect(this, SIGNAL(error()), this, SLOT(error_func()));
|
||||
connect(this, SIGNAL(start_create_dual_transition(const TransitionData*,Clip*,Clip*,const EffectMeta*)), this, SLOT(create_dual_transition(const TransitionData*,Clip*,Clip*,const EffectMeta*)));
|
||||
connect(this, SIGNAL(start_create_effect_ui(QXmlStreamReader*, Clip*, int, const QString*, const EffectMeta*, long, bool)), this, SLOT(create_effect_ui(QXmlStreamReader*, Clip*, int, const QString*, const EffectMeta*, long, bool)));
|
||||
connect(this, SIGNAL(start_create_dual_transition(const TransitionData*,ClipPtr,ClipPtr,const EffectMeta*)), this, SLOT(create_dual_transition(const TransitionData*,ClipPtr,ClipPtr,const EffectMeta*)));
|
||||
connect(this, SIGNAL(start_create_effect_ui(QXmlStreamReader*, ClipPtr, int, const QString*, const EffectMeta*, long, bool)), this, SLOT(create_effect_ui(QXmlStreamReader*, ClipPtr, int, const QString*, const EffectMeta*, long, bool)));
|
||||
connect(this, SIGNAL(start_question(const QString&, const QString &, int)), this, SLOT(question_func(const QString &, const QString &, int)));
|
||||
}
|
||||
|
||||
void LoadThread::load_effect(QXmlStreamReader& stream, Clip* c) {
|
||||
void LoadThread::load_effect(QXmlStreamReader& stream, ClipPtr c) {
|
||||
int effect_id = -1;
|
||||
QString effect_name;
|
||||
bool effect_enabled = true;
|
||||
@@ -194,7 +194,7 @@ bool LoadThread::load_worker(QFile& f, QXmlStreamReader& stream, int type) {
|
||||
int folder = 0;
|
||||
|
||||
Media* item = new Media(0);
|
||||
Footage* f = new Footage();
|
||||
FootagePtr f(new Footage());
|
||||
|
||||
f->using_inout = false;
|
||||
|
||||
@@ -300,7 +300,7 @@ bool LoadThread::load_worker(QFile& f, QXmlStreamReader& stream, int type) {
|
||||
case MEDIA_TYPE_SEQUENCE:
|
||||
{
|
||||
Media* parent = nullptr;
|
||||
Sequence* s = new Sequence();
|
||||
SequencePtr s(new Sequence());
|
||||
|
||||
// load attributes about sequence
|
||||
for (int j=0;j<stream.attributes().size();j++) {
|
||||
@@ -367,7 +367,7 @@ bool LoadThread::load_worker(QFile& f, QXmlStreamReader& stream, int type) {
|
||||
} else if (stream.name() == "clip" && stream.isStartElement()) {
|
||||
int media_type = -1;
|
||||
int media_id, stream_id;
|
||||
Clip* c = new Clip(s);
|
||||
ClipPtr c(new Clip(s));
|
||||
|
||||
// backwards compatibility code
|
||||
c->autoscale = false;
|
||||
@@ -428,7 +428,7 @@ bool LoadThread::load_worker(QFile& f, QXmlStreamReader& stream, int type) {
|
||||
case MEDIA_TYPE_FOOTAGE:
|
||||
if (media_id >= 0) {
|
||||
for (int j=0;j<loaded_media_items.size();j++) {
|
||||
Footage* m = loaded_media_items.at(j)->to_footage();
|
||||
FootagePtr m = loaded_media_items.at(j)->to_footage();
|
||||
if (m->save_id == media_id) {
|
||||
c->media = loaded_media_items.at(j);
|
||||
c->media_stream = stream_id;
|
||||
@@ -487,7 +487,7 @@ bool LoadThread::load_worker(QFile& f, QXmlStreamReader& stream, int type) {
|
||||
// correct links, clip IDs, transitions
|
||||
for (int i=0;i<s->clips.size();i++) {
|
||||
// correct links
|
||||
Clip* correct_clip = s->clips.at(i);
|
||||
ClipPtr correct_clip = s->clips.at(i);
|
||||
for (int j=0;j<correct_clip->linked.size();j++) {
|
||||
bool found = false;
|
||||
for (int k=0;k<s->clips.size();k++) {
|
||||
@@ -508,7 +508,7 @@ bool LoadThread::load_worker(QFile& f, QXmlStreamReader& stream, int type) {
|
||||
);
|
||||
waitCond.wait(&mutex);
|
||||
if (question_btn == QMessageBox::No) {
|
||||
delete s;
|
||||
s.reset();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -534,8 +534,8 @@ bool LoadThread::load_worker(QFile& f, QXmlStreamReader& stream, int type) {
|
||||
// create transitions
|
||||
for (int i=0;i<transition_data.size();i++) {
|
||||
const TransitionData& td = transition_data.at(i);
|
||||
Clip* primary = td.otc;
|
||||
Clip* secondary = td.ctc;
|
||||
ClipPtr primary = td.otc;
|
||||
ClipPtr secondary = td.ctc;
|
||||
if (primary != nullptr || secondary != nullptr) {
|
||||
if (primary == nullptr) {
|
||||
primary = secondary;
|
||||
@@ -760,7 +760,7 @@ void LoadThread::success_func() {
|
||||
|
||||
void LoadThread::create_effect_ui(
|
||||
QXmlStreamReader* stream,
|
||||
Clip* c,
|
||||
ClipPtr c,
|
||||
int type,
|
||||
const QString* effect_name,
|
||||
const EffectMeta* meta,
|
||||
@@ -795,12 +795,12 @@ void LoadThread::create_effect_ui(
|
||||
if (type == TA_NO_TRANSITION) {
|
||||
if (meta == nullptr) {
|
||||
// create void effect
|
||||
VoidEffect* ve = new VoidEffect(c, *effect_name);
|
||||
EffectPtr ve(new VoidEffect(c, *effect_name));
|
||||
ve->set_enabled(effect_enabled);
|
||||
ve->load(*stream);
|
||||
c->effects.append(ve);
|
||||
} else {
|
||||
Effect* e = create_effect(c, meta);
|
||||
EffectPtr e(create_effect(c, meta));
|
||||
e->set_enabled(effect_enabled);
|
||||
e->load(*stream);
|
||||
|
||||
@@ -808,7 +808,7 @@ void LoadThread::create_effect_ui(
|
||||
}
|
||||
} else {
|
||||
int transition_index = create_transition(c, nullptr, meta);
|
||||
Transition* t = c->sequence->transitions.at(transition_index);
|
||||
TransitionPtr t = c->sequence->transitions.at(transition_index);
|
||||
if (effect_length > -1) t->set_length(effect_length);
|
||||
t->set_enabled(effect_enabled);
|
||||
t->load(*stream);
|
||||
@@ -825,7 +825,7 @@ void LoadThread::create_effect_ui(
|
||||
waitCond.wakeAll();
|
||||
}
|
||||
|
||||
void LoadThread::create_dual_transition(const TransitionData* td, Clip* primary, Clip* secondary, const EffectMeta* meta) {
|
||||
void LoadThread::create_dual_transition(const TransitionData* td, ClipPtr primary, ClipPtr secondary, const EffectMeta* meta) {
|
||||
// lock mutex - ensures the load thread is suspended while this happens
|
||||
mutex.lock();
|
||||
|
||||
|
||||
+9
-9
@@ -34,8 +34,8 @@ struct TransitionData {
|
||||
int id;
|
||||
QString name;
|
||||
long length;
|
||||
Clip* otc;
|
||||
Clip* ctc;
|
||||
ClipPtr otc;
|
||||
ClipPtr ctc;
|
||||
};
|
||||
|
||||
class LoadThread : public QThread
|
||||
@@ -49,26 +49,26 @@ signals:
|
||||
void start_question(const QString &title, const QString &text, int buttons);
|
||||
void success();
|
||||
void error();
|
||||
void start_create_effect_ui(QXmlStreamReader* stream, Clip* c, int type, const QString *effect_name, const EffectMeta* meta, long effect_length, bool effect_enabled);
|
||||
void start_create_dual_transition(const TransitionData* td, Clip* primary, Clip* secondary, const EffectMeta* meta);
|
||||
void start_create_effect_ui(QXmlStreamReader* stream, ClipPtr c, int type, const QString *effect_name, const EffectMeta* meta, long effect_length, bool effect_enabled);
|
||||
void start_create_dual_transition(const TransitionData* td, ClipPtr primary, ClipPtr secondary, const EffectMeta* meta);
|
||||
void report_progress(int p);
|
||||
private slots:
|
||||
void question_func(const QString &title, const QString &text, int buttons);
|
||||
void error_func();
|
||||
void success_func();
|
||||
void create_effect_ui(QXmlStreamReader* stream, Clip* c, int type, const QString *effect_name, const EffectMeta* meta, long effect_length, bool effect_enabled);
|
||||
void create_dual_transition(const TransitionData* td, Clip* primary, Clip* secondary, const EffectMeta* meta);
|
||||
void create_effect_ui(QXmlStreamReader* stream, ClipPtr c, int type, const QString *effect_name, const EffectMeta* meta, long effect_length, bool effect_enabled);
|
||||
void create_dual_transition(const TransitionData* td, ClipPtr primary, ClipPtr secondary, const EffectMeta* meta);
|
||||
private:
|
||||
bool autorecovery;
|
||||
|
||||
bool load_worker(QFile& f, QXmlStreamReader& stream, int type);
|
||||
void load_effect(QXmlStreamReader& stream, Clip* c);
|
||||
void load_effect(QXmlStreamReader& stream, ClipPtr c);
|
||||
|
||||
void read_next(QXmlStreamReader& stream);
|
||||
void read_next_start_element(QXmlStreamReader& stream);
|
||||
void update_current_element_count(QXmlStreamReader& stream);
|
||||
|
||||
Sequence* open_seq;
|
||||
SequencePtr open_seq;
|
||||
QVector<Media*> loaded_media_items;
|
||||
QDir proj_dir;
|
||||
QDir internal_proj_dir;
|
||||
@@ -79,7 +79,7 @@ private:
|
||||
bool is_element(QXmlStreamReader& stream);
|
||||
|
||||
QVector<Media*> loaded_folders;
|
||||
QVector<Clip*> loaded_clips;
|
||||
QVector<ClipPtr> loaded_clips;
|
||||
QVector<Media*> loaded_sequences;
|
||||
Media* find_loaded_folder_by_id(int id);
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
|
||||
QSemaphore sem(5); // only 5 preview generators can run at one time
|
||||
|
||||
PreviewGenerator::PreviewGenerator(Media* i, Footage* m, bool r) :
|
||||
PreviewGenerator::PreviewGenerator(Media* i, FootagePtr m, bool r) :
|
||||
QThread(nullptr),
|
||||
fmt_ctx(nullptr),
|
||||
media(i),
|
||||
@@ -48,8 +48,7 @@ PreviewGenerator::PreviewGenerator(Media* i, Footage* m, bool r) :
|
||||
replace(r),
|
||||
cancelled(false)
|
||||
{
|
||||
data_path = get_data_path() + "/previews";
|
||||
QDir data_dir(data_path);
|
||||
data_dir = QDir(get_data_dir().filePath("previews"));
|
||||
if (!data_dir.exists()) {
|
||||
data_dir.mkpath(".");
|
||||
}
|
||||
@@ -506,11 +505,11 @@ void PreviewGenerator::generate_waveform() {
|
||||
}
|
||||
|
||||
QString PreviewGenerator::get_thumbnail_path(const QString& hash, const FootageStream& ms) {
|
||||
return data_path + "/" + hash + "t" + QString::number(ms.file_index);
|
||||
return data_dir.filePath(QString("%1t%2").arg(hash, QString::number(ms.file_index)));
|
||||
}
|
||||
|
||||
QString PreviewGenerator::get_waveform_path(const QString& hash, const FootageStream& ms) {
|
||||
return data_path + "/" + hash + "w" + QString::number(ms.file_index);
|
||||
return data_dir.filePath(QString("%1w%2").arg(hash, QString::number(ms.file_index)));
|
||||
}
|
||||
|
||||
void PreviewGenerator::run() {
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
#include <QThread>
|
||||
#include <QSemaphore>
|
||||
#include <QDir>
|
||||
|
||||
enum IconType {
|
||||
ICON_TYPE_VIDEO,
|
||||
@@ -45,7 +46,7 @@ class PreviewGenerator : public QThread
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
PreviewGenerator(Media*, Footage*, bool);
|
||||
PreviewGenerator(Media*, FootagePtr, bool);
|
||||
void run();
|
||||
void cancel();
|
||||
signals:
|
||||
@@ -57,12 +58,12 @@ private:
|
||||
void finalize_media();
|
||||
AVFormatContext* fmt_ctx;
|
||||
Media* media;
|
||||
Footage* footage;
|
||||
FootagePtr footage;
|
||||
bool retrieve_duration;
|
||||
bool contains_still_image;
|
||||
bool replace;
|
||||
bool cancelled;
|
||||
QString data_path;
|
||||
bool cancelled;
|
||||
QDir data_dir;
|
||||
QString get_thumbnail_path(const QString &hash, const FootageStream &ms);
|
||||
QString get_waveform_path(const QString& hash, const FootageStream &ms);
|
||||
};
|
||||
|
||||
@@ -399,7 +399,7 @@ void ProxyGenerator::cancel() {
|
||||
wait();
|
||||
}
|
||||
|
||||
double ProxyGenerator::get_proxy_progress(Footage *f) {
|
||||
double ProxyGenerator::get_proxy_progress(FootagePtr f) {
|
||||
if (proxy_queue.first().footage == f) {
|
||||
return current_progress;
|
||||
}
|
||||
|
||||
+2
-2
@@ -29,7 +29,7 @@
|
||||
#include "project/footage.h"
|
||||
|
||||
struct ProxyInfo {
|
||||
Footage* footage;
|
||||
FootagePtr footage;
|
||||
double size_multiplier;
|
||||
int codec_type;
|
||||
QString path;
|
||||
@@ -42,7 +42,7 @@ public:
|
||||
void run();
|
||||
void queue(const ProxyInfo& info);
|
||||
void cancel();
|
||||
double get_proxy_progress(Footage* f);
|
||||
double get_proxy_progress(FootagePtr f);
|
||||
private:
|
||||
// queue of footage to process proxies for
|
||||
QVector<ProxyInfo> proxy_queue;
|
||||
|
||||
Reference in New Issue
Block a user