From 38de84d6d067ad7bb04d753cd5e06c85878d5649 Mon Sep 17 00:00:00 2001 From: Sergej Geringer Date: Thu, 8 Sep 2022 23:48:35 +0200 Subject: [PATCH] cleanup --- core/src/MegaMolGraph_Convenience.cpp | 1 - core/src/param/FilePathParam.cpp | 11 +++-------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/core/src/MegaMolGraph_Convenience.cpp b/core/src/MegaMolGraph_Convenience.cpp index 4f82caae5d..4edf43382a 100644 --- a/core/src/MegaMolGraph_Convenience.cpp +++ b/core/src/MegaMolGraph_Convenience.cpp @@ -71,7 +71,6 @@ std::string megamol::core::MegaMolGraph_Convenience::SerializeCalls() const { } #include "mmcore/param/ButtonParam.h" -#include "mmcore/param/FilePathParam.h" std::string megamol::core::MegaMolGraph_Convenience::SerializeModuleParameters(std::string const& module_name) const { std::string serParams; diff --git a/core/src/param/FilePathParam.cpp b/core/src/param/FilePathParam.cpp index fed4960b75..a23150818c 100644 --- a/core/src/param/FilePathParam.cpp +++ b/core/src/param/FilePathParam.cpp @@ -87,24 +87,22 @@ void FilePathParam::SetValue(const std::filesystem::path& v, bool setDirty) { if (new_value.is_absolute() && !this->project_directory.empty()) { // is new path in project directory? // then represent as relative path - auto new_val_str = new_value.u8string(); - auto proj_dir_str = project_directory.u8string(); + // walk along directory path where project dir and new file path are the same auto val_it = new_value.begin(); auto proj_it = project_directory.begin(); while (*val_it == *proj_it) { val_it++; proj_it++; } + // if we walked the project directory till the end, new file is inside that directory if (*proj_it == *project_directory.end()) { - // new value is in project directory path - // collect the tail + // collect the tail of new file path and use it as new value std::filesystem::path project_relative_path; while (val_it != new_value.end()) { project_relative_path = project_relative_path / *val_it; val_it++; } - new_value = normalize_path(project_relative_path); } } @@ -113,9 +111,6 @@ void FilePathParam::SetValue(const std::filesystem::path& v, bool setDirty) { this->indicateParamChange(); if (setDirty) this->setDirty(); - } else { - // send around initial value, because the GUI might get stuck on an invalid file name - this->indicateChange(); } } } catch (std::filesystem::filesystem_error& e) {