From 6ee79d22cb5575a471b242465146c890fa253a07 Mon Sep 17 00:00:00 2001 From: Owen Arnold <owen.arnold@stfc.ac.uk> Date: Fri, 24 Feb 2012 09:38:28 +0000 Subject: [PATCH] refs #4742. Windows only --- .../Framework/Kernel/src/ConfigService.cpp | 36 ++++++++++--------- .../MantidPlot/src/ApplicationWindow.cpp | 11 ++++-- .../MantidPlot/src/Mantid/SetUpParaview.cpp | 9 ++++- 3 files changed, 36 insertions(+), 20 deletions(-) diff --git a/Code/Mantid/Framework/Kernel/src/ConfigService.cpp b/Code/Mantid/Framework/Kernel/src/ConfigService.cpp index f94f106bc87..5c74eed2059 100644 --- a/Code/Mantid/Framework/Kernel/src/ConfigService.cpp +++ b/Code/Mantid/Framework/Kernel/src/ConfigService.cpp @@ -1698,28 +1698,32 @@ Ammend paths to point to include the paraview core libraries. */ void ConfigServiceImpl::setParaviewLibraryPath(const std::string& path) { - Poco::Path existingPath; - char separator = existingPath.pathSeparator(); - std::string strSeparator; - strSeparator.push_back(separator); + std::string platformPathName; #ifdef _WIN32 - existingPath = Poco::Environment::get("PATH"); - existingPath.append(strSeparator); - existingPath.append(path); - Poco::Environment::set("PATH",existingPath.toString()); + platformPathName = "PATH"; #elif defined __linux__ - existingPath = Poco::Environment::get("LD_LIBRARY_PATH"); - existingPath.append(strSeparator); - existingPath.append(path); - Poco::Environment::set("LD_LIBRARY_PATH",existingPath.toString()); + throw std::runtime_error("Cannot dynamically set the library path on Linux"); #elif defined __APPLE__ - existingPath = Poco::Environment::get("DYLD_LIBRARY_PATH"); - existingPath.append(strSeparator); - existingPath.append(path); - Poco::Environment::set("DYLD_LIBRARY_PATH",existingPath.toString()); + throw std::runtime_error("Cannot dynamically set the library path on Mac") #else throw std::runtime_error("ConfigServiceImpl::setParaviewLibraryPath cannot determine the running platform and therefore cannot set the path to the Paraview libraries."); #endif + Poco::Path existingPath; + char separator = existingPath.pathSeparator(); + std::string strSeparator; + strSeparator.push_back(separator); + + if(Poco::Environment::has(platformPathName)) + { + existingPath = Poco::Environment::get(platformPathName); + existingPath.append(strSeparator); + existingPath.append(path); + } + else + { + existingPath = path; + } + Poco::Environment::set(platformPathName, path); } /* diff --git a/Code/Mantid/MantidPlot/src/ApplicationWindow.cpp b/Code/Mantid/MantidPlot/src/ApplicationWindow.cpp index 9ea3f066a07..88cf6bb8267 100644 --- a/Code/Mantid/MantidPlot/src/ApplicationWindow.cpp +++ b/Code/Mantid/MantidPlot/src/ApplicationWindow.cpp @@ -373,8 +373,7 @@ void ApplicationWindow::init(bool factorySettings, const QStringList& args) If applicable, set the Paraview path BEFORE libaries are loaded. Doing it here, before the call to MantidUI::init() prevents the logs being poluted with library loading errors. */ - UNUSED_ARG(args); - //trySetParaviewPath(args); + trySetParaviewPath(args); //Initialize Mantid // MG: 01/02/2009 - Moved this to before scripting so that the logging is connected when @@ -483,6 +482,8 @@ void ApplicationWindow::init(bool factorySettings, const QStringList& args) /* Function tries to set the paraview path. +This is a windows only feature. the PATH enviromental variable can be set at runtime on windows. + - Abort if Vates libraries do not seem to be present. - Othwerise, if the paraview.path is already in the properties file, use it. - Otherwise, if the user is not using executeandquit command arguments launch the Setup gui. @@ -491,12 +492,13 @@ Function tries to set the paraview path. */ void ApplicationWindow::trySetParaviewPath(const QStringList& commandArguments) { +#ifdef _WIN32 if(this->hasVatesAvailable()) { //Early check of execute and quit command arguments used by system tests. QString str; bool b_skipDialog = false; - foreach(str, commandArguments) + foreach(str, commandArguments) { if(this->shouldExecuteAndQuit(str)) { @@ -523,6 +525,9 @@ void ApplicationWindow::trySetParaviewPath(const QStringList& commandArguments) } } } +#else + UNUSED_ARG(commandArguments) +#endif } diff --git a/Code/Mantid/MantidPlot/src/Mantid/SetUpParaview.cpp b/Code/Mantid/MantidPlot/src/Mantid/SetUpParaview.cpp index c2e2ef5724a..08cdc4943a3 100644 --- a/Code/Mantid/MantidPlot/src/Mantid/SetUpParaview.cpp +++ b/Code/Mantid/MantidPlot/src/Mantid/SetUpParaview.cpp @@ -57,14 +57,21 @@ void SetUpParaview::onSet() { ConfigServiceImpl& config = ConfigService::Instance(); + std::cout << "getting location" << m_candidateLocation.toStdString() << std::endl; config.setParaviewLibraryPath(m_candidateLocation.toStdString()); + std::cout << "getting paraview path" << std::endl; config.setString("paraview.path", m_candidateLocation.toStdString()); + + std::cout << "getting file name" << std::endl; std::string filename = config.getUserFilename(); //Save the result so that on the next start up we don't have to bother the user. + + std::cout << "saving" << std::endl; config.saveConfig(filename); - QDialog::accept(); + std::cout << "closing" << std::endl; + this->close(); } /// Event handler for the onChoose event. -- GitLab