diff options
| author | Po Lu | 2024-02-07 21:09:18 +0800 |
|---|---|---|
| committer | Po Lu | 2024-02-07 21:09:34 +0800 |
| commit | e5cb268b2cf612492dfaf39d28f43357710003a6 (patch) | |
| tree | 024c2da0868ba489faad7126ad2452ff1c72db4b /java | |
| parent | ccae58a425674c36cb6f17bcebc4416d34f23a37 (diff) | |
| download | emacs-e5cb268b2cf612492dfaf39d28f43357710003a6.tar.gz emacs-e5cb268b2cf612492dfaf39d28f43357710003a6.zip | |
Fix DEBUG_THREADS in the Android port
* java/org/gnu/emacs/EmacsService.java (EmacsService): New field
`mainThread'.
(onCreate): Set `mainThread' to the thread where the service's
looper executes.
(checkEmacsThread): Compare against SERVICE.mainThread.
Diffstat (limited to 'java')
| -rw-r--r-- | java/org/gnu/emacs/EmacsService.java | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/java/org/gnu/emacs/EmacsService.java b/java/org/gnu/emacs/EmacsService.java index 93e34e6e694..b65b10b9528 100644 --- a/java/org/gnu/emacs/EmacsService.java +++ b/java/org/gnu/emacs/EmacsService.java | |||
| @@ -136,6 +136,10 @@ public final class EmacsService extends Service | |||
| 136 | been created yet. */ | 136 | been created yet. */ |
| 137 | private EmacsSafThread storageThread; | 137 | private EmacsSafThread storageThread; |
| 138 | 138 | ||
| 139 | /* The Thread object representing the Android user interface | ||
| 140 | thread. */ | ||
| 141 | private Thread mainThread; | ||
| 142 | |||
| 139 | static | 143 | static |
| 140 | { | 144 | { |
| 141 | servicingQuery = new AtomicInteger (); | 145 | servicingQuery = new AtomicInteger (); |
| @@ -236,6 +240,7 @@ public final class EmacsService extends Service | |||
| 236 | / metrics.density) | 240 | / metrics.density) |
| 237 | * pixelDensityX); | 241 | * pixelDensityX); |
| 238 | resolver = getContentResolver (); | 242 | resolver = getContentResolver (); |
| 243 | mainThread = Thread.currentThread (); | ||
| 239 | 244 | ||
| 240 | /* If the density used to compute the text size is lesser than | 245 | /* If the density used to compute the text size is lesser than |
| 241 | 160, there's likely a bug with display density computation. | 246 | 160, there's likely a bug with display density computation. |
| @@ -384,7 +389,13 @@ public final class EmacsService extends Service | |||
| 384 | { | 389 | { |
| 385 | if (DEBUG_THREADS) | 390 | if (DEBUG_THREADS) |
| 386 | { | 391 | { |
| 387 | if (Thread.currentThread () instanceof EmacsThread) | 392 | /* When SERVICE is NULL, Emacs is being executed non-interactively. */ |
| 393 | if (SERVICE == null | ||
| 394 | /* It was previously assumed that only instances of | ||
| 395 | `EmacsThread' were valid for graphics calls, but this is | ||
| 396 | no longer true now that Lisp threads can be attached to | ||
| 397 | the JVM. */ | ||
| 398 | || (Thread.currentThread () != SERVICE.mainThread)) | ||
| 388 | return; | 399 | return; |
| 389 | 400 | ||
| 390 | throw new RuntimeException ("Emacs thread function" | 401 | throw new RuntimeException ("Emacs thread function" |