Re: [gtkmm] weird segfault



On Mon, 2003-01-27 at 15:40, Rui Lopes wrote:
> Hi,
> 
> 
> > Rui Lopes wrote:
> >
> >>Hello all,
> >>
> >>I have this code,
> 
> [snip]
> 
> >>but it segfauls; here is the backtrace:
> 
> [snip]
> 
> 
> > It looks to me like the RefPtr is keeping the Display object alive until
> >  the main() routine is finished, even though the X11 connection is
> > destroyed before returning from run(). So when the Display object is
> > finally destroyed, the underlying GTK+ routines trip over something (a
> > stale pointer, perhaps) and fall down.
> >
> > You could try clearing your RefPtr before entering run() to avoid this.
> > Presumably you won't need it after that point?
> >
> > ..mj
> 
> 
> this was only a small example; it doesn't matter where I put that RefPtr,
> for example with this,
> 
> 
> int main(int argc, char *argv[])
> {
>   Gtk::Main kit(argc, argv);
>   Gtk::Window window;
> 
>   { // note this extra compound block.
>     Glib::RefPtr<Gdk::Display> refDisplay = Gdk::Display::get_default();
>   }
> 
>   Gtk::Main::run(window);
>   return 0;
> }
> 
> this crashes in the destructor before reaching run.
> 
> btw, i'm not seeing why you have suggested the destruction of the RefPtr
> before entering run().

Try changing this line in gdk/src/display.hg:
_WRAP_METHOD(static Glib::RefPtr<Display> get_default(),
gdk_display_get_default)

to
_WRAP_METHOD(static Glib::RefPtr<Display> get_default(),
gdk_display_get_default, refreturn)

-- 
Murray Cumming
murray usa net
www.murrayc.com




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