Re: Invalid cast from `GtkButton' to `GtkCombo'


Subject: Re: Invalid cast from `GtkButton' to `GtkCombo'
From: Martin Sevior (msevior@mccubbin.ph.unimelb.edu.au)
Date: Mon Jan 28 2002 - 14:57:57 CST


I have this fixed on my hard disk. Will commit soon.

Martin

On Mon, 28 Jan 2002, Pavel Roskin wrote:

> Hello!
>
> The CVS version of AbiWord reports a warning at runtime:
>
> Gtk-WARNING **: invalid cast from `GtkButton' to `GtkCombo'
>
> If I run the debugging version of AbiWord with --g-fatal-warnings, it
> shows where it happens:
>
> #0 0x403838d1 in __kill () from /lib/libc.so.6
> #1 0x4038364d in raise (sig=6) at ../sysdeps/posix/raise.c:27
> #2 0x40384cb8 in abort () at ../sysdeps/generic/abort.c:88
> #3 0x401cf6ce in g_logv (log_domain=0x401587c6 "Gtk",
> log_level=G_LOG_LEVEL_WARNING,
> format=0x401744a0 "invalid cast from `%s' to `%s'", args1=0xbffff58c)
> at gmessages.c:391
> #4 0x401cf76f in g_log (log_domain=0x401587c6 "Gtk",
> log_level=G_LOG_LEVEL_WARNING,
> format=0x401744a0 "invalid cast from `%s' to `%s'") at gmessages.c:408
> #5 0x40140d14 in gtk_type_check_object_cast (type_object=0x856da70,
> cast_type=45845)
> at gtktypeutils.c:642
> #6 0x08125115 in EV_UnixToolbar::refreshToolbar (this=0x856de68,
> pView=0x85b2868, mask=65535)
> at ev_UnixToolbar.cpp:925
> #7 0x08124be7 in EV_UnixToolbar::bindListenerToView (this=0x856de68,
> pView=0x85b2868)
> at ev_UnixToolbar.cpp:798
> #8 0x080d7a2a in AP_UnixFrame::_showDocument (this=0x8512a18, iZoom=100)
> at ap_UnixFrame.cpp:179
> #9 0x080d8ed1 in AP_UnixFrame::loadDocument (this=0x8512a18,
> szFilename=0x0, ieft=0,
> createNew=false) at ap_UnixFrame.cpp:624
> #10 0x080d8f5f in AP_UnixFrame::loadDocument (this=0x8512a18,
> szFilename=0x0, ieft=0)
> at ap_UnixFrame.cpp:629
> #11 0x080d7126 in AP_UnixApp::parseCommandLine (this=0x849e288) at
> ap_UnixApp.cpp:1582
> #12 0x080d6763 in AP_UnixApp::main (szAppName=0x834117b "AbiWord", argc=3,
> argv=0xbffff994)
> at ap_UnixApp.cpp:1337
> #13 0x080d363e in main (argc=3, argv=0xbffff994) at UnixMain.cpp:32
> #14 0x40371306 in __libc_start_main (main=0x80d35e0 <main>, argc=3,
> ubp_av=0xbffff994,
> init=0x80d0fac <_init>, fini=0x8341130 <_fini>, rtld_fini=0x4000d2dc
> <_dl_fini>,
> stack_end=0xbffff98c) at ../sysdeps/generic/libc-start.c:129
>
> (gdb) up 6
> #6 0x08125115 in EV_UnixToolbar::refreshToolbar (this=0x856de68,
> pView=0x85b2868, mask=65535)
> at ev_UnixToolbar.cpp:925
> 925 GtkCombo * item =
> GTK_COMBO(wd->m_widget);
> (gdb) l
> 920 {
> 921 bool bGrayed =
> EV_TIS_ShouldBeGray(tis);
> 922
> 923 _wd * wd = (_wd *)
> m_vecToolbarWidgets.getNthItem(k);
> 924 UT_ASSERT(wd);
> 925 GtkCombo * item =
> GTK_COMBO(wd->m_widget);
> 926 UT_ASSERT(item);
> 927
> gtk_widget_set_sensitive(GTK_WIDGET(item), !bGrayed); // Disable/enable
> toolbar item
> 928 }
> 929 break;
>
> The folowing patch fixes the warning. It eliminates the intermediate step
> of converting the widget to GtkCombo. Of course, if you want checks that
> only certaing widgets can happen at this point, then a case statement
> should be used, like the one above in the same function.
>
> =========================================
> --- src/af/ev/unix/ev_UnixToolbar.cpp
> +++ src/af/ev/unix/ev_UnixToolbar.cpp
> @@ -922,9 +922,8 @@
>
> _wd * wd = (_wd *) m_vecToolbarWidgets.getNthItem(k);
> UT_ASSERT(wd);
> - GtkCombo * item = GTK_COMBO(wd->m_widget);
> - UT_ASSERT(item);
> - gtk_widget_set_sensitive(GTK_WIDGET(item), !bGrayed); // Disable/enable toolbar item
> + UT_ASSERT(wd->m_widget);
> + gtk_widget_set_sensitive(GTK_WIDGET(wd->m_widget), !bGrayed); // Disable/enable toolbar item
> }
> break;
>
> =========================================
>
> --
> Regards,
> Pavel Roskin
>
>
>



This archive was generated by hypermail 2b25 : Mon Jan 28 2002 - 14:58:18 CST