emacs-devel
[Top][All Lists]
Advanced

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

Re: Using glib's g_file_monitor_file and g_file_monitor_directory


From: Jan Djärv
Subject: Re: Using glib's g_file_monitor_file and g_file_monitor_directory
Date: Fri, 7 Jun 2013 12:53:51 +0200

Hello.

6 jun 2013 kl. 13:06 skrev Michael Albinus <address@hidden>:

> Jan Djärv <address@hidden> writes:
> 
>> Hello.
> 
> Hi,
> 
>>> I've committed a patch to the trunk which prevents this crash. However,
>>> if you call "emacs -nw", you won't get any notification. I suppose we
>>> need an generalized g_main_loop integration, synchronized with the code
>>> in gtkutil.c.
>>> 
>>> Likely, we must move this code out of gtkutil.c and gfilenotify.c. Jan?
>> 
>> 
>> Which code?  The glib event loop integration is in xgselect.c.  I
>> think it is called in the -nw case also.  It is only dependent on
>> HAVE_GLIB.
>> The Gtk+ event loop integration is in xterm.c, it is a separate thing.
> 
> I was thinking about the g_main_loop_run and g_main_loop_quit calls in
> gtkutil.c. Reading the code in more detail, it looks like the calls have
> a local scope only, so we don't need to sync.

Right, it is only used when popping up a dialog.

> 
> gfilenotify.c needs a running glib event loop. If Emacs is called with
> the "-nw" flag there is no such event loop; it must be started in a new
> thread by gfilenotify.c I believe.


No need for that, you can just apply the patch below to xgselect.c and you will 
have a glib handling events for -nw.  The first call to g_main_context_pending 
does not return true for file monitoring events, why I don't know.  I think the 
window check was added for bug 9754 
(http://debbugs.gnu.org/cgi/bugreport.cgi?bug=9754), but you have to remove it 
for -nw.

=== modified file 'src/xgselect.c'
--- src/xgselect.c      2013-06-03 18:47:35 +0000
+++ src/xgselect.c      2013-06-07 10:40:37 +0000
@@ -44,15 +44,12 @@
   int i, nfds, tmo_in_millisec;
   USE_SAFE_ALLOCA;
 
-  if (! (window_system_available (NULL)
-        && g_main_context_pending (context = g_main_context_default ())))
-    return pselect (fds_lim, rfds, wfds, efds, timeout, sigmask);
-
   if (rfds) all_rfds = *rfds;
   else FD_ZERO (&all_rfds);
   if (wfds) all_wfds = *wfds;
   else FD_ZERO (&all_wfds);
 
+  context = g_main_context_default ();
   n_gfds = g_main_context_query (context, G_PRIORITY_LOW, &tmo_in_millisec,
                                 gfds, gfds_size);
   if (gfds_size < n_gfds)


        Jan D.




reply via email to

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