After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 534979 - GtkImageMenuItem is a bin but has two children.
GtkImageMenuItem is a bin but has two children.
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: GtkMenu
unspecified
Other All
: Normal minor
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2008-05-26 20:02 UTC by rainwoodman
Modified: 2008-11-02 16:16 UTC
See Also:
GNOME target: ---
GNOME version: Unversioned Enhancement


Attachments
patch gtkimagemenuitem.c (347 bytes, patch)
2008-05-26 20:03 UTC, rainwoodman
committed Details | Review

Description rainwoodman 2008-05-26 20:02:24 UTC
Please describe the problem:
GtkImageMenuItem is a GtkBin, but gtk_container_foreach on a GtkImageMenuItem iterates over the GtkImage.

The image should be an internal child; as it is already exposed in "image" property.

Steps to reproduce:

static void _callback(GtkWidget * widget, gpointer data){
   g_message("Child widget: type = %s", G_OBJECT_TYPE_NAME(widget));
}

int main(int argc, char* argv){
gtk_init(&argc, &argv);
{
GtkImageMenuItem * item = gtk_image_menu_item_new_from_stock(GTK_STOCK_OK,NULL);

gtk_container_foreach(item, _callback, NULL);
}
return NULL;
}


Actual results:
GtkImage
GtkAccelLabel


Expected results:
GtkAccelLabel

Does this happen every time?
Yes

Other information:
A patch follows
Comment 1 rainwoodman 2008-05-26 20:03:42 UTC
Created attachment 111569 [details] [review]
patch gtkimagemenuitem.c

The image should be an internal child.
Comment 2 Björn Lindqvist 2008-08-04 00:10:34 UTC
Looks good to me. Ping?
Comment 3 rainwoodman 2008-08-04 02:43:46 UTC
Echo from the reporter.
Comment 4 Björn Lindqvist 2008-08-04 21:37:40 UTC
Thanks for the patch. Committed in r20985:

2008-08-04  Björn Lindqvist  <bjourne@gmail.com>

	Bug 534979 – GtkImageMenuItem is a bin but has two children.

	* gtk/gtkimagemenuitem.c (gtk_image_menu_item_forall): Do not
	include the image widget when iterating over non-internal
	children. Patch by rainwoodman.
Comment 5 Matthias Clasen 2008-11-02 04:17:16 UTC
This is patch is wrong.

It breaks the contract of gtk_container_forall:

* Invokes @callback on each child of @container, including children
* that are considered "internal"

There is a ton of code out there that assumes that one can use forall recursively to iterate over all widgets in a hierarchy.
Comment 6 Matthias Clasen 2008-11-02 04:31:35 UTC
Actually, nevermind, you do the include_internals thing
Comment 7 rainwoodman 2008-11-02 16:16:17 UTC
yes I did.