fixed buggy link function

This commit is contained in:
itsmattkc
2018-11-13 20:48:41 +11:00
parent ff2ebc255b
commit 6a38cd05ae
3 changed files with 12 additions and 18 deletions
+6 -13
View File
@@ -1201,25 +1201,18 @@ void Timeline::set_marker() {
void Timeline::toggle_links() { void Timeline::toggle_links() {
LinkCommand* command = new LinkCommand(); LinkCommand* command = new LinkCommand();
command->s = sequence;
for (int i=0;i<sequence->clips.size();i++) { for (int i=0;i<sequence->clips.size();i++) {
Clip* c = sequence->clips.at(i); Clip* c = sequence->clips.at(i);
if (c != NULL && is_clip_selected(c, true)) { if (c != NULL && is_clip_selected(c, true)) {
command->clips.append(c); command->clips.append(i);
if (c->linked.size() > 0) { if (c->linked.size() > 0) {
command->link = false; // prioritize unlinking command->link = false; // prioritize unlinking
for (int j=0;j<c->linked.size();j++) { // add links to the command for (int j=0;j<c->linked.size();j++) { // add links to the command
bool found = false; if (!command->clips.contains(c->linked.at(j))) {
Clip* link = sequence->clips.at(c->linked.at(j)); command->clips.append(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);
}
} }
} }
} }
+3 -3
View File
@@ -1054,7 +1054,7 @@ LinkCommand::LinkCommand() : link(true), old_project_changed(mainWindow->isWindo
void LinkCommand::undo() { void LinkCommand::undo() {
for (int i=0;i<clips.size();i++) { for (int i=0;i<clips.size();i++) {
Clip* c = clips.at(i); Clip* c = s->clips.at(clips.at(i));
if (link) { if (link) {
c->linked.clear(); c->linked.clear();
} else { } else {
@@ -1067,11 +1067,11 @@ void LinkCommand::undo() {
void LinkCommand::redo() { void LinkCommand::redo() {
old_links.clear(); old_links.clear();
for (int i=0;i<clips.size();i++) { for (int i=0;i<clips.size();i++) {
Clip* c = clips.at(i); Clip* c = s->clips.at(clips.at(i));
if (link) { if (link) {
for (int j=0;j<clips.size();j++) { for (int j=0;j<clips.size();j++) {
if (i != j) { if (i != j) {
c->linked.append(j); c->linked.append(clips.at(j));
} }
} }
} else { } else {
+3 -2
View File
@@ -231,8 +231,9 @@ class LinkCommand : public QUndoCommand {
public: public:
LinkCommand(); LinkCommand();
void undo(); void undo();
void redo(); void redo();
QVector<Clip*> clips; Sequence* s;
QVector<int> clips;
bool link; bool link;
private: private:
QVector< QVector<int> > old_links; QVector< QVector<int> > old_links;