aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/citra_qt/bootmanager.cpp
diff options
context:
space:
mode:
authorGravatar Sacha <xsacha@gmail.com>2014-08-25 00:47:00 +1000
committerGravatar Sacha <xsacha@gmail.com>2014-08-25 00:47:00 +1000
commita3a70e56acfde2cf75dfd02a6c2f1828d28efe02 (patch)
tree56e2fb6a10d72abedebb83c1681f9cddbe7462e4 /src/citra_qt/bootmanager.cpp
parentfab2f28ea5f33106dfdc5d1c4197e01b4be9276a (diff)
Fix the threading for GL Context in Qt5.
Connect the emu_thread start/finish to a moveContext slot.
Diffstat (limited to 'src/citra_qt/bootmanager.cpp')
-rw-r--r--src/citra_qt/bootmanager.cpp22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/citra_qt/bootmanager.cpp b/src/citra_qt/bootmanager.cpp
index b0aa1e56..73f25e69 100644
--- a/src/citra_qt/bootmanager.cpp
+++ b/src/citra_qt/bootmanager.cpp
@@ -1,5 +1,6 @@
#include <QHBoxLayout>
#include <QKeyEvent>
+#include <QApplication>
#include "common/common.h"
#include "bootmanager.hxx"
@@ -79,15 +80,11 @@ class GGLWidgetInternal : public QGLWidget
public:
GGLWidgetInternal(QGLFormat fmt, GRenderWindow* parent) : QGLWidget(parent)
{
- doneCurrent();
parent_ = parent;
}
void paintEvent(QPaintEvent* ev)
{
- // Apparently, Windows doesn't display anything if we don't call this here.
- // TODO: Breaks linux though because we aren't calling doneCurrent() ... -.-
-// makeCurrent();
}
void resizeEvent(QResizeEvent* ev) {
parent_->SetClientAreaWidth(size().width());
@@ -118,10 +115,22 @@ GRenderWindow::GRenderWindow(QWidget* parent) : QWidget(parent), emu_thread(this
layout->addWidget(child);
layout->setMargin(0);
setLayout(layout);
+ QObject::connect(&emu_thread, SIGNAL(started()), this, SLOT(moveContext()));
+ QObject::connect(&emu_thread, SIGNAL(finished()), this, SLOT(moveContext()));
BackupGeometry();
}
+void GRenderWindow::moveContext()
+{
+ DoneCurrent();
+ // We need to move GL context to the swapping thread in Qt5
+#if QT_VERSION > QT_VERSION_CHECK(5, 0, 0)
+ // If the thread started running, move the GL Context to the new thread. Otherwise, move it back.
+ child->context()->moveToThread(emu_thread.isRunning() ? &emu_thread : qApp->thread());
+#endif
+}
+
GRenderWindow::~GRenderWindow()
{
emu_thread.Stop();
@@ -129,7 +138,7 @@ GRenderWindow::~GRenderWindow()
void GRenderWindow::SwapBuffers()
{
- child->makeCurrent(); // TODO: Not necessary?
+ // MakeCurrent is already called in renderer_opengl
child->swapBuffers();
}
@@ -212,4 +221,5 @@ void GRenderWindow::keyReleaseEvent(QKeyEvent* event)
if (!key_processed)
QWidget::keyPressEvent(event);
*/
-} \ No newline at end of file
+}
+