emacs-31 71df1ea6d07: Fix Fns_block_system_sleep to respect activity_id lifetime (bug#81577)

Alan Third <[email protected]>
Newsgroups gmane.emacs.diffs
Message-ID <[email protected]>
branch: emacs-31
commit 71df1ea6d0779041830d8c0f991e143cebd34943
Author: Stéphane Marks <[email protected]>
Commit: Alan Third <[email protected]>

    Fix Fns_block_system_sleep to respect activity_id lifetime (bug#81577)
    
    * src/nsfns.m (Fns_block_system_sleep): Move unblock_input after
    setting activity_id.
---
 src/nsfns.m | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/nsfns.m b/src/nsfns.m
index efe622782f7..148bbc7923a 100644
--- a/src/nsfns.m
+++ b/src/nsfns.m
@@ -3940,8 +3940,6 @@ or nil if the block fails.  */)
     activity_id = [[NSProcessInfo processInfo]
 			     beginActivityWithOptions: activity_options
 					       reason: reason];
-  unblock_input ();
-
   if (!sleep_block_map)
     sleep_block_map = [[NSMutableDictionary alloc] initWithCapacity: 25];
 
@@ -3949,10 +3947,14 @@ or nil if the block fails.  */)
     {
       [sleep_block_map setObject: activity_id
 			  forKey: [NSNumber numberWithInt: ++sleep_block_id]];
+      unblock_input ();
       return make_fixnum (sleep_block_id);
     }
   else
-    return Qnil;
+    {
+      unblock_input ();
+      return Qnil;
+    }
 }
 
 DEFUN ("ns-unblock-system-sleep",
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.