adonthell-devel
[Top][All Lists]
Advanced

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

[Adonthell-devel] main_menu bug


From: Kai Sterker
Subject: [Adonthell-devel] main_menu bug
Date: Sun, 29 Sep 2002 00:48:16 +0200

I did some research regarding the memory leak when bringing up and
closing the main_menu. I doubt that we can solve it without rewriting
large parts of the code and scripts.

I will try to explain, but it's pretty hard, which means that the code
is pretty bad ;). 

Whenever the player presses ESC, a call is made to adonthell::main. This
will create a new instance of win_manger. The main menu is then attached
to this manager. When the menu is closed, a call is made to
adonthell::main_quit. The win_manager is deleted again. But: the actual
window is not deleted. If the code would be sane, deleting the window
manager should also delete all windows still attached to it. 

I tried to call win_manager::destroy from the win_manager destructor
which would take care of this, but this caused a crash. Obviously, some
windows were free'd twice then. Once on C++ side, once on python side.
To work around this, I've modified win_base a little bit. Each window
knows to which win_manager it is attached, and if it is free'd it is
automatically detached. When the window manager itself is destroyed
later on, the window will not be free'd twice that way.

That worked partly, but a few new problems arose. For one, the old
fading problem appeared again. When loading a game from the start
screen, the screen faded to black, then the start screen faded in and
then the mapview popped up. 

Even worse, in init.py, we call main_menu::get_result to see what choice
the player made. But with the changes above, this call happens _after_
the main menu has been deleted.


To cut a long story short: it's a big mess!

And it's no new bug either. It's been like that since 0.3. So I suggest
we just leave it for now, and try to come up with a better design for
v0.4 (or possibly v0.3.4). It's nothing that can be fixed in a day, as
it'll have side effects at many different places.

Kai




reply via email to

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