emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master e5cb268b2cf: Fix DEBUG_THREADS in the Android port


From: Po Lu
Subject: master e5cb268b2cf: Fix DEBUG_THREADS in the Android port
Date: Wed, 7 Feb 2024 08:09:53 -0500 (EST)

branch: master
commit e5cb268b2cf612492dfaf39d28f43357710003a6
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>

    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.
---
 java/org/gnu/emacs/EmacsService.java | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

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
      been created yet.  */
   private EmacsSafThread storageThread;
 
+  /* The Thread object representing the Android user interface
+     thread.  */
+  private Thread mainThread;
+
   static
   {
     servicingQuery = new AtomicInteger ();
@@ -236,6 +240,7 @@ public final class EmacsService extends Service
                          / metrics.density)
                         * pixelDensityX);
     resolver = getContentResolver ();
+    mainThread = Thread.currentThread ();
 
     /* If the density used to compute the text size is lesser than
        160, there's likely a bug with display density computation.
@@ -384,7 +389,13 @@ public final class EmacsService extends Service
   {
     if (DEBUG_THREADS)
       {
-       if (Thread.currentThread () instanceof EmacsThread)
+       /* When SERVICE is NULL, Emacs is being executed non-interactively.  */
+       if (SERVICE == null
+           /* It was previously assumed that only instances of
+              `EmacsThread' were valid for graphics calls, but this is
+              no longer true now that Lisp threads can be attached to
+              the JVM.  */
+           || (Thread.currentThread () != SERVICE.mainThread))
          return;
 
        throw new RuntimeException ("Emacs thread function"



reply via email to

[Prev in Thread] Current Thread [Next in Thread]