Commit 86bea8d1 authored by Jasem Mutlaq's avatar Jasem Mutlaq

BUGS:382054

Fix Advance one time step backward or forward behavior. The lambda was executed after the scale tick was reset to its original value thereby rendering backward stepping useless. Now there is an explicit parameter in manualTick to specify direction.
parent 632ae310
......@@ -1264,9 +1264,7 @@ void KStars::slotStepBackward()
{
if (data()->clock()->isActive())
data()->clock()->stop();
data()->clock()->setClockScale(-1.0 * data()->clock()->scale()); //temporarily need negative time step
data()->clock()->manualTick(true);
data()->clock()->setClockScale(-1.0 * data()->clock()->scale()); //reset original sign of time step
data()->clock()->manualTick(true, true);
map()->forceUpdate();
}
......
......@@ -96,13 +96,13 @@ void SimClock::setManualMode(bool on)
ManualMode = on;
}
void SimClock::manualTick(bool force)
void SimClock::manualTick(bool force, bool backward)
{
if (force || (ManualMode && ManualActive))
{
//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)); });
QTimer::singleShot(1, [this,backward] { setUTC(UTC.addSecs((long double)Scale * (backward ? -1 : 1))); });
}
else if (!ManualMode)
tick();
......
......@@ -110,8 +110,11 @@ class SimClock : public QObject
* If ManualActive is true, add Scale seconds to the SimClock time.
* (we may want to modify this slightly...e.g., the number of seconds in a
* year is not constant (leap years), so it is better to increment the
* year, instead of adding 31 million seconds. */
void manualTick(bool force = false);
* year, instead of adding 31 million seconds.
* set backward to true to reverse sign of Scale value
*/
void manualTick(bool force = false, bool backward = false);
signals:
/** The time has changed (emitted by setUTC() ) */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment