From 9a0eed3d591b11f4c7e7ee1799ade7f0296a3bb1 Mon Sep 17 00:00:00 2001 From: Kevin Griffin Date: Thu, 7 Nov 2019 17:57:13 -0800 Subject: [PATCH 1/2] Resolves #3741. Fixed the issue with installing host profiles after moving or deleting the .visit directory while VisIt is running. --- src/common/misc/InstallationFunctions.C | 22 ++++ src/common/misc/InstallationFunctions.h | 1 + .../QvisSetupHostProfilesAndConfigWindow.C | 106 ++++++++++++------ src/resources/help/en_US/relnotes3.0.3.html | 1 + 4 files changed, 93 insertions(+), 37 deletions(-) diff --git a/src/common/misc/InstallationFunctions.C b/src/common/misc/InstallationFunctions.C index 64a39f717cd..b2a3c5b2819 100644 --- a/src/common/misc/InstallationFunctions.C +++ b/src/common/misc/InstallationFunctions.C @@ -403,6 +403,28 @@ GetAndMakeUserVisItHostsDirectory() return retval; } +// **************************************************************************** +// Method: GetVisItHostsDirectory +// +// Purpose: +// Returns only the path to the user's .visit directory's host subdirectory. +// Doesn't try to create the directory like +// GetAndMakeUserVisItHostsDirectory. +// +// Arguments: +// none +// +// Programmer: Kevin Griffin +// Creation: November 07, 2019 +// +// **************************************************************************** +std::string +GetVisItHostsDirectory() +{ + std::string retval = GetUserVisItDirectory() + "hosts"; + return retval; +} + // **************************************************************************** // Method: GetUserVisItHostsDirectory // diff --git a/src/common/misc/InstallationFunctions.h b/src/common/misc/InstallationFunctions.h index 880d95263c1..4c1a41f0dc5 100644 --- a/src/common/misc/InstallationFunctions.h +++ b/src/common/misc/InstallationFunctions.h @@ -66,6 +66,7 @@ std::string MISC_API GetUserVisItRCFile(); std::string MISC_API GetSystemVisItRCFile(); std::string MISC_API GetAndMakeUserVisItHostsDirectory(); +std::string MISC_API GetVisItHostsDirectory(); std::string MISC_API GetSystemVisItHostsDirectory(); typedef enum { diff --git a/src/gui/QvisSetupHostProfilesAndConfigWindow.C b/src/gui/QvisSetupHostProfilesAndConfigWindow.C index edfa8df8e89..724a4114ec7 100644 --- a/src/gui/QvisSetupHostProfilesAndConfigWindow.C +++ b/src/gui/QvisSetupHostProfilesAndConfigWindow.C @@ -52,6 +52,7 @@ #include #include +#include // **************************************************************************** // Method: QvisSetupHostProfilesAndConfigWindow::QvisSetupHostProfilesAndConfigWindow @@ -248,6 +249,10 @@ QvisSetupHostProfilesAndConfigWindow::readDefaultConfigList() // // Modifications: // +// Kevin Griffin, Thu Nov 7 17:43:56 PST 2019 +// Added a check to see if the files were successfully copied. If not, a +// debug log message is generated to aid in troubleshooting. +// // **************************************************************************** void @@ -271,7 +276,11 @@ QvisSetupHostProfilesAndConfigWindow::installConfigFile(const QString& srcFilena } // Note: Copy will not overwrite existing files - QFile::copy(srcFilename, destFilename); + bool success = QFile::copy(srcFilename, destFilename); + if(!success) + { + debug1 << "Installing " << srcFilename.toStdString() << " to " << destFilename.toStdString() << " was not successful" << endl; + } } // **************************************************************************** @@ -296,59 +305,82 @@ QvisSetupHostProfilesAndConfigWindow::installConfigFile(const QString& srcFilena // Mark C. Miller, Mon Sep 17 08:46:24 PDT 2012 // Fixed leak from using GetDefaultConfigFile directly as arg // in installConfigFile. +// +// Kevin Griffin, Thu Nov 7 17:43:56 PST 2019 +// In rare cases when the user moves or deletes their .visit directory +// all the directories in the path need to be recreated. The call to mkdir +// in the previous GetAndMakeUserVisItHostsDirectory called didn't do that +// and there were no checks for successful creation of the hosts directory. +// The call to get the hosts directory was split from making the directory +// so mkpath could be used to create all the parent directories if needed. +// Successful creation is now checked and if it fails the appropriate debug +// log message is created. +// // **************************************************************************** void QvisSetupHostProfilesAndConfigWindow::performSetup() { QString hostsInstallDirectory = - QString::fromStdString(GetAndMakeUserVisItHostsDirectory()); - - for (std::list::iterator it = networkList.begin(); - it != networkList.end(); ++it) + QString::fromStdString(GetVisItHostsDirectory()); + + // mkpath will create all parent directories necessary to create the directory + // this is needed in rare cases where the .visit directory is deleted or moved and the + // user wants to install the hosts profiles. + QDir dir; + bool success = dir.mkpath(hostsInstallDirectory); + if(success) { - if (it->checkBox->isChecked()) + for (std::list::iterator it = networkList.begin(); + it != networkList.end(); ++it) { - QString srcDir(GetVisItResourcesFile(VISIT_RESOURCES_HOSTS, - it->shortName.toStdString()).c_str()); - QDir srcHostProfileDir(srcDir, "host*.xml"); - QStringList files = srcHostProfileDir.entryList(); - for (int i = 0; i < files.size(); ++ i) + if (it->checkBox->isChecked()) { - const QString &thisProfile = files.at(i); - installConfigFile(srcDir + "/" + thisProfile, - hostsInstallDirectory + "/" + thisProfile); + QString srcDir(GetVisItResourcesFile(VISIT_RESOURCES_HOSTS, + it->shortName.toStdString()).c_str()); + QDir srcHostProfileDir(srcDir, "host*.xml"); + QStringList files = srcHostProfileDir.entryList(); + for (int i = 0; i < files.size(); ++ i) + { + const QString &thisProfile = files.at(i); + installConfigFile(srcDir + "/" + thisProfile, + hostsInstallDirectory + "/" + thisProfile); + } } } - } - for (std::list::iterator it = defaultConfigList.begin(); - it != defaultConfigList.end(); ++it) - { - if (it->radioButton->isChecked()) + for (std::list::iterator it = defaultConfigList.begin(); + it != defaultConfigList.end(); ++it) { - const char *configFilename[] = { - "config", "guiconfig", "visitrc", 0 }; - - for (int i = 0; configFilename[i] != 0; ++i) + if (it->radioButton->isChecked()) { - std::string srcCfgName = - it->shortName.toStdString() + - "/" + std::string(configFilename[i]); - QString srcCfgPath(GetVisItResourcesFile(VISIT_RESOURCES_HOSTS, srcCfgName).c_str()); - if (QFile::exists(srcCfgPath)) + const char *configFilename[] = { + "config", "guiconfig", "visitrc", 0 }; + + for (int i = 0; configFilename[i] != 0; ++i) { - char *srcCfgFile = GetDefaultConfigFile(configFilename[i]); - installConfigFile(srcCfgPath, srcCfgFile); - delete [] srcCfgFile; + std::string srcCfgName = + it->shortName.toStdString() + + "/" + std::string(configFilename[i]); + QString srcCfgPath(GetVisItResourcesFile(VISIT_RESOURCES_HOSTS, srcCfgName).c_str()); + if (QFile::exists(srcCfgPath)) + { + char *srcCfgFile = GetDefaultConfigFile(configFilename[i]); + installConfigFile(srcCfgPath, srcCfgFile); + delete [] srcCfgFile; + } } } } - } - QMessageBox msgBox; - msgBox.setText(tr("Host profiles and configuration files have been installed" - " and will be available after VisIt is restarted.")); - msgBox.exec(); + QMessageBox msgBox; + msgBox.setText(tr("Host profiles and configuration files have been installed" + " and will be available after VisIt is restarted.")); + msgBox.exec(); - close(); + close(); + } + else + { + debug1 << "Hosts directory (" << hostsInstallDirectory.toStdString() << ") was not successfully created." << endl; + } } diff --git a/src/resources/help/en_US/relnotes3.0.3.html b/src/resources/help/en_US/relnotes3.0.3.html index c3a63000b36..0da46d312fb 100644 --- a/src/resources/help/en_US/relnotes3.0.3.html +++ b/src/resources/help/en_US/relnotes3.0.3.html @@ -27,6 +27,7 @@
  • Fixed bug with VTK reader parsing .vtm files when 'DataSet' tag doesn't have a 'file' attribute.
  • Disable VCR play/reverse play buttons when there is not active drawn plot.
  • Fixed inability to Pick on glyphed points lying near the dataset bounds.
  • +
  • Fixed the issue with installing host profiles after deleting or moving the .visit folder while VisIt is running.
  • From 3891988936f340c8bb281ffa2d0a40373fc56cd0 Mon Sep 17 00:00:00 2001 From: Kevin Griffin Date: Thu, 7 Nov 2019 18:10:31 -0800 Subject: [PATCH 2/2] Added message box to display error when host profiles weren't successfully copied. --- src/gui/QvisSetupHostProfilesAndConfigWindow.C | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/gui/QvisSetupHostProfilesAndConfigWindow.C b/src/gui/QvisSetupHostProfilesAndConfigWindow.C index 724a4114ec7..d4ec20df41d 100644 --- a/src/gui/QvisSetupHostProfilesAndConfigWindow.C +++ b/src/gui/QvisSetupHostProfilesAndConfigWindow.C @@ -382,5 +382,11 @@ QvisSetupHostProfilesAndConfigWindow::performSetup() else { debug1 << "Hosts directory (" << hostsInstallDirectory.toStdString() << ") was not successfully created." << endl; + + QMessageBox msgBox; + msgBox.setText(tr("Error: Host profiles and configuration files have not been installed. See debug logs for more information.")); + msgBox.exec(); + + close(); } }