fixed linking bug

This commit is contained in:
itsmattkc
2018-07-18 13:17:14 +01:00
parent de46eb861b
commit 5e70fd4534
7 changed files with 55 additions and 36 deletions
+10 -9
View File
@@ -115,7 +115,11 @@ QTreeWidgetItem* Project::import_file(QString file) {
char* filename = new char[ba.size()+1];
strcpy(filename, ba.data());
QTreeWidgetItem* item = NULL;
QTreeWidgetItem* item = new_item();
Media* m = new Media();
m->url = file;
m->name = file.mid(file.lastIndexOf('/')+1);
item->setText(0, m->name);
AVFormatContext* pFormatCtx = NULL;
int errCode = avformat_open_input(&pFormatCtx, filename, NULL, NULL);
@@ -132,10 +136,6 @@ QTreeWidgetItem* Project::import_file(QString file) {
} else {
av_dump_format(pFormatCtx, 0, filename, 0);
Media* m = new Media();
m->url = file;
m->name = file.mid(file.lastIndexOf('/')+1);
// detect video/audio streams in file
for (int i=0;i<(int)pFormatCtx->nb_streams;i++) {
// Find the decoder for the video stream
@@ -159,17 +159,14 @@ QTreeWidgetItem* Project::import_file(QString file) {
}
m->length = pFormatCtx->duration;
item = new_item();
if (m->video_tracks.size() == 0) {
item->setIcon(0, QIcon(":/icons/audiosource.png"));
} else {
item->setIcon(0, QIcon(":/icons/videosource.png"));
}
item->setText(0, m->name);
item->setText(1, QString::number(m->length));
set_media_of_tree(item, m);
project_changed = true;
m->ready = true;
// generate waveform/thumbnail in another thread
PreviewGenerator* pg = new PreviewGenerator();
@@ -180,6 +177,10 @@ QTreeWidgetItem* Project::import_file(QString file) {
}
}
set_media_of_tree(item, m);
project_changed = true;
delete [] filename;
return item;
}
+19 -3
View File
@@ -846,9 +846,25 @@ void Timeline::toggle_links() {
LinkCommand* command = new LinkCommand();
for (int i=0;i<sequence->clip_count();i++) {
Clip* c = sequence->get_clip(i);
command->clips.append(c);
if (c->linked.size() > 0) {
command->link = false; // prioritize unlinking
if (c != NULL && is_clip_selected(c, true)) {
command->clips.append(c);
if (c->linked.size() > 0) {
command->link = false; // prioritize unlinking
for (int j=0;j<c->linked.size();j++) { // add links to the command
bool found = false;
Clip* link = sequence->get_clip(c->linked.at(j));
for (int k=0;k<command->clips.size();k++) {
if (command->clips.at(k) == link) {
found = true;
break;
}
}
if (!found) {
command->clips.append(link);
}
}
}
}
}
if (command->clips.size() > 0) {