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. */
|
/* 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));
|
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) {
|
if (!err) {
|
||||||
Debug(driver, 1, "Successfully probed {} driver '{}'", GetDriverTypeName(type), d->name);
|
Debug(driver, 1, "Successfully probed {} driver '{}'", GetDriverTypeName(type), d->name);
|
||||||
|
GetActiveDriver(type) = std::move(newd);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user