]> git.sesse.net Git - pkanalytics/blobdiff - video_widget.cpp
Fix a threading issue, where we would call into the Qt thread from the video thread.
[pkanalytics] / video_widget.cpp
index a5b45136537552282d1ec8c118f5cd998de51adb..126e874aa53b1591e6b53d984a26cfd63a25ad1e 100644 (file)
@@ -30,6 +30,8 @@ extern "C" {
 #include <vector>
 #include <unordered_set>
 
+#include "post_to_main_thread.h"
+
 #include <QOpenGLFunctions>
 #include <QWheelEvent>
 #include <QMouseEvent>
@@ -946,7 +948,9 @@ void VideoWidget::store_pts(int64_t pts)
 {
        last_pts = pts;
        last_position = lrint(pts * double(video_timebase.num) / double(video_timebase.den) * 1000);
-       emit position_changed(last_position);
+       post_to_main_thread([this, last_position{last_position.load()}] {
+               emit position_changed(last_position);
+       });
 }
 
 // Taken from Movit (see the comment there for explanation)