From 5263d532827d797842cf711289410035f66360ae Mon Sep 17 00:00:00 2001 From: Sacha Date: Tue, 5 Nov 2013 10:54:37 +1000 Subject: [PATCH] Implement throttling for Qt desktop UI (same as the Windows-only one in Core/Config) to stop it using 100% cpu in menus. --- Qt/qtemugl.cpp | 10 +++++++++- native | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Qt/qtemugl.cpp b/Qt/qtemugl.cpp index a70147884f..56b6eef1e8 100644 --- a/Qt/qtemugl.cpp +++ b/Qt/qtemugl.cpp @@ -24,11 +24,19 @@ void QtEmuGL::initializeGL() } void QtEmuGL::paintGL() { + static double startTime = 0; NativeUpdate(*input_state); NativeRender(); EndInputState(input_state); - time_update(); + if (globalUIState != UISTATE_INGAME && globalUIState != UISTATE_EXIT) { + time_update(); + double diffTime = time_now_d() - startTime; + startTime = time_now_d(); + int sleepTime = (int) (1000000.0 / 60.0) - (int) (diffTime * 1000000.0); + if (sleepTime > 0) + usleep(sleepTime); + } } void QtEmuGL::mouseDoubleClickEvent(QMouseEvent *) diff --git a/native b/native index a02668cf8a..c00a47c892 160000 --- a/native +++ b/native @@ -1 +1 @@ -Subproject commit a02668cf8a0167104513ea4fddcf3fe0a8b5572c +Subproject commit c00a47c8923a061ff970c0ba2b7ba9d73cb17a74