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 131566 - libglademm can't create a derived GtkOptionMenu
libglademm can't create a derived GtkOptionMenu
Status: RESOLVED NOTABUG
Product: libglademm
Classification: Other
Component: general
git master
Other Linux
: Normal normal
: ---
Assigned To: gtkmm-forge
gtkmm-forge
Depends on:
Blocks:
 
 
Reported: 2004-01-15 14:56 UTC by Roger Leigh
Modified: 2011-01-16 23:33 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Testcase for both plain Gtkmm and libglademm (3.88 KB, application/octet-stream)
2004-01-15 14:57 UTC, Roger Leigh
Details
gtkmm-131566-2.tar.bz2 (2.89 KB, application/x-compressed-tar)
2004-10-28 21:23 UTC, Roger Leigh
Details

Description Roger Leigh 2004-01-15 14:56:28 UTC
If I derive a new widget from GtkOptionMenu, I can't create it from a Glade
interface: a empty menu is created, and I see this error:

(gladeexamplewindow:8373): Gtk-CRITICAL **: file gtkmenu.c: line 865
(gtk_menu_popup): assertion `GTK_IS_MENU (menu)' failed
 
(gladeexamplewindow:8373): Gtk-CRITICAL **: file gtkmenu.c: line 1088
(gtk_menu_get_active): assertion `GTK_IS_MENU (menu)' failed

However, the widget /does/ contain a menu, since I can manipulate it from
within the C++ object.

I'll attach a test case.


Regards,
Roger
Comment 1 Roger Leigh 2004-01-15 14:57:41 UTC
Created attachment 23381 [details]
Testcase for both plain Gtkmm and libglademm
Comment 2 Murray Cumming 2004-01-20 18:37:58 UTC
I'm going to have to create a C example when I get around to this.
Feel free to do that for me.
Comment 3 Murray Cumming 2004-01-22 10:38:55 UTC
Is that attachment a tar.gz? Please mention the filename when attaching.
Comment 4 Roger Leigh 2004-03-17 16:42:46 UTC
I've been able to work around this problem by not deriving from
Gtk::OptionMenu or Gtk::MenuItem.  Instead, I've used SigC::bind to
call a method with an object as an argument, rather than storing the
object in a derived Gtk::MenuItem.

I've created a boost::lexical_cast<> workalike called

template<typename T>
std::string describe(const T& obj)

which converts the object into a textual description for use in the
optionmenu (it's specialised for each type).


How exactly should I write in a C testcase for this issue, given that
it only occurs when using C++ derived classes?

It's as though the set_menu method behaves differently depending on
wether you created the OptionMenu directly, or by libglademm
get_widget_derived.  The latter does have the menu (the item count is
correct), but it doesn't display them.

Thanks,
Roger
Comment 5 Murray Cumming 2004-03-30 11:05:39 UTC
Sorry, but this is not a simple-as-possible test case. If you provide a simple
test case then I will investigate, and probably fix, any bug.
Comment 6 Murray Cumming 2004-10-14 15:35:43 UTC
Is there any chance of us getting that test case?
Comment 7 Roger Leigh 2004-10-16 15:28:22 UTC
What should the C testcase do?  There's no libglade get_widget_derived()
equivalent, so I'm unsure what exactly you want.  I'll be happy to try writing
another testcase--but I need to know what it should do first.

Thanks,
Roger
Comment 8 Murray Cumming 2004-10-28 00:12:51 UTC
Nevermind about the C test case yet. We still don't have a simple C++ test case
from you.
Comment 9 Roger Leigh 2004-10-28 21:23:32 UTC
Created attachment 33181 [details]
gtkmm-131566-2.tar.bz2

This testcase is a simplified version of the original testcase.  I've
 - removed all the templated code
 - removed all unused cruft
 - commented the objectoptionmenu header

The objectoptionmenu.* files implement the classes ObjectOptionMenuItem
(derived from Gtk::MenuItem) and ObjectOptionMenu (derived from
Gtk::OptionMenu).

examplewindow.* is plain C++, and just creates a main window containing an
ObjectOptionMenu containing some ObjectOptionMenuItems.  This works perfectly.

gladeexamplewindow.* is exactly the same, but the ObjectOptionMenu is got from
a Glade::XML object with get_widget_derived.  This appears to work according to
the debugging messages (the contained Gtk::Menu does contain the correct number
of items and the current selection is correct), but it shows up empty with
warnings:

OptionMenu::on_changed()
    There are 6 items
    Currently selected: 1
OptionMenu::on_changed()
    There are 6 items
    Currently selected: 5

(gladeexamplewindow:5036): Gtk-CRITICAL **: file gtkmenu.c: line 1235
(gtk_menu_popup): assertion `GTK_IS_MENU (menu)' failed

(gladeexamplewindow:5036): Gtk-CRITICAL **: file gtkmenu.c: line 1470
(gtk_menu_get_active): assertion `GTK_IS_MENU (menu)' failed


Hopefully this is a good bit simpler, but I don't think I can make it much
simpler without losing the purpose of what I'm trying to do.


Regards,
Roger
Comment 10 Murray Cumming 2004-10-29 09:44:09 UTC
In your constructor

ObjectOptionMenu::ObjectOptionMenu(BaseObjectType* cobject,
				   const Glib::RefPtr<Gnome::Glade::Xml>& xml_interface):
  m_menu()
{}

You do not call the base class constructor.

This is explained here:
http://www.gtkmm.org/docs/gtkmm-2.4/docs/tutorial/html/ch19s03.html

Please reopen the bug if this does not fix the problem.
Comment 11 Murray Cumming 2004-10-29 09:44:54 UTC
Also, I suggest that you use warnings as errors. This would have caught the
unused cobject parameter.
Comment 12 Roger Leigh 2004-10-29 13:04:59 UTC
That does indeed fix the problem, thanks.

I thought it looked funny, but I couldn't for the life of me see what it
was--and I've written quite a few derived widgets with those constructors in. 
Sorry for being a such a lamer!
Comment 13 Murray Cumming 2004-10-30 20:57:45 UTC
No problem. That's why I prod people to make test cases.