]> git.sesse.net Git - kdenlive/blobdiff - src/clipmanager.cpp
Various changes for getting an OpenGL context (almost) everywhere it is needed.
[kdenlive] / src / clipmanager.cpp
index 584955a4f00f84c1cc33d5e43a098ae0f5a8a3c5..22fee7559ab503448312ff01a5e4bc725704a000 100644 (file)
 
 #include <QGraphicsItemGroup>
 #include <QtConcurrentRun>
+#include <QGLWidget>
 
 #include <KFileMetaInfo>
 
 
-ClipManager::ClipManager(KdenliveDoc *doc) :
+ClipManager::ClipManager(KdenliveDoc *doc, QGLWidget *glContext) :
     QObject(),
+    m_mainGLContext(glContext),
     m_audioThumbsQueue(),
     m_doc(doc),
     m_abortThumb(false),
@@ -165,6 +167,10 @@ void ClipManager::stopThumbs(const QString &id)
 
 void ClipManager::slotGetThumbs()
 {
+    // We are in a new thread, so we need a new OpenGL context for the remainder of the function.
+    QGLWidget ctx(0, m_mainGLContext);
+    ctx.makeCurrent();
+
     QMap<QString, int>::const_iterator i;
     int max;
     int done = 0;
@@ -251,6 +257,10 @@ void ClipManager::askForAudioThumb(const QString &id)
 
 void ClipManager::slotGetAudioThumbs()
 {
+    // We are in a new thread, so we need a new OpenGL context for the remainder of the function.
+    QGLWidget ctx(0, m_mainGLContext);
+    ctx.makeCurrent();
+
     Mlt::Profile prof((char*) KdenliveSettings::current_profile().toUtf8().constData());
     mlt_audio_format audioFormat = mlt_audio_s16;
     while (!m_abortAudioThumb && !m_audioThumbsQueue.isEmpty()) {