diff options
author | glx <glx@openttd.org> | 2008-05-16 21:32:10 +0000 |
---|---|---|
committer | glx <glx@openttd.org> | 2008-05-16 21:32:10 +0000 |
commit | 180272ed8628e2af038750ee2ddeea8d33b931a4 (patch) | |
tree | 888b28ea7e2b673ee4041871da413ac800eb559a | |
parent | 5469686001aa00ab071afa62ba1a857b03d34a59 (diff) | |
download | openttd-180272ed8628e2af038750ee2ddeea8d33b931a4.tar.xz |
(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.
-rw-r--r-- | src/driver.h | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/driver.h b/src/driver.h index 7d1a3429c..572e10cb0 100644 --- a/src/driver.h +++ b/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); } |