Re: Glib::RefPtr

    CObject::CObject ( const Glib::ustring& filename )
        m_pFrame = (Gtk::Frame*)( new CThumbnail ( filename ) );

    Gtk::Frame* CObject::GetFrame ()
        return ( m_pFrame );


    class CThumbnail : public Gtk::Frame

I have neglected to mention the slot argument:

    m_pFlowBox->bind_list_store ( m_refCurrentModel, sigc::mem_fun ( *this, &CBridge::OnContentCreate () ) );
    Gtk::Widget* CBridge::OnContentCreate ( const Glib::RefPtr<CObject >& refObject )
        return ( (Gtk::Widget*)refObject->GetFrame () );

m_pFrame is stored in the CObject constructor, and retrieved for the return value of the callback slot, it is otherwise untouched in the application.

I construct two models and bind the first, and everything goes as expected. When I then bind the second model, all is still well. But when I bind the first model again, I get a bunch of failed assertions and a blank display.

I also constructed a much simpler example using Gtk::Label in place of Gtk::Frame and CThumbnail (which does contain Gtk::manage() calls) and

    m_pLabel = new Gtk::Label (filename);

in the CObject constructor. The results are the same.

On 10/08/2017 07:47 AM, Daniel Boles wrote:
How do you create m_pFrame, and what do you do with it between creating it and finding it to be 0?

It sounds to be like you might be Gtk::manage()ing it and then adding it to a container, in which case, that container sinks the floating reference and takes over ownership completely. If so, you'd need to not do that; have it as a non-pointer member and just hand out observing references/pointers to it.

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]