[kstars] kstars: For quite some time, I have known there was an issue with the SimClock in KStars.

Jasem Mutlaq null at kde.org
Wed May 24 19:37:09 UTC 2017


Git commit e893a64a7a11baf3e853df134000c7a9ae815701 by Jasem Mutlaq, on behalf of Robert Lancaster.
Committed on 24/05/2017 at 19:35.
Pushed by mutlaqja into branch 'master'.

For quite some time, I have known there was an issue with the SimClock in KStars.

Whenever you try to run it in hours or anything longer than that, the interface becomes much more unresponsive.  I figured it was an issue with an animation thread not sleeping long enough for the interface to have a chance to do other things.  I investigated that today and found that I was close.  There is a QTimer with a time interval that is used for the time simulation normally, but if you go beyond a certain speed, it just set the clock and didn't use a timer.  It seems to be called "manual tick."  Well the problem is that it needs to wait a moment before doing that so the interface can respond to any other commands.  I found the solution was very simple, a one shot timer, even one as short as 1 millisecond seems to solve the problem.

CCMAIL:kstars-devel at kde.org

M  +1    -0    kstars/kstarsactions.cpp
M  +5    -1    kstars/time/simclock.cpp

https://commits.kde.org/kstars/e893a64a7a11baf3e853df134000c7a9ae815701

diff --git a/kstars/kstarsactions.cpp b/kstars/kstarsactions.cpp
index 6f7c82ff7..0d7d12014 100644
--- a/kstars/kstarsactions.cpp
+++ b/kstars/kstarsactions.cpp
@@ -536,6 +536,7 @@ void KStars::slotToggleWIView()
     {
         m_WIView = new WIView(0);
         m_wiDock = new QDockWidget(this);
+        m_wiDock->setStyleSheet("QDockWidget::title{background-color:black;}");
         m_wiDock->setObjectName("What's Interesting");
         m_wiDock->setAllowedAreas(Qt::RightDockWidgetArea);
         QWidget * container = QWidget::createWindowContainer(m_WIView->getWIBaseView());
diff --git a/kstars/time/simclock.cpp b/kstars/time/simclock.cpp
index 7f9434f0e..01713e347 100644
--- a/kstars/time/simclock.cpp
+++ b/kstars/time/simclock.cpp
@@ -102,7 +102,11 @@ void SimClock::manualTick( bool force )
 {
     if ( force || (ManualMode && ManualActive) )
     {
-        setUTC( UTC.addSecs( (long double)Scale ) );
+        //The single shot timer is needed because otherwise the animation is happening so frequently
+        //that the kstars interface becomes too unresponsive.
+        QTimer::singleShot(1, [this]{
+            setUTC( UTC.addSecs( (long double)Scale ) );
+        });
     }
     else if ( ! ManualMode )
         tick();


More information about the Kstars-devel mailing list