Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
geringsj committed Apr 25, 2023
1 parent b2f1680 commit 38de84d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
1 change: 0 additions & 1 deletion core/src/MegaMolGraph_Convenience.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
11 changes: 3 additions & 8 deletions core/src/param/FilePathParam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand All @@ -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) {
Expand Down

0 comments on commit 38de84d

Please sign in to comment.