diff --git a/app/widget/projectexplorer/projectexplorer.cpp b/app/widget/projectexplorer/projectexplorer.cpp index 5b519396d..286925665 100644 --- a/app/widget/projectexplorer/projectexplorer.cpp +++ b/app/widget/projectexplorer/projectexplorer.cpp @@ -32,6 +32,7 @@ #include "dialog/footageproperties/footageproperties.h" #include "dialog/sequence/sequence.h" #include "widget/menu/menu.h" +#include "window/mainwindow/mainwindow.h" OLIVE_NAMESPACE_ENTER @@ -422,6 +423,15 @@ void ProjectExplorer::DeleteSelected() foreach (Item* item, selected) { ItemPtr item_ptr = item->get_shared_ptr(); + // If this is a sequence, close it + if (item_ptr->type() == Item::kSequence) { + Sequence* s = static_cast(item_ptr.get()); + + if (Core::instance()->main_window()->IsSequenceOpen(s)) { + Core::instance()->main_window()->CloseSequence(s); + } + } + new ProjectViewModel::RemoveItemCommand(&model_, item_ptr, command); } diff --git a/app/window/mainwindow/mainwindow.cpp b/app/window/mainwindow/mainwindow.cpp index 489ef9a67..96500c42d 100644 --- a/app/window/mainwindow/mainwindow.cpp +++ b/app/window/mainwindow/mainwindow.cpp @@ -160,6 +160,17 @@ void MainWindow::CloseSequence(Sequence *sequence) } } +bool MainWindow::IsSequenceOpen(Sequence *sequence) const +{ + foreach (TimelinePanel* tp, timeline_panels_) { + if (tp->GetConnectedViewer() == sequence->viewer_output()) { + return true; + } + } + + return false; +} + #ifdef Q_OS_WINDOWS void MainWindow::SetTaskbarButtonState(TBPFLAG flags) { diff --git a/app/window/mainwindow/mainwindow.h b/app/window/mainwindow/mainwindow.h index e2d8ee10e..716f17a56 100644 --- a/app/window/mainwindow/mainwindow.h +++ b/app/window/mainwindow/mainwindow.h @@ -57,6 +57,8 @@ public: void CloseSequence(Sequence* sequence); + bool IsSequenceOpen(Sequence* sequence) const; + #ifdef Q_OS_WINDOWS void SetTaskbarButtonState(TBPFLAG flags);