Re: Crashes using custom signals



On Wed, 14 Jan 2009 19:02:13 -0700
"Phillip Neiswanger" <sigsegv0 gmail com> wrote:
> 
> Hi,
> 
> At this end of this message is a simple test program. Note the
> connect() call in the Application constructor. If I move the
> connect() out of that constructor and into the MainWindow constructor
> like so:
> 
> MainWindow::MainWindow()
> {
>      Application::instance()->
>          signal_a().
>             connect(sigc::mem_fun(*this, &MainWindow::on_a));
> }
> 
> I get a core dump in the connect() call. The back trace looks like
> this:

[snip]

You have a number of issues.  First Gtk::Main is not intended to be
derived from (although I doubt that is the direct cause of your
failure). Secondly, MainWindow is a member of the class you have
attempted to derive from Gtk::Main, so attempts to access other members
of your derived class in the MainWindow constructor gives rise to
undefined behaviour (your derived object does not exist at that
point - probably though your dynamic cast returned a null pointer, which
you also did not check for). Thirdly, you are connecting to a temporary
signal object (the return type is wrong).

Are you trying to write it as a java program?  There are some java
bindings if you want to try them out.

Chris



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