Re: Glib::RefPtr

My T_item is:

class CObject : public Glib::Object
    static Glib::RefPtr<CObject > create ( const Glib::ustring& );
    virtual         ~CObject ();
    explicit        CObject ( const Glib::ustring& );
    Gtk::Frame*     m_pFrame;

The string argument is the name of the photo file, and the Frame contains the display built from the information in the photo file.

Creating the model:.

    m_refSpecificModel = Gio::ListStore<CObject >::create ( filename );


    m_refCurrentModel = m_refSpecificModel;
    m_pFlowBox->bind_list_store ( m_refCurrentModel, ... );

All m_* variables are members of the executing class and therefore do not go out of scope. I don't see why m_refSpecificModel's reference count should go to 0.

When I try to re-bind the model, the CObject instances are still present in m_refSpecificModel and the value of each m_pFrame is unchanged, but m_pFrame->gobj () returns 0.

On 10/08/2017 06:50 AM, Daniel Boles wrote:
If you want to keep the models around, then you should keep a RefPtr to them around, so that you hold an extra reference to stop them being destroyed.

FlowBox should only destroy the binding, not the model itself; if the latter occurs, it must be a result of you not having kept a reference to the model to keep it alive.

Or did I misunderstand?

gtkmm-list mailing list
gtkmm-list gnome org

It is better to have tried and failed than to have failed to try, but the result's the same.
   — Mike Dennison

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