Re: creatring Glib::RefPtr from plain pointer



On Thu, 2015-01-22 at 00:25 +0000, test_account tutanota de wrote:
Hi, I need someone to explain this:

this is correct:
Glib::RefPtr<Gtk::Menu> pMenuPopup = Gtk::manage(new Gtk::Menu(menu));

No, and I doubt it would compile.

it this correct to? if not why not?
Glib::RefPtr<Gtk::Menu> pMenuPopup = Glib::RefPtr<Gtk::Menu>(new
Gtk::Menu(menu));

You shouldn't use RefPtr<> with widgets (such as Gtk::Menu). If
something needs to use RefPtr<> then you'd generally get the RefPtr<>
from a method such as create(), get_something(), or get_default().

-- 
Murray Cumming
murrayc murrayc com
www.murrayc.com




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