summaryrefslogtreecommitdiff
path: root/platform/android
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2016-10-24 14:14:37 +0100
committerRobin Watts <robin.watts@artifex.com>2016-10-24 14:42:46 +0100
commita76bbd0f0b2f966a04a560cb02ba2d926f0e4adb (patch)
treed5aa9c04ae1569d9782fce3e890f6a869ad3a2cf /platform/android
parentafaf3dc8801e863fdfafdda35192973fa635cb0e (diff)
downloadmupdf-a76bbd0f0b2f966a04a560cb02ba2d926f0e4adb.tar.xz
Bug 697226: Fix SEGV in Android viewer.
As we skip through pages very quickly, it is apparently possible to trigger a SEGV. Alex Talis has given a clear description of the problem on the bug, and proposed this solution. Essentially this tweaks our CancellableAsyncTask class to ensure that we do not destroy the cookie before it has finished being accessed.
Diffstat (limited to 'platform/android')
-rw-r--r--platform/android/viewer/src/com/artifex/mupdfdemo/CancellableAsyncTask.java10
-rw-r--r--platform/android/viewer/src/com/artifex/mupdfdemo/PageView.java14
2 files changed, 14 insertions, 10 deletions
diff --git a/platform/android/viewer/src/com/artifex/mupdfdemo/CancellableAsyncTask.java b/platform/android/viewer/src/com/artifex/mupdfdemo/CancellableAsyncTask.java
index fcb1b744..53d16f57 100644
--- a/platform/android/viewer/src/com/artifex/mupdfdemo/CancellableAsyncTask.java
+++ b/platform/android/viewer/src/com/artifex/mupdfdemo/CancellableAsyncTask.java
@@ -46,10 +46,16 @@ public class CancellableAsyncTask<Params, Result>
CancellableAsyncTask.this.onPostExecute(result);
task.doCleanup();
}
+
+ @Override
+ protected void onCancelled(Result result)
+ {
+ task.doCleanup();
+ }
};
}
- public void cancelAndWait()
+ public void cancel()
{
this.asyncTask.cancel(true);
ourTask.doCancel();
@@ -67,8 +73,6 @@ public class CancellableAsyncTask<Params, Result>
catch (CancellationException e)
{
}
-
- ourTask.doCleanup();
}
public void execute(Params ... params)
diff --git a/platform/android/viewer/src/com/artifex/mupdfdemo/PageView.java b/platform/android/viewer/src/com/artifex/mupdfdemo/PageView.java
index 502e0c2b..5f5cc638 100644
--- a/platform/android/viewer/src/com/artifex/mupdfdemo/PageView.java
+++ b/platform/android/viewer/src/com/artifex/mupdfdemo/PageView.java
@@ -144,12 +144,12 @@ public abstract class PageView extends ViewGroup {
private void reinit() {
// Cancel pending render task
if (mDrawEntire != null) {
- mDrawEntire.cancelAndWait();
+ mDrawEntire.cancel();
mDrawEntire = null;
}
if (mDrawPatch != null) {
- mDrawPatch.cancelAndWait();
+ mDrawPatch.cancel();
mDrawPatch = null;
}
@@ -229,7 +229,7 @@ public abstract class PageView extends ViewGroup {
public void setPage(int page, PointF size) {
// Cancel pending render task
if (mDrawEntire != null) {
- mDrawEntire.cancelAndWait();
+ mDrawEntire.cancel();
mDrawEntire = null;
}
@@ -603,7 +603,7 @@ public abstract class PageView extends ViewGroup {
// Stop the drawing of previous patch if still going
if (mDrawPatch != null) {
- mDrawPatch.cancelAndWait();
+ mDrawPatch.cancel();
mDrawPatch = null;
}
@@ -647,12 +647,12 @@ public abstract class PageView extends ViewGroup {
public void update() {
// Cancel pending render task
if (mDrawEntire != null) {
- mDrawEntire.cancelAndWait();
+ mDrawEntire.cancel();
mDrawEntire = null;
}
if (mDrawPatch != null) {
- mDrawPatch.cancelAndWait();
+ mDrawPatch.cancel();
mDrawPatch = null;
}
@@ -673,7 +673,7 @@ public abstract class PageView extends ViewGroup {
public void removeHq() {
// Stop the drawing of the patch if still going
if (mDrawPatch != null) {
- mDrawPatch.cancelAndWait();
+ mDrawPatch.cancel();
mDrawPatch = null;
}