Re: Help on compiling notebook example



Hi Krzesimir and all,

Thanks for the help.

Now I made changes to my code as in .h file:
  class CGraphView : public Gtk::ScrolledWindow
  {
    Gtk::Label _pageTabLabel;
    //    static Gtk::Label _pageMenuLabel;
    Gtk::Label _pageMenuLabel;
  };
So the static has been changed to a member object.

In my .cpp file, I am using the following to add a page to my Gtk::Notebook:
  ... ...
  Gtk::Adjustment h_adj(0, 0, 1000);
  Gtk::Adjustment v_adj(0, 0, 1000);
  CGraphView * graph_view = new CGraphView(h_adj, v_adj, label);

  append_page(* graph_view, graph_view->_pageTabLabel, /*CGraphView::*/graph_view->_pageMenuLabel);
  ... ...

After I compiled the code and running, I tried to add a page - everything seems to work. But when I exit the program, I got the following warning:
    (utool:4351): GLib-GObject-WARNING **: gsignal.c:2390: instance `0x90806c8' has no handler with id `611'
And it seems one such warning for each page I've added.

My questions are:
1. What caused this warning and how do I fix it?
2. The Gtk::Notebook function I used to append a page is:
         int append_page (Widget& child, Widget& tab_label, Widget& menu_label)
    Here is from the gtkmm reference manual:

Appends a page to notebook, specifying the widget to use as the label in the popup menu.

Parameters:
childThe Gtk::Widget to use as the contents of the page.
tab_labelThe Gtk::Widget to be used as the label for the page.
menu_labelThe widget to use as a label for the page-switch menu.
    What is the purpose of menu_label? Is it visible somehow and when? What is the page-switch menu?

Any examples or link are welcome.

Thanks,
Chun

On Fri, Dec 17, 2010 at 11:54 PM, Krzesimir Nowak <qdlacz gmail com> wrote:
On Thu, 2010-12-16 at 23:49 -0800, Chun Yang wrote:
> Hi All,
>
> Sorry again. I kept pressing some button I was not aware and sent this
> email again.
>
> Here are my question:
> 1. What are the warning (highlighted in green) after I started to run
> the program?
> 2. What is the reason for me to get all the warnings (in blue) and the
> error (in red)? I can not continue the program due to the error.
> 3. How do I fix the error?
>

I see 3 questions, not 2. :) And one thing - especially for you I
switched my mail view to HTML instead of plaintext, but still all the
text is black on white. But probably I can guess what is what.


1. Some prelink + gdb issues, probably nothing you should be worrying
about now. If you want some reading, here is the link:
http://www.cygwin.com/ml/gdb-patches/2006-02/msg00164.html

2. The warnings are displayed because when CGraphView::_pageMenuLabel is
constructed, a GType system is not yet initialized. And it is not
initialized because static members are constructed before main() is
started.

3. Seems that widgets cannot be static members. So a fix could be making
it a nonstatic member of the class. Or, if you want it to be static
anyway, make it a pointer. And in constructor of CGraphView you could
check if this pointer is zero. If so - create a button, otherwise do
nothing. But don't forget to delete it at some point or you'll get a
memory leak.
> Thanks,
> Chun
>

Krzesimir

