From 5cbfa6034ad0dea57830bc74aeba1d84cf90bad9 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Sun, 23 Jul 2023 11:06:56 +0200 Subject: [PATCH] Fix a crash on exit. --- video_widget.cpp | 10 ++++++++++ video_widget.h | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) 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(); -- 2.39.2