Re: FileChooserDialog



Murray Cumming wrote:
On Mon, 2009-02-09 at 09:07 -0500, Damon Register wrote:
1. libglade    C                          error
2. libglademm  C++                        no error
3. libglademm  C++ with hello class       error
4. gtk-builder C                          error
5. gtk-builder C++                        no error
6. gtk-builder C++ with hello class       error

Most of my apps use method 6 so that is the one on which I am focusing
my effort.  I am pasting each hello file to this message

What is the actual error that you experience?
When I close the application I get

(hello.exe:2684): GLib-GObject-CRITICAL **: g_object_unref: assertion `G_IS_OBJECT (object)' failed


Could you also please _attach_ files rather than pasting them inline.
OK

Even better, please report bugs in bugzilla.
Since I don't consider myself a very experienced programmer, I hesitate
to make a bug report before I even know it is a bug.  To me it seems
a bug but I could be wrong.

In my hello example I found that when I add remove() to the quitmethod()
function, I no longer get the fail message when the program exits.  I also
see that the fail message happens in the hello class destructor.  Is there
a problem with hello being a Gtk::Window descendant and getting destroyed
when main() exits (when gtk is already shutdown)?

Damon Register

<?xml version="1.0"?>
<!--*- mode: xml -*-->
<interface>
  <object class="GtkWindow" id="hello_main_window">
    <child>
      <object class="GtkLayout" id="layout1">
        <property name="width_request">450</property>
        <property name="height_request">450</property>
        <property name="visible">True</property>
        <property name="width">450</property>
        <property name="height">450</property>
        <child>
          <object class="GtkFileChooserButton" id="filechooserbutton1">
            <property name="width_request">100</property>
            <property name="height_request">80</property>
            <property name="visible">True</property>
          </object>
          <packing>
            <property name="x">108</property>
            <property name="y">294</property>
          </packing>
        </child>
      </object>
    </child>
  </object>
</interface>
SOURCES  = hello.cpp
OBJS     = ${SOURCES:.cpp=.o}
CPPFLAGS =-g -fomit-frame-pointer `pkg-config gtkmm-2.4 --cflags`
LDADD    =`pkg-config gtkmm-2.4 --libs`
CC       = g++
PACKAGE  = hello.exe

all : ${OBJS}
	${CC} -o ${PACKAGE} ${OBJS} ${LDADD}

.cpp.o:
	${CC} ${CPPFLAGS} -c $<
#include <gtkmm.h>
#include <iostream>

class hello : public Gtk::Window
{
public:
    hello();
    virtual ~hello();

protected:

    Glib::RefPtr<Gtk::Builder>  refXml;
    Gtk::FileChooserButton* filechooserbutton1;
    Gtk::Layout *layout1;

    virtual void on_my_file_activated();
    virtual bool quitmethod();
};

hello::hello()
{
    std::cout << "hello()" << std::endl;
    refXml = Gtk::Builder::create_from_file("../hello.xml");
    refXml->get_widget("layout1", layout1);
    layout1->reparent(*this);

    refXml->get_widget("filechooserbutton1", filechooserbutton1);
    filechooserbutton1->signal_file_activated().connect( sigc::mem_fun(*this, &hello::on_my_file_activated  ) );

    Gtk::Main::signal_quit().connect(sigc::mem_fun(*this, &hello::quitmethod));
    std::cout << "hello() end" << std::endl;
}

hello::~hello()
{
    std::cout << "~hello()" << std::endl;
}

bool hello::quitmethod()
{
    std::cout << "quitmethod()" << std::endl;
    //remove();
    return false;
}

void hello::on_my_file_activated()
{
    std::cout << "on_my_file_activated()" << std::endl;
}

int main(int argc, char *argv[])
{
    Gtk::Main kit(argc, argv);
    hello window;
    kit.run(window);
    std::cout << "main() end" << std::endl;
    return 0;
}

/*
(hello.exe:2684): GLib-GObject-CRITICAL **: g_object_unref: assertion `G_IS_OBJECT (object)' failed
*/


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