refBuilder->get_widget_derived usage
- From: Markus Kolb <markus kolb+gtkmm tower-net de>
- To: gtkmm Mailinglist <gtkmm-list gnome org>
- Subject: refBuilder->get_widget_derived usage
- Date: Sat, 28 Feb 2015 10:47:42 +0100
Hi,
I'm currently stuck and need your help...
I'd like to "load" a child Box from a glade-file to a derived class.
But on usage of the ContainerServer* returned by static ContainerServer*
create(),
I get a segv:
p_notebook_game->append_page(*p_container_server, _("Server"));
#0 0x00007ffff79f10b3 in Gtk::Notebook::append_page(Gtk::Widget&,
Gtk::Widget&) () at /usr/lib64/libgtkmm-3.0.so.1
#1 0x000000000041a2a5 in on_dialog_new_response(int) (response_id=-5)
at battleship.cpp:450
#2 0x00007ffff79bbbc7 in () at /usr/lib64/libgtkmm-3.0.so.1
#3 0x00007ffff4676e78 in g_closure_invoke () at
/usr/lib64/libgobject-2.0.so.0
#4 0x00007ffff4688311 in () at /usr/lib64/libgobject-2.0.so.0
#5 0x00007ffff468fd48 in g_signal_emit_valist ()
at /usr/lib64/libgobject-2.0.so.0
#6 0x00007ffff4690002 in g_signal_emit () at
/usr/lib64/libgobject-2.0.so.0
#7 0x00007ffff4676e78 in g_closure_invoke () at
/usr/lib64/libgobject-2.0.so.0
#8 0x00007ffff468807d in () at /usr/lib64/libgobject-2.0.so.0
Needs the refBuilder be available and isn't it possible to hide it?
So does the *p_cs get deleted when refBuilder gets deleted?
Or why this doesn't work?
How to do it? The examples only "load" main-dialogs.
class ContainerServer : public Gtk::Box
{
public:
ContainerServer(BaseObjectType* cobject, const
Glib::RefPtr<Gtk::Builder>& refBuilder);
static ContainerServer* create();
private:
Gtk::TreeView* m_p_treeview;
} ;
ContainerServer::ContainerServer(BaseObjectType* cobject, const
Glib::RefPtr<Gtk::Builder>& refBuilder) : Gtk::Box(cobject)
{
refBuilder->get_widget("treeview_server", m_p_treeview);
m_p_treeview->get_model();
// TODO: liststore stuff
}
ContainerServer* ContainerServer::create()
{
// Load the GtkBuilder file and instantiate its widgets
Glib::RefPtr<Gtk::Builder> refBuilder = Gtk::Builder::create();
try
{
refBuilder->add_from_file(Glib::build_filename(Configuration::get().get_datadir(),
"bs_server.glade"));
} catch (const Glib::FileError& ex)
{
g_critical("FileError: %s", ex.what().c_str());
return 0;
} catch (const Glib::MarkupError& ex)
{
g_critical("MarkupError: %s", ex.what().c_str());
return 0;
} catch (const Gtk::BuilderError& ex)
{
g_critical("BuilderError: %s", ex.what().c_str());
return 0;
}
ContainerServer* p_cs = 0;
refBuilder->get_widget_derived<ContainerServer>("box_server", p_cs);
return p_cs;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]