Skip to content

Commit 939fc49

Browse files
committed
Merge remote-tracking branch 'upstream/develop-9.6' into merge-develop-9.6-15.02.2021_2
2 parents c85a95d + ae45b80 commit 939fc49

4 files changed

Lines changed: 39 additions & 11 deletions

File tree

docs/notes/bugfix-16296.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Fix crash on Android when restarting the location tracker

docs/notes/bugfix-23055.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Allow seek command to reset "eof" result after read command reaches the end of a file on macOS
2+

engine/src/dskmac.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1601,6 +1601,11 @@ class MCStdioFileHandle: public MCSystemFileHandle
16011601
virtual bool Seek(int64_t offset, int p_dir)
16021602
{
16031603
// TODO Add MCSystemFileHandle::SetStream(char *newptr) ?
1604+
if (m_is_eof)
1605+
{
1606+
clearerr(m_stream);
1607+
m_is_eof = false;
1608+
}
16041609
return fseeko(m_stream, offset, p_dir < 0 ? SEEK_END : (p_dir > 0 ? SEEK_SET : SEEK_CUR)) == 0;
16051610
}
16061611

engine/src/java/com/runrev/android/SensorModule.java

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -358,17 +358,37 @@ protected void onLocationChanged(Location location)
358358
public double getLongitude() { return m_last_location.getLongitude(); }
359359
public double getAltitude() { return m_last_location.getAltitude(); }
360360

361-
//override to make sure currently known location is sent if already started by heading tracker
362-
public boolean startTracking(boolean p_loosely)
363-
{
364-
boolean t_result;
365-
t_result = super.startTracking(p_loosely);
366-
if (t_result && m_last_location != null)
367-
onLocationChanged(m_last_location);
368-
return t_result;
369-
}
370-
}
371-
361+
//override to make sure currently known location is sent if already started by internal tracking
362+
public boolean startTracking(boolean p_loosely)
363+
{
364+
// Check if already tracking at the requested level
365+
int t_tracking_requested = p_loosely ? COARSE_TRACKING : FINE_TRACKING;
366+
367+
if (m_tracking_requested == t_tracking_requested)
368+
return true;
369+
370+
boolean t_result;
371+
t_result = super.startTracking(p_loosely);
372+
if (t_result && m_last_location != null)
373+
m_engine.post(new Runnable() {
374+
public void run() {
375+
onLocationChanged(m_last_location);
376+
}
377+
});
378+
return t_result;
379+
}
380+
381+
// override to clear cached last location if not tracking internallly
382+
public boolean stopTracking()
383+
{
384+
boolean t_result;
385+
t_result = super.stopTracking();
386+
if (t_result && !isTracking())
387+
m_last_location = null;
388+
return t_result;
389+
}
390+
}
391+
372392
class HeadingTracker extends Tracker implements SensorEventListener
373393
{
374394
private Sensor m_magnetometer;

0 commit comments

Comments
 (0)