From dcde4bd46cb87bb861ec906881bdec7da1141152 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Wed, 25 Jul 2018 21:14:44 +0100 Subject: [PATCH] sorta fixed some stuff --- main.cpp | 2 +- panels/timeline.cpp | 7 ++++++- ui/timelinewidget.cpp | 11 ++++++++--- ui/viewerwidget.cpp | 21 +++++++++++++++++++++ ui/viewerwidget.h | 1 + 5 files changed, 37 insertions(+), 5 deletions(-) diff --git a/main.cpp b/main.cpp index 2b0d7ddd0..61fc82cca 100644 --- a/main.cpp +++ b/main.cpp @@ -10,7 +10,7 @@ int main(int argc, char *argv[]) // init ffmpeg subsystem av_register_all(); - QApplication::setAttribute(Qt::AA_ShareOpenGLContexts, true); +// QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts, true); QApplication a(argc, argv); MainWindow w; diff --git a/panels/timeline.cpp b/panels/timeline.cpp index 9e8c4b648..0b9830fd6 100644 --- a/panels/timeline.cpp +++ b/panels/timeline.cpp @@ -908,7 +908,12 @@ bool Timeline::snap_to_point(long point, long* l) { void Timeline::snap_to_clip(long* l, bool playhead_inclusive) { snapped = false; if (snapping) { - if (!playhead_inclusive || !snap_to_point(playhead, l)) { + if (playhead_inclusive && !playing) { + playhead_inclusive = snap_to_point(playhead, l); + } else { + playhead_inclusive = false; + } + if (!playhead_inclusive) { for (int i=0;iclip_count();i++) { Clip* c = sequence->get_clip(i); if (c != NULL) { diff --git a/ui/timelinewidget.cpp b/ui/timelinewidget.cpp index 0b695554c..028c21f3e 100644 --- a/ui/timelinewidget.cpp +++ b/ui/timelinewidget.cpp @@ -634,9 +634,12 @@ bool subvalidate_snapping(const Ghost& g, long* frame_diff, long snap_point) { } void validate_snapping(const Ghost& g, long* frame_diff) { - panel_timeline->snapped = false; if (panel_timeline->snapping) { - if (!subvalidate_snapping(g, frame_diff, panel_timeline->playhead)) { + bool snap_to_clip = true; + if (!panel_timeline->playing) { + snap_to_clip = !subvalidate_snapping(g, frame_diff, panel_timeline->playhead); + } + if (snap_to_clip) { for (int j=0;jclip_count();j++) { Clip* c = sequence->get_clip(j); if (c != NULL) { @@ -657,11 +660,13 @@ void TimelineWidget::update_ghosts(QPoint& mouse_pos) { long validator; // first try to snap + panel_timeline->snapped = false; 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]; validate_snapping(g, &frame_diff); + if (panel_timeline->snapped) break; } } @@ -789,7 +794,7 @@ void TimelineWidget::update_ghosts(QPoint& mouse_pos) { } // apply changes to selections - if (panel_timeline->tool != TIMELINE_TOOL_SLIP) { + if (panel_timeline->tool != TIMELINE_TOOL_SLIP && !panel_timeline->importing) { for (int i=0;iselections.size();i++) { Selection& s = panel_timeline->selections[i]; if (panel_timeline->trim_target > -1) { diff --git a/ui/viewerwidget.cpp b/ui/viewerwidget.cpp index 732c3ba09..0b09a009c 100644 --- a/ui/viewerwidget.cpp +++ b/ui/viewerwidget.cpp @@ -34,17 +34,38 @@ ViewerWidget::ViewerWidget(QWidget *parent) : QOpenGLWidget(parent) { connect(&retry_timer, SIGNAL(timeout()), this, SLOT(retry())); } +void ViewerWidget::deleteFunction() { + // destroy all textures as well + for (int i=0;iclip_count();i++) { + Clip* c = sequence->get_clip(i); + if (c->texture != NULL) { + /* TODO NOTE: apparently "destroy()" is non-functional here because + * it requires a valid current context, and I guess it's no longer + * valid or current by the time this function is called. Not sure + * how to handle that just yet... + */ + + c->texture->destroy(); + c->texture = NULL; + } + } +} + void ViewerWidget::retry() { update(); } void ViewerWidget::initializeGL() { + connect(context(), SIGNAL(aboutToBeDestroyed()), this, SLOT(deleteFunction())); + initializeOpenGLFunctions(); glClearColor(0, 0, 0, 1); glMatrixMode(GL_PROJECTION); glEnable(GL_TEXTURE_2D); glEnable(GL_BLEND); + + update(); } //void ViewerWidget::resizeGL(int w, int h) diff --git a/ui/viewerwidget.h b/ui/viewerwidget.h index b671092b8..3b4136203 100644 --- a/ui/viewerwidget.h +++ b/ui/viewerwidget.h @@ -32,6 +32,7 @@ private: QVector samples; private slots: void retry(); + void deleteFunction(); }; #endif // VIEWERWIDGET_H