diff --git a/ApplicationCode/Commands/ExportCommands/RicSnapshotFilenameGenerator.cpp b/ApplicationCode/Commands/ExportCommands/RicSnapshotFilenameGenerator.cpp index 0e1cde72c2..6939dd7188 100644 --- a/ApplicationCode/Commands/ExportCommands/RicSnapshotFilenameGenerator.cpp +++ b/ApplicationCode/Commands/ExportCommands/RicSnapshotFilenameGenerator.cpp @@ -51,7 +51,7 @@ QString RicSnapshotFilenameGenerator::generateSnapshotFileName(RimViewWindow* vi fileName = viewWindow->uiCapability()->uiName(); } - fileName = caf::Utils::makeValidFileBasename(fileName); + fileName = makeValidFileName(fileName); return fileName; } @@ -71,9 +71,7 @@ QString RicSnapshotFilenameGenerator::generateSnapshotFilenameForRimView(Rim3dVi if ( !timeSteps.empty() ) fileName += QString("_%1_%2").arg(timeStep, 2, 10, QChar('0')) .arg(timeSteps[timeStep]); - fileName.replace("-", "_"); - - fileName = caf::Utils::makeValidFileBasename(fileName); + fileName = makeValidFileName(fileName); return fileName; } @@ -111,3 +109,18 @@ QString RicSnapshotFilenameGenerator::resultName(Rim3dView * rimView) return ""; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RicSnapshotFilenameGenerator::makeValidFileName(const QString& filename) +{ + QString trimmedString = filename; + + // Use lowercase instead of dash before calling caf::Utils::makeValidFileBasename + trimmedString.replace("-", "_"); + + trimmedString = caf::Utils::makeValidFileBasename(trimmedString); + + return trimmedString; +} diff --git a/ApplicationCode/Commands/ExportCommands/RicSnapshotFilenameGenerator.h b/ApplicationCode/Commands/ExportCommands/RicSnapshotFilenameGenerator.h index 2862d64e3e..e5fc9c6838 100644 --- a/ApplicationCode/Commands/ExportCommands/RicSnapshotFilenameGenerator.h +++ b/ApplicationCode/Commands/ExportCommands/RicSnapshotFilenameGenerator.h @@ -34,4 +34,5 @@ public: private: static QString generateSnapshotFilenameForRimView(Rim3dView* rimView); static QString resultName(Rim3dView* rimView); + static QString makeValidFileName(const QString& filename); };