Merge lp:~wlformyd/stellarium/bug1210510 into lp:stellarium

Proposed by William Formyduval
Status: Merged
Merged at revision: 6676
Proposed branch: lp:~wlformyd/stellarium/bug1210510
Merge into: lp:stellarium
Diff against target: 80 lines (+27/-4)
2 files modified
src/StelMainView.cpp (+24/-3)
src/StelMainView.hpp (+3/-1)
To merge this branch: bzr merge lp:~wlformyd/stellarium/bug1210510
Reviewer Review Type Date Requested Status
Guillaume Chereau Pending
Fabien Chéreau Pending
Review via email: mp+210332@code.launchpad.net

Description of the change

Fix for bug1210510. Prevent more than maximum_fps (from config.ini) scene updates in drawBackground.

To post a comment you must log in.
lp:~wlformyd/stellarium/bug1210510 updated
6627. By William Formyduval

Moved setting of flagMaxFpsUpdatePending to before singleShot to avoid race

Revision history for this message
Alexander Wolf (alexwolf) wrote :

Looks like after latest couple of changes this patch doesn't work as expected.

lp:~wlformyd/stellarium/bug1210510 updated
6628. By William Formyduval

Added a pause of the minFPS timer when working at maxFPS

Revision history for this message
William Formyduval (wlformyd) wrote :

I think the problem was the minFPS timer still going on when at maxFPS. Latest commit should fix that. Tested with various min/max FPS settings and maxFPS seems to be honored now.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/StelMainView.cpp'
2--- src/StelMainView.cpp 2014-02-15 23:11:29 +0000
3+++ src/StelMainView.cpp 2014-03-13 03:08:31 +0000
4@@ -340,6 +340,7 @@
5 setCursorTimeout(conf->value("gui/mouse_cursor_timeout", 10.f).toFloat());
6 maxfps = conf->value("video/maximum_fps",10000.f).toFloat();
7 minfps = conf->value("video/minimum_fps",10000.f).toFloat();
8+ flagMaxFpsUpdatePending = false;
9
10 // XXX: This should be done in StelApp::init(), unfortunately for the moment we need init the gui before the
11 // plugins, because the gui create the QActions needed by some plugins.
12@@ -432,6 +433,12 @@
13 lastEventTimeSec = StelApp::getTotalRunTime();
14 }
15
16+void StelMainView::maxFpsSceneUpdate()
17+{
18+ updateScene();
19+ flagMaxFpsUpdatePending = false;
20+}
21+
22 void StelMainView::drawBackground(QPainter*, const QRectF&)
23 {
24 const double now = StelApp::getTotalRunTime();
25@@ -441,9 +448,23 @@
26 // after that, it switches back to the default minfps value to save power
27 if (now-lastEventTimeSec<2.5)
28 {
29- double duration = 1./getMaxFps();
30- int dur = (int)(duration*1000);
31- QTimer::singleShot(dur<5 ? 5 : dur, this, SLOT(updateScene()));
32+ if (!flagMaxFpsUpdatePending)
33+ {
34+ double duration = 1./getMaxFps();
35+ int dur = (int)(duration*1000);
36+
37+ if (minFpsTimer!=NULL)
38+ {
39+ disconnect(minFpsTimer, SIGNAL(timeout()), 0, 0);
40+ delete minFpsTimer;
41+ minFpsTimer = NULL;
42+ }
43+ flagMaxFpsUpdatePending = true;
44+ QTimer::singleShot(dur<5 ? 5 : dur, this, SLOT(maxFpsSceneUpdate()));
45+ }
46+ } else if (minFpsTimer == NULL) {
47+ // Restart the minfps timer
48+ minFpsChanged();
49 }
50
51 // Manage cursor timeout
52
53=== modified file 'src/StelMainView.hpp'
54--- src/StelMainView.hpp 2014-02-27 16:15:23 +0000
55+++ src/StelMainView.hpp 2014-03-13 03:08:31 +0000
56@@ -108,6 +108,7 @@
57 //! Get the current maximum frames per second.
58 float getMaxFps() {return maxfps;}
59
60+ void maxFpsSceneUpdate();
61 //! Updates the scene and process all events
62 void updateScene();
63
64@@ -139,7 +140,7 @@
65 private:
66 //! Start the display loop
67 void startMainLoop();
68-
69+
70 QString getSupportedOpenGLVersion() const;
71
72 //! The StelMainView singleton
73@@ -171,6 +172,7 @@
74 double lastEventTimeSec;
75
76 QTimer* minFpsTimer;
77+ bool flagMaxFpsUpdatePending;
78 //! The minimum desired frame rate in frame per second.
79 float minfps;
80 //! The maximum desired frame rate in frame per second.