Commit c7f463ea authored by Cory Quammen's avatar Cory Quammen

Added PV_SETTINGS_DEBUG environment variable

When set, the application will print information about where settings
file are being looked for and whether loading them succeeded.

Change-Id: Ie98c568c417cef4bdbfb545ea5fe87bb3663453f
parent ba08af44
......@@ -37,6 +37,13 @@
#include <algorithm>
#include <cfloat>
#define vtkSMSettingsDebugMacro(x)\
{ if (vtksys::SystemTools::GetEnv("PV_SETTINGS_DEBUG")) { \
vtksys_ios::ostringstream vtkerror; \
vtkerror << x << endl; \
vtkOutputWindowDisplayText(vtkerror.str().c_str());} }
//----------------------------------------------------------------------------
namespace {
class SettingsCollection {
......@@ -890,6 +897,7 @@ bool vtkSMSettings::AddCollectionFromFile(const std::string & fileName,
{
std::string settingsFileName(fileName);
std::ifstream settingsFile(settingsFileName.c_str(), ios::in | ios::binary | ios::ate);
vtkSMSettingsDebugMacro("Attempting to load settings file '" << fileName << "'");
if (settingsFile.is_open())
{
std::streampos size = settingsFile.tellg();
......@@ -901,13 +909,18 @@ bool vtkSMSettings::AddCollectionFromFile(const std::string & fileName,
settingsFile.close();
bool success = this->AddCollectionFromString(std::string(settingsString),
priority);
priority);
delete[] settingsString;
vtkSMSettingsDebugMacro("Loading settings file '" << fileName << "' " << (success ? "succeeded" : "failed"));
return success;
}
else
{
vtkSMSettingsDebugMacro("Could not open settings file '" << fileName << "'");
// Shouldn't this return false?
std::string emptyString;
return this->AddCollectionFromString(emptyString, priority);
}
......
......@@ -348,9 +348,9 @@ void vtkInitializationHelper::LoadSettings()
for (size_t cc = 0; cc < pathsToSearch.size(); cc++)
{
std::string path = pathsToSearch[cc];
if (vtksys::SystemTools::FileExists((path + "/" + filename).c_str(), true))
siteSettingsFile = path + "/" + filename;
if (vtksys::SystemTools::FileExists(siteSettingsFile.c_str(), true))
{
siteSettingsFile = path + "/" + filename;
settingsFileFound = true;
break;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment