Merge lp:~sojkam1-fel/stellarium/fix-24h-wrap into lp:stellarium

Proposed by Michal Sojka
Status: Merged
Merged at revision: 7481
Proposed branch: lp:~sojkam1-fel/stellarium/fix-24h-wrap
Merge into: lp:stellarium
Diff against target: 63 lines (+6/-8)
2 files modified
src/core/StelApp.cpp (+5/-6)
src/core/StelApp.hpp (+1/-2)
To merge this branch: bzr merge lp:~sojkam1-fel/stellarium/fix-24h-wrap
Reviewer Review Type Date Requested Status
Alexander Wolf Approve
Review via email: mp+253575@code.launchpad.net

Description of the change

Allow running in real time for longer than 24 hours

When Stellarium runs in real time, after 24 hours the time jumps back to the instant when Stellarium was started. The reason is that class QTime, which is used for measuring elapsed time, cannot represent intervals longer than 24 hours.

Fix this problem by using QDateTime::currentMSecsSinceEpoch(), which is available since Qt 4.7.

BTW, is there a reason why StelApp::qtime was a static member?

To post a comment you must log in.
Revision history for this message
Alexander Wolf (alexwolf) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/core/StelApp.cpp'
2--- src/core/StelApp.cpp 2015-02-18 22:21:55 +0000
3+++ src/core/StelApp.cpp 2015-03-19 20:58:23 +0000
4@@ -76,6 +76,7 @@
5 #include <QDir>
6 #include <QCoreApplication>
7 #include <QScreen>
8+#include <QDateTime>
9
10 #ifdef USE_STATIC_PLUGIN_HELLOSTELMODULE
11 Q_IMPORT_PLUGIN(HelloStelModuleStelPluginInterface)
12@@ -167,18 +168,16 @@
13
14 // Initialize static variables
15 StelApp* StelApp::singleton = NULL;
16-QTime* StelApp::qtime = NULL;
17+qint64 StelApp::startMSecs = 0;
18
19 void StelApp::initStatic()
20 {
21- StelApp::qtime = new QTime();
22- StelApp::qtime->start();
23+ StelApp::startMSecs = QDateTime::currentMSecsSinceEpoch();
24 }
25
26 void StelApp::deinitStatic()
27 {
28- delete StelApp::qtime;
29- StelApp::qtime = NULL;
30+ StelApp::startMSecs = 0;
31 }
32
33 /*************************************************************************
34@@ -756,7 +755,7 @@
35 // Return the time since when stellarium is running in second.
36 double StelApp::getTotalRunTime()
37 {
38- return (double)(StelApp::qtime->elapsed())/1000.;
39+ return (double)(QDateTime::currentMSecsSinceEpoch() - StelApp::startMSecs)/1000.;
40 }
41
42
43
44=== modified file 'src/core/StelApp.hpp'
45--- src/core/StelApp.hpp 2015-02-18 22:10:28 +0000
46+++ src/core/StelApp.hpp 2015-03-19 20:58:23 +0000
47@@ -35,7 +35,6 @@
48 class QSettings;
49 class QNetworkAccessManager;
50 class QNetworkReply;
51-class QTime;
52 class QTimer;
53 class StelLocationMgr;
54 class StelSkyLayerMgr;
55@@ -334,7 +333,7 @@
56 // Define whether the StelApp instance has completed initialization
57 bool initialized;
58
59- static QTime* qtime;
60+ static qint64 startMSecs;
61
62 // Temporary variables used to store the last gl window resize
63 // if the core was not yet initialized