From ff9e9eb90bc83e5acb5b2d174c7221c94027cf85 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Thu, 8 Apr 2021 12:42:09 +1000 Subject: [PATCH] fixed qt assert when importing files --- app/task/project/import/import.cpp | 8 ++++---- app/widget/nodeview/nodeviewundo.cpp | 9 +++++---- app/widget/nodeview/nodeviewundo.h | 2 ++ 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/app/task/project/import/import.cpp b/app/task/project/import/import.cpp index 4e10f1eb6..d88f1317a 100644 --- a/app/task/project/import/import.cpp +++ b/app/task/project/import/import.cpp @@ -115,14 +115,14 @@ void ProjectImportTask::Import(Folder *folder, QFileInfoList import, int &counte footage->SetLabel(file_info.fileName()); if (footage->IsValid()) { - // Move footage to main thread - footage->moveToThread(folder->thread()); - // See if this footage is an image sequence ValidateImageSequence(footage, import, i); // Create undoable command that adds the items to the model - parent_command->add_child(new NodeAddCommand(folder->parent(), footage)); + NodeAddCommand* nac = new NodeAddCommand(folder->parent(), footage); + nac->PushToThread(folder->thread()); + parent_command->add_child(nac); + parent_command->add_child(new FolderAddChild(folder, footage)); } else { // Add to list so we can tell the user about it later diff --git a/app/widget/nodeview/nodeviewundo.cpp b/app/widget/nodeview/nodeviewundo.cpp index 731b5f989..456c1b1ce 100644 --- a/app/widget/nodeview/nodeviewundo.cpp +++ b/app/widget/nodeview/nodeviewundo.cpp @@ -89,14 +89,15 @@ NodeAddCommand::NodeAddCommand(NodeGraph *graph, Node *node) : graph_(graph), node_(node) { - if (memory_manager_.thread() != node->thread()) { - memory_manager_.moveToThread(node_->thread()); - } - // Ensures that when this command is destroyed, if redo() is never called again, the node will be destroyed too node_->setParent(&memory_manager_); } +void NodeAddCommand::PushToThread(QThread *thread) +{ + memory_manager_.moveToThread(thread); +} + void NodeAddCommand::redo() { node_->setParent(graph_); diff --git a/app/widget/nodeview/nodeviewundo.h b/app/widget/nodeview/nodeviewundo.h index 72b8e5e82..3954bd068 100644 --- a/app/widget/nodeview/nodeviewundo.h +++ b/app/widget/nodeview/nodeviewundo.h @@ -76,6 +76,8 @@ class NodeAddCommand : public UndoCommand { public: NodeAddCommand(NodeGraph* graph, Node* node); + void PushToThread(QThread* thread); + virtual Project* GetRelevantProject() const override; virtual void redo() override;