From f13366e273e4e74059aab58cd38e993f1d3a5046 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Fri, 23 Nov 2018 22:00:17 +1100 Subject: [PATCH] fixed occasional gl crash on close and made import context menu item always available --- effects/internal/crossdissolvetransition.cpp | 1 + mainwindow.cpp | 7 +++- playback/cacher.cpp | 1 - ui/sourcetable.cpp | 12 +++--- ui/timelinewidget.cpp | 41 ++++++++++++-------- ui/viewerwidget.cpp | 14 ++++--- ui/viewerwidget.h | 5 ++- 7 files changed, 48 insertions(+), 33 deletions(-) diff --git a/effects/internal/crossdissolvetransition.cpp b/effects/internal/crossdissolvetransition.cpp index 802700dda..06183138a 100644 --- a/effects/internal/crossdissolvetransition.cpp +++ b/effects/internal/crossdissolvetransition.cpp @@ -10,6 +10,7 @@ void CrossDissolveTransition::process_coords(double progress, GLTextureCoords&, if (!(data == TA_CLOSING_TRANSITION && secondary_clip != NULL)) { float color[4]; glGetFloatv(GL_CURRENT_COLOR, color); + if (data == TA_CLOSING_TRANSITION) progress = 1.0 - progress; glColor4f(1.0, 1.0, 1.0, color[3]*progress); } } diff --git a/mainwindow.cpp b/mainwindow.cpp index 9359d2efd..cb8c525e9 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -222,6 +222,9 @@ MainWindow::MainWindow(QWidget *parent) : } MainWindow::~MainWindow() { + panel_sequence_viewer->viewer_widget->delete_function(); + panel_footage_viewer->viewer_widget->delete_function(); + set_sequence(NULL); QString data_dir = get_data_path(); @@ -248,11 +251,11 @@ MainWindow::~MainWindow() { delete ui; + delete panel_sequence_viewer; + delete panel_footage_viewer; delete panel_project; delete panel_effect_controls; delete panel_timeline; - delete panel_sequence_viewer; - delete panel_footage_viewer; close_debug(); } diff --git a/playback/cacher.cpp b/playback/cacher.cpp index 20b9310f0..eda419f39 100644 --- a/playback/cacher.cpp +++ b/playback/cacher.cpp @@ -431,7 +431,6 @@ void cache_video_worker(Clip* c, long playhead) { bool reverse = (c->reverse && !c->ignore_reverse); c->ignore_reverse = false; - int64_t eighth_second = av_q2d(av_inv_q(c->stream->time_base))*0.125; int64_t smallest_pts = INT64_MAX; if (reverse && c->queue.size() > 0) { int64_t quarter_sec = qRound64(av_q2d(av_inv_q(c->stream->time_base))) >> 2; diff --git a/ui/sourcetable.cpp b/ui/sourcetable.cpp index 3fd930719..e321e9030 100644 --- a/ui/sourcetable.cpp +++ b/ui/sourcetable.cpp @@ -39,13 +39,13 @@ SourceTable::SourceTable(QWidget* parent) : QTreeWidget(parent) { void SourceTable::show_context_menu() { QMenu menu(this); - if (selectedItems().size() == 0) { - QAction* import_action = menu.addAction("Import..."); - connect(import_action, SIGNAL(triggered(bool)), panel_project, SLOT(import_dialog())); + QAction* import_action = menu.addAction("Import..."); + connect(import_action, SIGNAL(triggered(bool)), panel_project, SLOT(import_dialog())); - QAction* new_folder_action = menu.addAction("New Folder..."); - connect(new_folder_action, SIGNAL(triggered(bool)), mainWindow, SLOT(on_actionFolder_triggered())); - } else { + QAction* new_folder_action = menu.addAction("New Folder..."); + connect(new_folder_action, SIGNAL(triggered(bool)), mainWindow, SLOT(on_actionFolder_triggered())); + + if (selectedItems().size() > 0) { if (selectedItems().size() == 1) { // replace footage int type = get_type_from_tree(selectedItems().at(0)); diff --git a/ui/timelinewidget.cpp b/ui/timelinewidget.cpp index 5bf4c4abd..1e44b6fa4 100644 --- a/ui/timelinewidget.cpp +++ b/ui/timelinewidget.cpp @@ -73,7 +73,7 @@ void TimelineWidget::right_click_ripple() { void TimelineWidget::show_context_menu(const QPoint& pos) { if (sequence != NULL) { - // hack because sometimes right clicking doesn't trigger mouseReleaseEvent + // hack because sometimes right clicking doesn't trigger mouse release event panel_timeline->rect_select_init = false; panel_timeline->rect_select_proc = false; @@ -909,7 +909,7 @@ void TimelineWidget::mouseReleaseEvent(QMouseEvent *event) { sequence->clips.at(g.clip)->undeletable = true; if (g.transition != NULL) { g.transition->parent_clip->undeletable = true; - g.transition->secondary_clip->undeletable = true; + if (g.transition->secondary_clip != NULL) g.transition->secondary_clip->undeletable = true; } Selection s; @@ -924,7 +924,7 @@ void TimelineWidget::mouseReleaseEvent(QMouseEvent *event) { sequence->clips.at(g.clip)->undeletable = false; if (g.transition != NULL) { g.transition->parent_clip->undeletable = false; - g.transition->secondary_clip->undeletable = false; + if (g.transition->secondary_clip != NULL) g.transition->secondary_clip->undeletable = false; } } } @@ -1157,7 +1157,7 @@ void TimelineWidget::update_ghosts(const QPoint& mouse_pos, bool lock_frame) { if (panel_timeline->tool != TIMELINE_TOOL_SLIP) { // slipping doesn't move the clips so we don't bother snapping for it for (int i=0;ighosts.size();i++) { - Ghost& g = panel_timeline->ghosts[i]; + const Ghost& g = panel_timeline->ghosts.at(i); if (panel_timeline->trim_target == -1 || g.trim_in) { fm = g.old_in + frame_diff; if (panel_timeline->snap_to_timeline(&fm, true, true, true)) { @@ -1281,19 +1281,28 @@ void TimelineWidget::update_ghosts(const QPoint& mouse_pos, bool lock_frame) { if (validator < 0) frame_diff -= validator; if (g.transition != NULL) { - // prevent clip_in from going below 0 - if (c->media_type == MEDIA_TYPE_SEQUENCE - || (ms != NULL && !ms->infinite_length)) { - validator = g.old_clip_in + frame_diff; - if (validator < 0) frame_diff -= validator; - } + if (g.transition->secondary_clip != NULL) { + // prevent dual transitions from going below 0 on the primary or above media length on the secondary + validator = g.transition->parent_clip->get_clip_in_with_transition() + frame_diff; + if (validator < 0) frame_diff -= validator; - // prevent clip length exceeding media length - if (c->media_type == MEDIA_TYPE_SEQUENCE - || (ms != NULL && !ms->infinite_length)) { - validator = g.old_clip_in + g.ghost_length + frame_diff; - if (validator > g.media_length) frame_diff -= validator - g.media_length; - } + validator = g.transition->secondary_clip->get_timeline_out_with_transition() - g.transition->secondary_clip->get_timeline_in_with_transition() + g.transition->secondary_clip->get_clip_in_with_transition() + frame_diff - g.transition->secondary_clip->getMaximumLength(); + if (validator > 0) frame_diff -= validator; + } else { + // prevent clip_in from going below 0 + if (c->media_type == MEDIA_TYPE_SEQUENCE + || (ms != NULL && !ms->infinite_length)) { + validator = g.old_clip_in + frame_diff; + if (validator < 0) frame_diff -= validator; + } + + // prevent clip length exceeding media length + if (c->media_type == MEDIA_TYPE_SEQUENCE + || (ms != NULL && !ms->infinite_length)) { + validator = g.old_clip_in + g.ghost_length + frame_diff; + if (validator > g.media_length) frame_diff -= validator - g.media_length; + } + } } // prevent clips from crossing tracks diff --git a/ui/viewerwidget.cpp b/ui/viewerwidget.cpp index 6cb3ff263..f1b1dbbd3 100644 --- a/ui/viewerwidget.cpp +++ b/ui/viewerwidget.cpp @@ -51,14 +51,16 @@ ViewerWidget::ViewerWidget(QWidget *parent) : connect(&retry_timer, SIGNAL(timeout()), this, SLOT(retry())); setContextMenuPolicy(Qt::CustomContextMenu); - connect(this, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(show_context_menu())); + connect(this, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(show_context_menu())); } -void ViewerWidget::deleteFunction() { +void ViewerWidget::delete_function() { // destroy all textures as well - makeCurrent(); - closeActiveClips(viewer->seq, true); - doneCurrent(); + if (viewer->seq != NULL) { + makeCurrent(); + closeActiveClips(viewer->seq, true); + doneCurrent(); + } } void ViewerWidget::show_context_menu() { @@ -107,7 +109,7 @@ void ViewerWidget::retry() { } void ViewerWidget::initializeGL() { - connect(context(), SIGNAL(aboutToBeDestroyed()), this, SLOT(deleteFunction()), Qt::DirectConnection); + connect(context(), SIGNAL(aboutToBeDestroyed()), this, SLOT(delete_function()), Qt::DirectConnection); retry_timer.start(); } diff --git a/ui/viewerwidget.h b/ui/viewerwidget.h index 1f2931484..7d15b8cc2 100644 --- a/ui/viewerwidget.h +++ b/ui/viewerwidget.h @@ -20,7 +20,7 @@ class ViewerWidget : public QOpenGLWidget { Q_OBJECT public: - ViewerWidget(QWidget *parent = 0); + ViewerWidget(QWidget *parent = 0); void paintGL(); void initializeGL(); @@ -31,6 +31,8 @@ public: bool waveform; Clip* waveform_clip; MediaStream* waveform_ms; +public slots: + void delete_function(); protected: void paintEvent(QPaintEvent *e); // void resizeGL(int w, int h); @@ -47,7 +49,6 @@ private: void process_effect(Clip* c, Effect* e, double timecode, GLTextureCoords& coords, GLuint& composite_texture, bool& fbo_switcher, int data); private slots: void retry(); - void deleteFunction(); void show_context_menu(); void save_frame(); };