Re: Gdk problem.

PerBeatus wrote:

Simple question. Why it compiles ok, and at run prints "segmentation fault" ?

    Gtk::Main main(argc, argv);

    Gtk::Window w;

    Gdk::Color c_red;

    Glib::RefPtr<Gdk::Window> gdk_w = w.get_frame();

I don't think Gtk::Window::get_frame() does what you're expecting. It actually only returns a valid Gdk::Window when GTK is providing its own window frames*, which on most platforms (X, Windows, etc) isn't the case, given window frames are provided by a separate window manager process or the OS, so it isn't really useful for GTK to give programs access to them. Instead get_frame() returns a Glib::RefPtr<Gdk::Window> containing NULL, hence your segfault.

By the way, not everybody likes red. ;) If you want to draw attention to your window, try Gtk::Window::set_urgency_hint(). Or possibly you were just looking for:
  w.modify_bg(Gtk::STATE_NORMAL, Gdk::Color("red"));

[*] I think GTK only does this with DirectFB, which doesn't or didn't always provide window management.

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