Re: gtkmm2.4 and MSVC (again)

m h wrote:


Gtk::Window * window1 = this;
try {

Gtk::Widget * q = dynamic_cast<Gtk::Widget *>(


(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
	virtual ~HelloWorld() {}

  Gtk::Button m_button;

class MyHelloWorld : public HelloWorld
	MyHelloWorld() {}
	virtual ~MyHelloWorld() {}

	int i;  // comment this out and helloworld does not crash !

: 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
  // ( in the ObjectBase::is_derived_ method !!!

int main (int argc, char *argv[])
  Gtk::Main kit(argc, argv);

  MyHelloWorld 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+ (

I'm lost...


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