> On Thu, Dec 16, 2010 at 11:45 PM, Chun Yang <achunyang2010 gmail com>
> wrote:
>
>         Sorry I pressed the wrong button.
>
>         Let me continue.
>
>         I have the following code:
>
>         In my .h file, I have:
>           class CGraphView : public Gtk::ScrolledWindow
>           {
>             ..... .....
>             static Gtk::Button _pageMenuLabel;
>           };
>
>         In my .cpp I have:
>
>         Gtk::Button CGraphView::_pageMenuLabel("X");
>
>
>         I planned to use _pageMenuLabel as an page to Gtk::Notebook as
>         in:
>           append_page(* graph_view, graph_view->_pageTabLabel,
>         CGraphView::_pageMenuLabel);
>         After I compile and  run gdb with breakpoint set on the above
>         line, I got the following.
>
>         I got two questions to asked
>
>
>
>         (gdb) r
>         Starting program: /proj/utool/gui/build/utool
>         warning: .dynamic section for
>         "/usr/lib/libpangocairo-1.0.so.0" is not at the expected
>         address
>         warning: difference appears to be caused by prelink, adjusting
>         expectations
>         warning: .dynamic section for "/usr/lib/libpango-1.0.so.0" is
>         not at the expected address
>         warning: difference appears to be caused by prelink, adjusting
>         expectations
>         warning: .dynamic section for "/usr/lib/libX11.so.6" is not at
>         the expected address
>         warning: difference appears to be caused by prelink, adjusting
>         expectations
>         warning: .dynamic section for "/lib/libz.so.1" is not at the
>         expected address
>         warning: difference appears to be caused by prelink, adjusting
>         expectations
>         [Thread debugging using libthread_db enabled]
>
>         Breakpoint 2, __static_initialization_and_destruction_0
>         (__initialize_p=1, __priority=65535) at src/CGraphView.cpp:6
>         (gdb) n
>
>         (process:3431): GLib-GObject-CRITICAL **: gtype.c:2706: You
>         forgot to call g_type_init()
>
>         (process:3431): GLib-CRITICAL **: g_once_init_leave: assertion
>         `initialization_value != 0' failed
>
>         (process:3431): GLib-GObject-CRITICAL **: gtype.c:2706: You
>         forgot to call g_type_init()
>
>         (process:3431): GLib-GObject-CRITICAL **: gtype.c:2706: You
>         forgot to call g_type_init()
>
>         (process:3431): GLib-GObject-CRITICAL **: gtype.c:2706: You
>         forgot to call g_type_init()
>
>         (process:3431): GLib-GObject-CRITICAL **:
>         g_type_add_interface_static: assertion
>         `G_TYPE_IS_INSTANTIATABLE (instance_type)' failed
>
>         (process:3431): GLib-GObject-CRITICAL **: gtype.c:2706: You
>         forgot to call g_type_init()
>
>         (process:3431): GLib-GObject-CRITICAL **:
>         g_type_add_interface_static: assertion
>         `G_TYPE_IS_INSTANTIATABLE (instance_type)' failed
>
>         (process:3431): GLib-GObject-CRITICAL **: gtype.c:2706: You
>         forgot to call g_type_init()
>
>         (process:3431): GLib-GObject-CRITICAL **: gtype.c:2706: You
>         forgot to call g_type_init()
>
>         (process:3431): GLib-GObject-CRITICAL **:
>         g_type_add_interface_static: assertion
>         `G_TYPE_IS_INSTANTIATABLE (instance_type)' failed
>
>         (process:3431): GLib-GObject-CRITICAL **: gtype.c:2706: You
>         forgot to call g_type_init()
>
>         (process:3431): GLib-CRITICAL **: g_once_init_leave: assertion
>         `initialization_value != 0' failed
>
>         (process:3431): GLib-GObject-CRITICAL **: gtype.c:2706: You
>         forgot to call g_type_init()
>
>         (process:3431): GLib-GObject-CRITICAL **: gtype.c:2706: You
>         forgot to call g_type_init()
>
>         (process:3431): GLib-GObject-CRITICAL **:
>         g_type_add_interface_static: assertion
>         `G_TYPE_IS_INSTANTIATABLE (instance_type)' failed
>
>         (process:3431): GLib-CRITICAL **: g_once_init_leave: assertion
>         `initialization_value != 0' failed
>
>         (process:3431): GLib-GObject-WARNING **: cannot retrieve class
>         for invalid (unclassed) type `<invalid>'
>
>         (process:3431): GLib-GObject-CRITICAL **:
>         g_object_class_find_property: assertion `G_IS_OBJECT_CLASS
>         (class)' failed
>
>         (process:3431): GLib-GObject-CRITICAL **: gtype.c:3270: You
>         forgot to call g_type_init()
>
>         (process:3431): glibmm-WARNING **:
>         Glib::ConstructParams::ConstructParams(): object class
>         "(null)" has no property named "label"
>
>         (process:3431): GLib-GObject-CRITICAL **: g_type_class_unref:
>         assertion `g_class != NULL' failed
>
>         (process:3431): GLib-GObject-CRITICAL **: g_object_newv:
>         assertion `G_TYPE_IS_OBJECT (object_type)' failed
>
>         (process:3431): GLib-GObject-CRITICAL **: gtype.c:2706: You
>         forgot to call g_type_init()
>
>         (process:3431): glibmm-CRITICAL **:
>         Glib::Interface::Interface(const Glib::Interface_Class&):
>         assertion `gobject_ != 0' failed
>         (gdb)
>
> _______________________________________________
> gtkmm-list mailing list
> gtkmm-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtkmm-list





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]