#include <cassert>
#include <iostream>
#include <glibmm.h>

using namespace std;

struct DerivedSource : public Glib::Source
{
    DerivedSource()
    {
    }

    virtual ~DerivedSource()
    {
        cout << "~DerivedSource()\n";
    }

    static Glib::RefPtr<DerivedSource> create()
    {
        Glib::RefPtr<DerivedSource> source(new DerivedSource());

        return source;
    }

    virtual bool prepare(int& timeout)
    {
        assert(false);
    }

    virtual bool check()
    {
        assert(false);
    }

    virtual bool dispatch(sigc::slot_base* slot)
    {
        assert(false);
    }
};

int main()
{
    Glib::RefPtr<Glib::MainContext> context = Glib::MainContext::create();
    Glib::RefPtr<DerivedSource> source = DerivedSource::create();

    source->attach(context);

    cout << "> source->destroy()\n";
    source->destroy();
    cout << "<\n";

    cout << "> source->destroy()\n";
    source->destroy();
    cout << "<\n";
}

