1
0
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:
Peter Nelson
2025-10-30 20:22:30 +00:00
committed by GitHub
parent 3f19240bbe
commit 038c4d2b87

View File

@@ -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;
}