Re: [gtk-list] Re: Gtk--: Tracking down clobbered pointers and mysterious crashes





> ->I'm experiencing 2 mysterious crashes in my Gtk-- program
> ->which I can't figure out and which I'm guessing to be some
> ->kind of pointer gone astray. What I'm wondering is this:
> ->
> ->1) Does anybody have any suggestions for some (software)
> ->tools which might aid in discovering these obsucre bugs?
>
>    Well... gdb does it right, no ? [I'm so impatient
>    to see your response to this stupid answer... :)]

Usually it does but in this case it doesn't. The behaviour
I'm seeing is that a pointer seems to break without real
cause ... I tracked a previous similar bug to a bad pointer
initialization in another section of the program ... the thing
that gets me is that these errors only show up if I use themes ...
I fully accept the concept that my program contains bugs,
but I've never first hand experienced the kind of memory
corruption I'm seeeing now ... chances are I'm just making
some dumb mistake somewhere, but so far it has eluded
me ... as such GDB is of limited value ...

> ->2) I typically allocate most my Gtk-- objects on the stack.
> ->Is this considered OK or would dynamic allocation be
> ->better? I seem to remember that Gtk objects are very
> ->small themselves and dynamically allocate the memory
> ->they need (which would make stack allocation OK). Any
> ->tips from the Gtk-- gurus?
>
>    Could you provide some example code of what you
>    "typically" do ? Some common errors in such cases
>    look like :
>    < example code deleted >

What I mean is this: rather than allocating pointers and use
"new Gtk_Widget", I allocate objects and init them with the
constructor invokation:

     class Test
          {
          public:             T( );

               Gtk_HBox  hb1, hb2;
               Gtk_VBox  vb1, vb2;
               Gtk_Checkbox   cb1, cb2;
               Gtk_Label l1,l2;
          };

     Test::Test (),
          hb1 (TRUE, 3),
          hb2 (TRUE, 5),
          vb1 (TRUE, 5),
          vb2 (TRUE, 5)
          cb1 (),
          cb2 (),
          l1 ("Label1"),
          l2 ("Label2")
     {
     cout << "Constructor";
     }

Is this good, bad, dangerous, safe or just plain crazy?

Thanks
--> Robert




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