Subject: bug#25851: 25.2; GTK warning when starting Emacs when desktop file has more than one frame

From: [email-masked] (N. Jackson)
Date: Thu, 23 Feb 2017 21:33:33 -0500

At 18:24 +0200 on Thursday 2017-02-23, Eli Zaretskii wrote:
>
> Thanks. It might be enough if you run Emacs under a debugger
> with a breakpoint in the GTK function which emits this warning,
> then show us the backtrace from that function. That should point
> to the code that gets executed when it probably shouldn't.

This warning is emitted by line 11414 of
`gtk_window_parse_geometry' in gtkwindow.c in the gtk+-3.22.8
sources. The code looks like this:

  gboolean
  gtk_window_parse_geometry (GtkWindow   *window,
                             const gchar *geometry)
  {
    gint result, x = 0, y = 0;
    guint w, h;
    GtkWidget *child;
    GdkGravity grav;
    gboolean size_set, pos_set;
    GdkScreen *screen;

    g_return_val_if_fail (GTK_IS_WINDOW (window), FALSE);
    g_return_val_if_fail (geometry != NULL, FALSE);

    child = gtk_bin_get_child (GTK_BIN (window));
    if (!child || !gtk_widget_get_visible (child))
      g_warning ("gtk_window_parse_geometry() called on a window with no "
                 "visible children; the window should be set up before "
                 "gtk_window_parse_geometry() is called.");
  ...

There is a note in the commentary preceding the function that
echos the warning message:

   * Note that for gtk_window_parse_geometry() to work as
   * expected, it has to be called when the window has its “final”
   * size, i.e. after calling gtk_widget_show_all() on the
   * contents and gtk_window_set_geometry_hints() on the window.

The only place in the Emacs sources where I see
`gtk_window_parse_geometry' being called is in `xg_set_geometry'
at line 802 of gtkutil.c where the code looks like this:

  /* Silence warning about visible children.  */
  id = g_log_set_handler ("Gtk", G_LOG_LEVEL_WARNING | G_LOG_FLAG_FATAL
                          | G_LOG_FLAG_RECURSION, my_log_handler, NULL);

  if (!gtk_window_parse_geometry (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)),
                                  geom_str))
    fprintf (stderr, "Failed to parse: '%s'\n", geom_str);

So it looks like a previous attempt to avoid the warning message
is no longer successful.

As requested, here is the backtrace when the warning is emitted:

