From b7ba2e2c578f9b7085adfc50d8db4b84183e8f2b Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 11 Oct 2015 14:11:12 +0200 Subject: DOCS/client_api_examples/qt_opengl: fix uninit mpv_opengl_cb_uninit_gl() still needs the OpenGL context. It makes calls to free OpenGL objects. Strictly speaking, this is probably unnecessary, because the OpenGL context is destroyed afterwards (implicitly freeing all related objects). But mpv_opengl_cb_uninit_gl() does not require the destruction of the OpenGL context, and thus has to free resources manually. It's also true that OpenGL normally simply ignores API calls (or returns errors) if no context is set, but doing it properly is cleaner. That makeCurrent() can be called in the destructor is explicitly allowed and recommended for freeing GL resources in the Qt docs. This fixes a mpv error message on exit. --- DOCS/client_api_examples/qt_opengl/mpvwidget.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/DOCS/client_api_examples/qt_opengl/mpvwidget.cpp b/DOCS/client_api_examples/qt_opengl/mpvwidget.cpp index 2f3bf7e200..16b800995c 100644 --- a/DOCS/client_api_examples/qt_opengl/mpvwidget.cpp +++ b/DOCS/client_api_examples/qt_opengl/mpvwidget.cpp @@ -47,6 +47,7 @@ MpvWidget::MpvWidget(QWidget *parent, Qt::WindowFlags f) MpvWidget::~MpvWidget() { + makeCurrent(); if (mpv_gl) mpv_opengl_cb_set_update_callback(mpv_gl, NULL, NULL); // Until this call is done, we need to make sure the player remains -- cgit v1.2.3