adonthell-devel
[Top][All Lists]
Advanced

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

Re: [Adonthell-devel] User interface open items


From: Kai Sterker
Subject: Re: [Adonthell-devel] User interface open items
Date: Tue, 3 Jan 2012 22:02:13 +0100

On Tue, Jan 3, 2012 at 9:43 AM, Kai Sterker <address@hidden> wrote:

>> It seems that whatever it is, it's somehow related to adding something
>> to window_manager.
>
> Sounds like something is messing up the stack. Could be tricky to
> find, but I'll take a look, hopefully tonight.

For the record, here's what I am doing to debug this.

First, added your code to wastesedge/schedules/obj/comment.py
Second, added Vera.ttf from adonthell test data to wastesedge/gfx/gui
Third, ran wastesedge with gdb (with irrelevant output removed):

 address@hidden:~/adonthell/adonthell-sdl1.3/test$ gdb .libs/worldtest
 GNU gdb (Ubuntu/Linaro 7.3-0ubuntu2) 7.3-2011.08
 (gdb) run -g ../.. wastesedge

Walked over to the barrel and had a look:

 Program received signal SIGSEGV, Segmentation fault.
 0x0000000000000031 in ?? ()
 (gdb) bt
 #1  0x00007ffff6c4c405 in operator() (p1=<optimized out>, this=<optimized out>)
    at ../../../adonthell/src/base/callback.h:579
 #2  input::listener::raise_event (this=<optimized out>, ev=<optimized out>)
    at ../../../adonthell/src/input/listener.cc:131
 #3  0x00007ffff6c4c444 in input::manager::raise_event (ev=...)
    at ../../../adonthell/src/input/manager.cc:49

Okay, so we're inside an input listener where we handle pressing
SPACE. And in gui::window_manager::add we have the following code:

    // add window at first position of the input queue
    input::listener *il = new input::listener();
    input::manager::add (il);
    input::manager::give_focus (il);

Manipulating input listeners while we're currently inside one looks
suspicious. So lets comment the last two lines for now and try again.
Different stack trace this time:

 (gdb) bt
 #0  0x0000000000000010 in ?? ()
 #1  0x00007ffff6e3ba2e in gui::layout::draw (this=0x1010040,
    address@hidden, address@hidden, da=0x0, target=0x759ce0)
    at ../../../adonthell/src/gui/layout.cc:134
 #2  0x00007ffff6e43225 in gui::window_manager::update ()
    at ../../../adonthell/src/gui/window_manager.cc:55

So we're now done adding the window and crashing while drawing.
Problem might be that we're creating a window on Python side (so
Python owns that reference), then passing it to the window manager and
finally letting Python remove the reference. So lets change that for
now by updating comment.py and adding the following lines:

  la.thisown = 0
  l.thisown = 0

This tells python to not destroy the underlying C++ object when the
Python wrapper instance goes out of scope and gets garbage collected.

Afterwards, it works!


So it seems there's two issues:

* Modifying the input listener list while iterating over it. I'll
think about something, but for the beginning I'll commit a quick and
dirty workaround. Shouldn't take long ...
* Second, make sure layout::add_child or window_manager::add take
proper ownership of the C++ object. Need to check the SWIG manual how
to best go about that. For now, manually changing ownership should be
an acceptable workaround.


I'll keep you updated. Let me know if something else hinders your
progress on the speech bubbles.

Kai

P.S.: When debugging, I find it helpful to set CXXFLAGS="-O0 -g"
before running configure. That way, optimisation does not get in the
way of the debugger.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]