#0  0x00000000005657ee in xg_set_geometry (f=0x10aa9f0) at gtkutil.c:806
#1  0x00000000005667cf in xg_create_frame_widgets (f=0x10aa9f0) at gtkutil.c:1216
#2  0x000000000054fc76 in x_window (f=0x10aa9f0) at xfns.c:2727
#3  0x0000000000551d79 in Fx_create_frame (parms=57485619) at xfns.c:3484
#4  0x000000000062c40d in Ffuncall (nargs=2, args=0x7fffffff8ec8) at eval.c:2699
#5  0x000000000067664b in exec_byte_code (bytestr=10582108, vector=10582141, maxdepth=18, args_template=0, nargs=0, args=0x0) at bytecode.c:880
#6  0x000000000062d16f in funcall_lambda (fun=10582045, nargs=1, arg_vector=0xa1787d <pure+531805>) at eval.c:2929
#7  0x000000000062c68f in Ffuncall (nargs=2, args=0x7fffffff9400) at eval.c:2748
#8  0x000000000067664b in exec_byte_code (bytestr=23626564, vector=14868461, maxdepth=14, args_template=1030, nargs=1, args=0x7fffffff9a80) at bytecode.c:880
#9  0x000000000062cd50 in funcall_lambda (fun=22350725, nargs=1, arg_vector=0x7fffffff9a78) at eval.c:2863
#10 0x000000000062c68f in Ffuncall (nargs=2, args=0x7fffffff9a70) at eval.c:2748
#11 0x000000000062b382 in Fapply (nargs=2, args=0x7fffffff9a70) at eval.c:2284
#12 0x000000000062c2d5 in Ffuncall (nargs=3, args=0x7fffffff9a68) at eval.c:2679
#13 0x000000000067664b in exec_byte_code (bytestr=23644068, vector=21208917, maxdepth=62, args_template=514, nargs=1, args=0x7fffffffa010) at bytecode.c:880
#14 0x000000000062cd50 in funcall_lambda (fun=19980181, nargs=1, arg_vector=0x7fffffffa010) at eval.c:2863
#15 0x000000000062c68f in Ffuncall (nargs=2, args=0x7fffffffa008) at eval.c:2748
#16 0x000000000067664b in exec_byte_code (bytestr=11218740, vector=11218773, maxdepth=54, args_template=1026, nargs=1, args=0x7fffffffa568) at bytecode.c:880
#17 0x000000000062cd50 in funcall_lambda (fun=11218685, nargs=1, arg_vector=0x7fffffffa560) at eval.c:2863
#18 0x000000000062c68f in Ffuncall (nargs=2, args=0x7fffffffa558) at eval.c:2748
#19 0x000000000067664b in exec_byte_code (bytestr=11217524, vector=11217557, maxdepth=22, args_template=2054, nargs=2, args=0x7fffffffaad8) at bytecode.c:880
#20 0x000000000062cd50 in funcall_lambda (fun=11217469, nargs=2, arg_vector=0x7fffffffaac8) at eval.c:2863
#21 0x000000000062c68f in Ffuncall (nargs=3, args=0x7fffffffaac0) at eval.c:2748
#22 0x000000000067664b in exec_byte_code (bytestr=29837764, vector=20327621, maxdepth=70, args_template=4114, nargs=4, args=0x7fffffffb0e0) at bytecode.c:880
#23 0x000000000062cd50 in funcall_lambda (fun=25722397, nargs=4, arg_vector=0x7fffffffb0c0) at eval.c:2863
#24 0x000000000062c68f in Ffuncall (nargs=5, args=0x7fffffffb0b8) at eval.c:2748
#25 0x000000000067664b in exec_byte_code (bytestr=18636228, vector=22137909, maxdepth=122, args_template=1542, nargs=9, args=0x7fffffffb618) at bytecode.c:880
#26 0x000000000062cd50 in funcall_lambda (fun=21872565, nargs=9, arg_vector=0x7fffffffb610) at eval.c:2863
#27 0x000000000062c68f in Ffuncall (nargs=10, args=0x7fffffffb608) at eval.c:2748
#28 0x000000000067664b in exec_byte_code (bytestr=19811332, vector=21941397, maxdepth=42, args_template=2, nargs=0, args=0x7fffffffbba8) at bytecode.c:880
#29 0x000000000062cd50 in funcall_lambda (fun=21941501, nargs=0, arg_vector=0x7fffffffbba8) at eval.c:2863
#30 0x000000000062c68f in Ffuncall (nargs=1, args=0x7fffffffbba0) at eval.c:2748
#31 0x000000000067664b in exec_byte_code (bytestr=19804484, vector=21941597, maxdepth=66, args_template=1026, nargs=0, args=0x7fffffffc100) at bytecode.c:880
#32 0x000000000062cd50 in funcall_lambda (fun=20574093, nargs=0, arg_vector=0x7fffffffc100) at eval.c:2863
#33 0x000000000062c68f in Ffuncall (nargs=1, args=0x7fffffffc0f8) at eval.c:2748
#34 0x000000000067664b in exec_byte_code (bytestr=19384580, vector=18492589, maxdepth=18, args_template=2, nargs=0, args=0x7fffffffc6d0) at bytecode.c:880
#35 0x000000000062cd50 in funcall_lambda (fun=21708709, nargs=0, arg_vector=0x7fffffffc6d0) at eval.c:2863
#36 0x000000000062c68f in Ffuncall (nargs=1, args=0x7fffffffc6c8) at eval.c:2748
#37 0x000000000062b780 in funcall_nil (nargs=1, args=0x7fffffffc6c8) at eval.c:2338
#38 0x000000000062bc60 in run_hook_with_args (nargs=1, args=0x7fffffffc6c8, funcall=0x62b75d <funcall_nil>) at eval.c:2515
#39 0x000000000062b807 in Frun_hook_with_args (nargs=1, args=0x7fffffffc6c8) at eval.c:2380
#40 0x000000000062bcea in run_hook (hook=21708709) at eval.c:2528
#41 0x000000000062b7c4 in Frun_hooks (nargs=2, args=0x7fffffffc7d0) at eval.c:2362
#42 0x000000000062c2d5 in Ffuncall (nargs=3, args=0x7fffffffc7c8) at eval.c:2679
#43 0x000000000067664b in exec_byte_code (bytestr=11253852, vector=11253885, maxdepth=86, args_template=2, nargs=0, args=0x7fffffffcd88) at bytecode.c:880
#44 0x000000000062cd50 in funcall_lambda (fun=11253805, nargs=0, arg_vector=0x7fffffffcd88) at eval.c:2863
#45 0x000000000062c68f in Ffuncall (nargs=1, args=0x7fffffffcd80) at eval.c:2748
#46 0x000000000067664b in exec_byte_code (bytestr=11249860, vector=11249893, maxdepth=50, args_template=2, nargs=0, args=0x7fffffffd230) at bytecode.c:880
#47 0x000000000062cd50 in funcall_lambda (fun=11249813, nargs=0, arg_vector=0x7fffffffd230) at eval.c:2863
#48 0x000000000062c9f7 in apply_lambda (fun=11249813, args=0, count=4) at eval.c:2800
#49 0x000000000062b026 in eval_sub (form=21000067) at eval.c:2217
#50 0x000000000062a512 in Feval (form=21000067, lexical=0) at eval.c:1994
#51 0x0000000000581380 in top_level_2 () at keyboard.c:1121
#52 0x0000000000628baf in internal_condition_case (bfun=0x58135d <top_level_2>, handlers=19104, hfun=0x580d8a <cmd_error>) at eval.c:1315
#53 0x00000000005813c1 in top_level_1 (ignore=0) at keyboard.c:1129
#54 0x000000000062817e in internal_catch (tag=45936, func=0x581382 <top_level_1>, arg=0) at eval.c:1080
#55 0x00000000005812b5 in command_loop () at keyboard.c:1090
#56 0x000000000058087a in recursive_edit_1 () at keyboard.c:697
#57 0x0000000000580a7a in Frecursive_edit () at keyboard.c:768
#58 0x000000000057e832 in main (argc=1, argv=0x7fffffffd758) at emacs.c:1629

Lisp Backtrace:
"x-create-frame" (0xffff8ed0)
"x-create-frame-with-faces" (0xffff9408)
0x1550b80 PVEC_COMPILED
"apply" (0xffff9a70)
"frame-creation-function" (0xffffa010)
"make-frame" (0xffffa560)
"make-frame-on-display" (0xffffaac8)
"frameset--restore-frame" (0xffffb0c0)
"frameset-restore" (0xffffb610)
"desktop-restore-frameset" (0xffffbba8)
"desktop-read" (0xffffc100)
0x14b3fa0 PVEC_COMPILED
"run-hooks" (0xffffc7d0)
"command-line" (0xffffcd88)
"normal-top-level" (0xffffd230)

I hopes this helps and please let me know if I can provide further
information. Thanks.

N.