From: Steinar H. Gunderson Date: Sun, 23 Jul 2023 09:06:56 +0000 (+0200) Subject: Fix a crash on exit. X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;ds=sidebyside;h=5cbfa6034ad0dea57830bc74aeba1d84cf90bad9;p=pkanalytics Fix a crash on exit. --- diff --git a/video_widget.cpp b/video_widget.cpp index 0bd910c..5d706ac 100644 --- a/video_widget.cpp +++ b/video_widget.cpp @@ -249,6 +249,16 @@ VideoWidget::VideoWidget(QWidget *parent) connect(video_window, &VideoWindow::mouse_moved, this, &VideoWidget::mouseMoveEvent); } +VideoWidget::~VideoWidget() +{ + stop(); + + // Qt will delete video_window for us after we're gone, + // so make sure its destructor does not try to mess with + // our freelist. The actual freelist frames will leak. + video_window->set_current_frame(nullptr); +} + GLuint compile_shader(const string &shader_src, GLenum type) { GLuint obj = glCreateShader(type); diff --git a/video_widget.h b/video_widget.h index 4361d30..b97be69 100644 --- a/video_widget.h +++ b/video_widget.h @@ -26,7 +26,7 @@ class VideoWidget : public QWidget { public: VideoWidget(QWidget *parent); - ~VideoWidget() { stop(); } + ~VideoWidget(); bool open(const std::string &filename); // False on error. void play();