URL:
<http://gna.org/bugs/?24139>
Summary: Display Singleton isn't a singleton
Project: Battle for Wesnoth
Submitted by: aginor
Submitted on: Sat 05 Dec 2015 06:26:15 AM UTC
Category: Bug
Severity: 3 - Normal
Priority: 5 - Normal
Item Group: None of the others
Status: None
Privacy: Public
Assigned to: None
Originator Email:
Open/Closed: Open
Discussion Lock: Any
Release: dev
Operating System: Any/All
_______________________________________________________
Details:
Exposed by #24138
The game will create one instance of the display class during the initial
loading screen, then a new one as a campaign is started without freeing the
initial one.
During the display class constructor it will update a pointer for the
singleton to point to the current instance, and setting it to null inside the
destructor.
This is fraught with wrongness because of the following:
0 Instance 1 is created - Singleton pointer now points to instance 1
0 Instance 2 is created - Singleton pointer now points to instance 2
0 Instance 2 is destroyed (return to main screen) - Singleton pointer is set
to null
The lifetime of both objects is concurrent, but the singleton is wrongly used
here. I think the correct behaviour would be to introduce a display manager
that would manage the instances of the display, having the constructor and
destructor register/deregister with the manager. The display manager is then
responsible for keeping track of the current instance of the display, which
other classes can then use instead of the current incorrect
display::get_singleton function call.
_______________________________________________________
Reply to this item at:
<http://gna.org/bugs/?24139>
_______________________________________________
Message sent via/by Gna!
http://gna.org/
_______________________________________________
Wesnoth-bugs mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-bugs