Check for null options before changing path in registry
This commit is contained in:
@@ -204,8 +204,12 @@ public:
|
|||||||
|
|
||||||
struct OptionsPusher {
|
struct OptionsPusher {
|
||||||
FilePathList localPathList;
|
FilePathList localPathList;
|
||||||
OptionsPusher(const ReaderWriter::Options* options)
|
bool validOptions;
|
||||||
|
OptionsPusher(const ReaderWriter::Options* options):
|
||||||
|
validOptions(false)
|
||||||
{
|
{
|
||||||
|
if (!options)
|
||||||
|
return;
|
||||||
Registry* registry = Registry::instance();
|
Registry* registry = Registry::instance();
|
||||||
localPathList = registry->getDataFilePathList();
|
localPathList = registry->getDataFilePathList();
|
||||||
const FilePathList& regPathList = registry->getDataFilePathList();
|
const FilePathList& regPathList = registry->getDataFilePathList();
|
||||||
@@ -219,11 +223,13 @@ struct OptionsPusher {
|
|||||||
}
|
}
|
||||||
// Save the current Registry path list and install the augmented one.
|
// Save the current Registry path list and install the augmented one.
|
||||||
localPathList.swap(registry->getDataFilePathList());
|
localPathList.swap(registry->getDataFilePathList());
|
||||||
|
validOptions = true;
|
||||||
}
|
}
|
||||||
~OptionsPusher()
|
~OptionsPusher()
|
||||||
{
|
{
|
||||||
// Restore the old path list
|
// Restore the old path list
|
||||||
localPathList.swap(Registry::instance()->getDataFilePathList());
|
if (validOptions)
|
||||||
|
localPathList.swap(Registry::instance()->getDataFilePathList());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
Reference in New Issue
Block a user