mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-04 06:00:15 +00:00
(svn r13126) -Fix (r13022) [FS#2009, FS#2010]: driver list should be dynamically allocated as static uninitialistion order is undetermined. The list is freed when the latest driver is removed.
This commit is contained in:
parent
13954aaaff
commit
0cab2cade2
11
src/driver.h
11
src/driver.h
@ -43,7 +43,7 @@ private:
|
||||
|
||||
static Drivers &GetDrivers()
|
||||
{
|
||||
static Drivers s_drivers;
|
||||
static Drivers &s_drivers = *new Drivers();
|
||||
return s_drivers;
|
||||
}
|
||||
|
||||
@ -71,7 +71,14 @@ public:
|
||||
*/
|
||||
virtual ~DriverFactoryBase() {
|
||||
if (this->name == NULL) return;
|
||||
GetDrivers().erase(this->name);
|
||||
|
||||
/* Prefix the name with driver type to make it unique */
|
||||
char buf[32];
|
||||
strecpy(buf, GetDriverTypeName(type), lastof(buf));
|
||||
strecpy(buf + 5, this->name, lastof(buf));
|
||||
|
||||
GetDrivers().erase(buf);
|
||||
if (GetDrivers().empty()) delete &GetDrivers();
|
||||
free(this->name);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user