Fwd: RE: SUSPECT: Re: [gtkmm] RE: TreeView Model, SEGV on append - mor e info [erik_ohrnberger dme net]



Am 2003.10.27 21:23 schrieb(en) "Ohrnberger, Erik":
Martin,
	Well, something must have changed as it's now working.  Wonder
what
I did.  Don't really like things like this that appear and then go away,
but
it appears to be working now.  Grrr.

	See below for additional comments interspersed.

	Erik.

-----Original Message-----
From: Martin Schulze [mailto:martin-ml hippogriff de]
Sent: Monday, October 27, 2003 3:50 PM
To: Ohrnberger, Erik
Cc: 'gtkmm-list gnome org'
Subject: SUSPECT: Re: [gtkmm] RE: TreeView Model, SEGV on
append - more
info


Am 2003.10.27 19:32 schrieb(en) "Ohrnberger, Erik":
> Everyone,
> 	I have a little bit more information on this.
>
> 	In the class that uses the TreeView, I have the following
> organization:
>
> Class is subclassed from Gtk::ScrolledWindow, and contains the
> following
> data members:
> 	Gtk::TreeView					tvMoldList;
> 	MoldListCols*					pCols;
> 	Glib::RefPtr<Gtk::ListStore>			pMoldListModel;
>
> In the class CTOR, I create the column instance (pCols)
with a new.  I
> also
> create the model:
> 	pMoldListModel = ListStore::create( *pCols );
>
> Set the model to the treeview:
> 	tvMoldList.set_model( pMoldListModel );
>
> and then append the columns to the treeview:
> 	tvMoldList.append_column( "Icon", (*pCols).Icon );
>
> In the MoldListCols CTOR, I add it's columns:
> 	add( Icon ); ....
>
> In one of the class's methods, I want to add a single line to the
> model,
> however, by then the data member pMoldListModel returns a NULL, like
> it's
> lost scope or something.  Well, once I create another
model, load all
> the
> items that should be in there and append line item that I wanted
> originally,
> it appears to work just fine.

The call
     pMoldListModel = ListStore::create( *pCols );
does indeed succeed and pMoldListModel is != 0 by then?

Yes.  In the class' CTOR, this succeeds.


You do instantiate Gtk::Main before your ctor is executed?

Gtk::Main is declared inside of main(), and on the line below,
MainWindow is
declared.  This leads me to believe that Gtk::Main is instantiated
first.


There is no other call pMoldListModel = ... in your code?

Nope.


pMoldListModel isn't hidden by a local variable?

Nope.


You always operate on the same instance of your class?

Yup.  It's declared as a data member of another class, which is higher
in
the GUI instance tree (if you think of how the widgets are all nested
within
each other).


Have you tried to allocate the TreeView dynamically
with Gtk::manage(new Gtk::TreeView) in your ctor?

Nope.


What does tvMoldList.get_model() yield by the time
pMoldListModel is 0?


It was NULL.  But now appears to have cleared up.

> It strikes me as strange that the model data member (pMoldListModel)
> would
> loose it's value between method calls.  You would think
that it would
> maintain it's value so that you could manipulate the model for the
> lifetime
> of the object.
>
> What do you think?  Is this in fact the expected behavior of the
> TreeView,
> Gtk::ListStore classes?

No, absolutely not. RefPtr<> aquires a reference on the ListStore.
The ListStore will not be freed until the last reference has become
out of scope. You could try to assign pMoldListModel to a global
variable (so that two reference with a completely different scope
refer to the same ListModel) and see if anything changes.

I'm sorry, without a compilable example we can only do guesswork.

Regards,

   Martin


I understand about having a solid example for you making things easier,
however, I don't think that my employer would like it if I sent
proprietary
code out of the corporation.


I really appreciate you helping me out in the manner that you are.  It
is
proving itself to be useful.

   Thanks,
	Erik.



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