From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: =?iso-8859-1?Q?Jan_Dj=E4rv?= Newsgroups: gmane.emacs.devel Subject: Re: Using glib's g_file_monitor_file and g_file_monitor_directory Date: Fri, 7 Jun 2013 12:53:51 +0200 Message-ID: <74C82774-F83F-46E4-9865-C2649FD481D0@swipnet.se> References: <87zjxxn6th.fsf@gmx.de> <83bo7ozc0q.fsf@gnu.org> <87zjxxn6th.fsf@gmx.de> <87hajqpjn1.fsf@gmx.de> <8738t7pewc.fsf@gmx.de> <83fvx7p1h4.fsf@gnu.org> <877gihc3qm.fsf@gmx.de> <83mwrd6c54.fsf@gnu.org> <87obbtaie8.fsf@gmx.de> <83bo7ozc0q.fsf@gnu.org> <87bo7ngwj8.fsf@gmx.de> <83mwr7xm7b.fsf@gnu.org> <3d7gibw6sa.fsf@fencepost.gnu.org> <83bo7nxim8.fsf@gnu.org> <834ndfxh0g.fsf@gnu.org> <2cobbnt897.fsf@fencepost.gnu.org> <87ip1vq8wy.fsf@gmx.de> <51AD8485.90201@cs.ucla.edu> <878v2od70c.fsf@gmx.de> <2AEE82C8-0C4C-4CF8-B44B-FF2E657B03CD@swipnet.se> <87hahba47a.fsf@gmx.de> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 (Mac OS X Mail 6.3 \(1503\)) Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1370602444 18320 80.91.229.3 (7 Jun 2013 10:54:04 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 7 Jun 2013 10:54:04 +0000 (UTC) Cc: Paul Eggert , emacs-devel@gnu.org To: Michael Albinus Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Jun 07 12:54:04 2013 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UkuJ1-00064U-U5 for ged-emacs-devel@m.gmane.org; Fri, 07 Jun 2013 12:54:04 +0200 Original-Received: from localhost ([::1]:41394 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UkuJ1-0001c9-9D for ged-emacs-devel@m.gmane.org; Fri, 07 Jun 2013 06:54:03 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43037) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UkuIu-0001bf-Lk for emacs-devel@gnu.org; Fri, 07 Jun 2013 06:54:00 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UkuIq-0008VJ-Fy for emacs-devel@gnu.org; Fri, 07 Jun 2013 06:53:56 -0400 Original-Received: from mailout.melmac.se ([62.20.26.67]:47525) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UkuIq-0008U2-2U for emacs-devel@gnu.org; Fri, 07 Jun 2013 06:53:52 -0400 Original-Received: from mail01.melmac.se (mail01.melmac.se [62.20.26.80]) by mailout.melmac.se (Postfix) with ESMTP id 8F74295C3 for ; Fri, 7 Jun 2013 12:53:46 +0200 (CEST) Original-Received: (qmail 11412 invoked by uid 89); 7 Jun 2013 10:53:46 -0000 Original-Received: from h-46-59-42-57.na.cust.bahnhof.se (HELO coolsville.localdomain) (boel.djarv@bdtv.se@46.59.42.57) by mail01.melmac.se with ESMTPA; 7 Jun 2013 10:53:46 -0000 Original-Received: from [172.20.199.13] (unknown [172.20.199.13]) by coolsville.localdomain (Postfix) with ESMTPSA id 2EC431A1BCD; Fri, 7 Jun 2013 10:53:46 +0000 (UTC) In-Reply-To: <87hahba47a.fsf@gmx.de> X-Mailer: Apple Mail (2.1503) X-detected-operating-system: by eggs.gnu.org: Solaris 10 X-Received-From: 62.20.26.67 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:160203 Archived-At: Hello. 6 jun 2013 kl. 13:06 skrev Michael Albinus : > Jan Dj=E4rv writes: >=20 >> Hello. >=20 > Hi, >=20 >>> 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. >>>=20 >>> Likely, we must move this code out of gtkutil.c and gfilenotify.c. = Jan? >>=20 >>=20 >> 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. >=20 > 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. >=20 > 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=3D9754), but you have to = remove it for -nw. =3D=3D=3D 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; =20 - if (! (window_system_available (NULL) - && g_main_context_pending (context =3D g_main_context_default = ()))) - return pselect (fds_lim, rfds, wfds, efds, timeout, sigmask); - if (rfds) all_rfds =3D *rfds; else FD_ZERO (&all_rfds); if (wfds) all_wfds =3D *wfds; else FD_ZERO (&all_wfds); =20 + context =3D g_main_context_default (); n_gfds =3D g_main_context_query (context, G_PRIORITY_LOW, = &tmo_in_millisec, gfds, gfds_size); if (gfds_size < n_gfds) Jan D.