mirror of
https://github.com/OpenTTD/OpenTTD
synced 2026-01-21 19:32:54 +01:00
Codechange: Make driver probe behave the same as loading by name. (#14736)
Inconsistent initialisation order when setting active driver and starting the driver.
This commit is contained in:
@@ -145,11 +145,12 @@ bool DriverFactoryBase::SelectDriverImpl(const std::string &name, Driver::Type t
|
||||
|
||||
/* Keep old driver in case we need to switch back, or may still need to process an OS callback. */
|
||||
auto oldd = std::move(GetActiveDriver(type));
|
||||
GetActiveDriver(type) = d->CreateInstance();
|
||||
auto newd = d->CreateInstance();
|
||||
|
||||
auto err = GetActiveDriver(type)->Start({});
|
||||
auto err = newd->Start({});
|
||||
if (!err) {
|
||||
Debug(driver, 1, "Successfully probed {} driver '{}'", GetDriverTypeName(type), d->name);
|
||||
GetActiveDriver(type) = std::move(newd);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user