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 dP
parent bbb8926a63
commit 3d475b964e

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