Skip to content

Commit 7e09578

Browse files
SG-41548 Make saveFileDialog RV command permissions check optional (#1056)
### SG-41548 Make saveFileDialog RV command permissions check optional ### Linked issues NA ### Describe the reason for the change. Some Windows users reported that when using the saveFileDialog() RV command and writing on a network drive with the appropriate write permissions, RV was incorrectly reporting that the destination directory was not writable by the user. We were not able to reproduce this issue which would have allowed us to find the real cause of this issue. ### Summarize your change. This commit makes the saveFileDialog RV command permissions check prior to saving optional if the RV_SKIP_SAVE_FILE_DIALOG_PERMISSIONS_CHECK environment variable is set and also adds a "Try to Save Anyway" button if the permission check fails. Note that if the directory of the saving operation is really not writable, then the write operation will fail. At least this will unblock users facing this issue which seams to be Windows + Network drive specific. ### Describe what you have tested and on which operating system. Successfuly tested by the Windows users facing this specific Windows + Network drive issue. ### Add a list of changes, and note any that might need special attention during the review. ### If possible, provide screenshots. Signed-off-by: Bernard Laberge <bernard.laberge@autodesk.com>
1 parent 46a84c3 commit 7e09578

1 file changed

Lines changed: 27 additions & 17 deletions

File tree

src/lib/app/RvCommon/MuUICommands.cpp

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -896,25 +896,35 @@ namespace Rv
896896
v = pathConform(UTF8::qconvert(files.at(0)));
897897
QFileInfo info(UTF8::qconvert(v.c_str()));
898898

899-
//
900-
// QFileInfo says a non-existant file is not writable, so have
901-
// to check the directory in that case.
902-
//
903-
const bool isDirWritable = TwkUtil::isWritable(UTF8::qconvert(info.absolutePath()).c_str());
904-
const bool isFileWritable = TwkUtil::isWritable(v.c_str());
905-
if ((!info.exists() && !isDirWritable) || (info.exists() && !isFileWritable))
899+
// Allow skipping permissions check via environment variable
900+
static const bool skipPermissionsCheck = (getenv("RV_SKIP_SAVE_FILE_DIALOG_PERMISSIONS_CHECK") != nullptr);
901+
if (!skipPermissionsCheck)
906902
{
907-
QString message = QString("File '") + UTF8::qconvert(v.c_str())
908-
+ "' is not writable; please check the permissions or "
909-
"choose another location.";
910-
QMessageBox confirm(QMessageBox::Warning, "Permissions", message, QMessageBox::NoButton, rvDoc, Qt::Sheet);
911-
912-
QPushButton* q1 = confirm.addButton("OK", QMessageBox::AcceptRole);
913-
confirm.setIcon(QMessageBox::Question);
914-
confirm.exec();
915-
v = "";
903+
//
904+
// QFileInfo says a non-existant file is not writable, so have
905+
// to check the directory in that case.
906+
//
907+
const bool isDirWritable = TwkUtil::isWritable(UTF8::qconvert(info.absolutePath()).c_str());
908+
const bool isFileWritable = TwkUtil::isWritable(v.c_str());
909+
910+
if ((!info.exists() && !isDirWritable) || (info.exists() && !isFileWritable))
911+
{
912+
QString message = QString("File '") + UTF8::qconvert(v.c_str())
913+
+ "' is not writable; please check the permissions or "
914+
"choose another location.";
915+
QMessageBox confirm(QMessageBox::Warning, "Permissions", message, QMessageBox::NoButton, rvDoc, Qt::Sheet);
916+
917+
QPushButton* q1 = confirm.addButton("Try to Save Anyway", QMessageBox::AcceptRole);
918+
QPushButton* q2 = confirm.addButton("Choose Another Location", QMessageBox::RejectRole);
919+
confirm.setDefaultButton(q2);
920+
confirm.setIcon(QMessageBox::Question);
921+
confirm.exec();
922+
if (confirm.clickedButton() != q1)
923+
v = "";
924+
}
916925
}
917-
else if (info.exists())
926+
927+
if (info.exists())
918928
{
919929
QString message = QString("File '") + UTF8::qconvert(v.c_str()) + "' exists; overwrite ?";
920930
QMessageBox confirm(QMessageBox::Warning, "Overwrite", message, QMessageBox::NoButton, rvDoc, Qt::Sheet);

0 commit comments

Comments
 (0)