Skip to content

Commit

Permalink
corrections for non shared ptrs in OTIO code
Browse files Browse the repository at this point in the history
  • Loading branch information
itsmattkc committed Dec 16, 2020
1 parent 6cb6407 commit 7849d6f
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 24 deletions.
12 changes: 11 additions & 1 deletion app/project/projectviewmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,11 @@ ProjectViewModel::AddItemCommand::AddItemCommand(ProjectViewModel* model, Item*
parent_(folder),
child_(child)
{
// Ensure all operations are done in folder's thread
if (memory_manager_.thread() != parent_->thread()) {
memory_manager_.moveToThread(parent_->thread());
}

child_->setParent(&memory_manager_);
}

Expand All @@ -581,6 +586,12 @@ ProjectViewModel::RemoveItemCommand::RemoveItemCommand(ProjectViewModel *model,
model_(model),
item_(item)
{
// Ensure all operations are done in folder's thread
parent_ = item_->item_parent();

if (memory_manager_.thread() != item_->thread()) {
memory_manager_.moveToThread(item_->thread());
}
}

Project *ProjectViewModel::RemoveItemCommand::GetRelevantProject() const
Expand All @@ -590,7 +601,6 @@ Project *ProjectViewModel::RemoveItemCommand::GetRelevantProject() const

void ProjectViewModel::RemoveItemCommand::redo_internal()
{
parent_ = item_->item_parent();
model_->RemoveChild(parent_, item_, &memory_manager_);
}

Expand Down
25 changes: 7 additions & 18 deletions app/task/project/loadotio/loadotio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ bool LoadOTIOTask::Run()
}

// Keep track of imported footage
QMap<QString, FootagePtr> imported_footage;
QMap<QString, Footage*> imported_footage;

foreach (auto timeline, timelines) {
SequencePtr sequence = std::make_shared<Sequence>();
Sequence* sequence = new Sequence();
sequence->set_name(QString::fromStdString(timeline->name()));
project_->root()->add_child(sequence);
sequence->setParent(project_->root());

ViewerOutput* seq_viewer = sequence->viewer_output();

Expand Down Expand Up @@ -160,22 +160,22 @@ bool LoadOTIOTask::Run()
// Link footage
QString footage_url = QString::fromStdString(static_cast<OTIO::ExternalReference*>(otio_clip->media_reference())->target_url());

FootagePtr probed_item;
Footage* probed_item;

if (imported_footage.contains(footage_url)) {
probed_item = imported_footage.value(footage_url);
} else {
probed_item = Decoder::Probe(project_, footage_url, &IsCancelled());
imported_footage.insert(footage_url, probed_item);
project_->root()->add_child(probed_item);
probed_item->setParent(project_->root());
}

if (probed_item && probed_item->type() == Item::kFootage) {
MediaInput* media = new MediaInput();
if (track->track_type() == Timeline::kTrackTypeVideo) {
media->SetStream(probed_item->get_first_stream_of_type(Stream::kVideo));
media->SetStream(probed_item->get_first_enabled_stream_of_type(Stream::kVideo));
} else {
media->SetStream(probed_item->get_first_stream_of_type(Stream::kAudio));
media->SetStream(probed_item->get_first_enabled_stream_of_type(Stream::kAudio));
}
sequence->AddNode(media);

Expand All @@ -188,19 +188,8 @@ bool LoadOTIOTask::Run()

}
}

sequence->moveToThread(qApp->thread());
}

// Ugly hack to move footage streams to main thread
/*foreach (ItemPtr item, imported_footage) {
if (item && item->type() == Item::kFootage) {
foreach (StreamPtr stream, std::static_pointer_cast<Footage>(item)->streams()) {
stream->moveToThread(qApp->thread());
}
}
}*/

project_->moveToThread(qApp->thread());

return true;
Expand Down
8 changes: 4 additions & 4 deletions app/task/project/saveotio/saveotio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ SaveOTIOTask::SaveOTIOTask(Project *project) :

bool SaveOTIOTask::Run()
{
QList<ItemPtr> sequences = project_->get_items_of_type(Item::kSequence);
QVector<Item*> sequences = project_->get_items_of_type(Item::kSequence);

if (sequences.isEmpty()) {
SetError(tr("Project contains no sequences to export."));
Expand All @@ -48,8 +48,8 @@ bool SaveOTIOTask::Run()

std::vector<opentimelineio::v1_0::SerializableObject*> serialized;

foreach (ItemPtr item, sequences) {
SequencePtr seq = std::static_pointer_cast<Sequence>(item);
foreach (Item* item, sequences) {
Sequence* seq = static_cast<Sequence*>(item);

auto otio_timeline = SerializeTimeline(seq);

Expand Down Expand Up @@ -91,7 +91,7 @@ bool SaveOTIOTask::Run()
return (es == opentimelineio::v1_0::ErrorStatus::OK);
}

opentimelineio::v1_0::Timeline *SaveOTIOTask::SerializeTimeline(SequencePtr sequence)
opentimelineio::v1_0::Timeline *SaveOTIOTask::SerializeTimeline(Sequence *sequence)
{
auto otio_timeline = new opentimelineio::v1_0::Timeline(sequence->name().toStdString());

Expand Down
2 changes: 1 addition & 1 deletion app/task/project/saveotio/saveotio.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class SaveOTIOTask : public Task
virtual bool Run() override;

private:
opentimelineio::v1_0::Timeline* SerializeTimeline(SequencePtr sequence);
opentimelineio::v1_0::Timeline* SerializeTimeline(Sequence* sequence);

opentimelineio::v1_0::Track* SerializeTrack(TrackOutput* track);

Expand Down

0 comments on commit 7849d6f

Please sign in to comment.