summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/driver.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/driver.cpp b/src/driver.cpp
index 70f695122..825c489b9 100644
--- a/src/driver.cpp
+++ b/src/driver.cpp
@@ -116,15 +116,18 @@ bool DriverFactoryBase::SelectDriverImpl(const char *name, Driver::Type type)
if (d->type != type) continue;
if (d->priority != priority) continue;
+ Driver *oldd = *GetActiveDriver(type);
Driver *newd = d->CreateInstance();
+ *GetActiveDriver(type) = newd;
+
const char *err = newd->Start(NULL);
if (err == NULL) {
DEBUG(driver, 1, "Successfully probed %s driver '%s'", GetDriverTypeName(type), d->name);
- delete *GetActiveDriver(type);
- *GetActiveDriver(type) = newd;
+ delete oldd;
return true;
}
+ *GetActiveDriver(type) = oldd;
DEBUG(driver, 1, "Probing %s driver '%s' failed with error: %s", GetDriverTypeName(type), d->name, err);
delete newd;
}