Subject: bug#20802: Segfault when showing non-GTK+ tooltip

From: martin rudalics <[email-masked]>
Date: Thu, 18 Jun 2015 18:48:29 +0200

> Do you agree that there's no need to decide whether we should free the
 > image cache while deleting a frame, and instead do that when we delete
 > a terminal?  If you agree, we should move the code that frees the
 > image cache there.

I do agree.

 > If, in addition, you are saying that we will sometimes delete a
 > terminal when it still has live frames,

frame.c has this very cryptic

     /* FIXME: Deleting the terminal crashes emacs because of a GTK
        bug.
        http://lists.gnu.org/archive/html/emacs-devel/2011-10/msg00363.html */

I doubt it's a Gtk bug.  It certainly is related to refcounts.

 > then we could simply count the
 > frames on a terminal instead of using a refcount.  Something like this
 > (we already have similar code in delete_frame):
 >
 >        count = 0;
 >        FOR_EACH_FRAME (tail, frame1)
 > 	if (FRAME_TERMINAL (XFRAME (frame)) == FRAME_TERMINAL (XFRAME (frame1)))
 > 	  count++;

Something like that.  In any case we should get rid of _all_ refcounts
for frames and displays.  If you came up with a patch for Windows I
could do the remaining platforms (I'm not very eager doing this from
scratch since I build without image support and there might be some
wrinkle where testing with image support would be safer).

martin