Re: gtkmm2.4 and MSVC (again)
- From: Cedric Gustin <cedric gustin swing be>
- To: m h <msh126 yahoo com>
- Cc: gtkmm-list gnome org
- Subject: Re: gtkmm2.4 and MSVC (again)
- Date: Mon, 01 Nov 2004 22:11:49 +0100
m h wrote:
window1_glade::window1_glade():Gtk::Window(Gtk::WINDOW_TOPLEVEL){
Gtk::Window * window1 = this;
try {
Gtk::Widget * q = dynamic_cast<Gtk::Widget *>(
Glib::ObjectBase::_get_current_wrapper((GObject
*)(window1->gobj())));
}
(this line is from Widget_class::show_callback(). i'm
not sure why this cast fails when a derived class has
member variables. any idea why this matters?
I guess this problem is beyond my gtkmm/C++/MSVC expertize.
I worked on this simple helloworld example
----- Cut here -----
#include <gtkmm/main.h>
#include <gtkmm/button.h>
#include <gtkmm/window.h>
class HelloWorld : public Gtk::Window
{
public:
HelloWorld();
virtual ~HelloWorld() {}
protected:
Gtk::Button m_button;
};
class MyHelloWorld : public HelloWorld
{
public:
MyHelloWorld() {}
virtual ~MyHelloWorld() {}
private:
int i; // comment this out and helloworld does not crash !
};
HelloWorld::HelloWorld()
: m_button("Hello World")
{
// helloworld crashes here if MyHelloWorld has the integermember
// Stepping into add(m_button),
// gtk_container_add(this->gobj(),m_button.gobj())
// is supposed to be called. this->gobj() and m_button.gobj() return
// correctly but the call to gtk_container_add results in a coredump
// (objectbase.cc) in the ObjectBase::is_derived_ method !!!
add(m_button);
m_button.show();
}
int main (int argc, char *argv[])
{
Gtk::Main kit(argc, argv);
MyHelloWorld helloworld;
Gtk::Main::run(helloworld);
return 0;
}
----- cut here -----
As pointed ou by Matt, there is a problem when a member (int i) is added
to a derived class. helloworld crashes at the add(m_button) line,
which corresponds to a gtk_container_add call (Timothy also pointed out
this bottleneck). For some unknown reason, the program then jumps to the
ObjectBase::is_derived_ method and crashes. Comment out the "int i;"
declaration, and it works as expected.
By the way, I also reproduced the crash against a native MSVC build of
GTK+ (http://severna.homeip.net/gtk-win32.php)
I'm lost...
Cedric
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]