Skip to content

Commit e81196d

Browse files
committed
Fix E32USER-CBase 47 panic from position requestor when speed == 0
1 parent 43877e6 commit e81196d

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

src/PositionRequestor.cpp

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -362,18 +362,26 @@ void CDynamicPositionRequestor::RunL()
362362
else
363363
{
364364
LOG(_L8("Max speed=%f m/s"), speed);
365-
TReal time;
366-
TInt err = Math::Round(time, KDistanceBetweenPoints / speed, 0); // Round to seconds
367-
// to prevent too often positioner options updated
368-
if (err != KErrNone)
369-
LOG(_L8("Time Round error"));
370-
User::LeaveIfError(err);
371-
372-
updateInterval = TTimeIntervalMicroSeconds(time * KSecond);
373-
// Use range restrictions
374-
updateInterval = Min(
375-
Max(updateInterval, KPositionMinUpdateInterval),
376-
KPositionMaxUpdateInterval);
365+
TReal time = KDistanceBetweenPoints / speed;
366+
if (Math::IsFinite(time)) // i.e. speed > 0
367+
{
368+
TInt err = Math::Round(time, time, 0); // Round to seconds
369+
// to prevent too often positioner options updated
370+
if (err != KErrNone)
371+
LOG(_L8("Time Round error"));
372+
User::LeaveIfError(err);
373+
374+
updateInterval = TTimeIntervalMicroSeconds(time * KSecond);
375+
// Use range restrictions
376+
updateInterval = Min(
377+
Max(updateInterval, KPositionMinUpdateInterval),
378+
KPositionMaxUpdateInterval);
379+
}
380+
else
381+
{
382+
LOG(_L8("Error calculating position update time - set it to max value"));
383+
updateInterval = KPositionMaxUpdateInterval;
384+
}
377385
}
378386

379387
if (updateInterval != iUpdateOptions.UpdateInterval())

0 commit comments

Comments
 (0)