dlr-gtlab / gtlab-core

GTlab Core Framework
https://www.gtlab.de
Other
7 stars 2 forks source link

Tasks get lost after saving project via "Save As" #608

Open rainman110 opened 1 year ago

rainman110 commented 1 year ago

In GitLab by @bjoernTWK on Oct 23, 2023, 08:09

Summary

If a project is duplicated with the save-as-function (CTRL+SHIFT+S), the processes/calculators are not availabel in the new project (in one case GTlab crashed via the project)

Steps to reproduce

How can we reproduce the issue - this is very important!

  • Open a project
  • Duplicate the project via the save-as-function
  • Open duplicated project
jensschmeink commented 7 months ago

@bjoernTWK can you explain which problems occurred and which calculators were affected?

bjoernTWK commented 7 months ago

@bjoernTWK can you explain which problems occurred and which calculators were affected?

In my case the tasks are not copied in the new project (the folder was empty after the process -> maybe the external process element saving path is not applied correctly)

rainman110 commented 7 months ago

Bug Analysis

rainman110 commented 4 months ago

I have to withdraw my last analysis. The new path is known.

A multitude of problems come together here, I try to note them here:

  1. First the project is duplicated using memento->clone(). The "ProcessData" object cannot be cloned, as it does not have an invokable default constructor. Hence, the ProcessData node is a dummy and will be returned as a nullptr, when quering it by its classname.
  2. By providing a Q_INVOKABLE constructor to GtProcessData, issue 1. can be fixed. Still, the tasks cannot be saved, as the task group is still internally not initialized. Practially this means, that this internal information is not cloned.

Even if we fix this, only the active task group would be saved, as it is only part of the project. IMHO, all tasks need to be copied though, when saving a project to a different location.

@real-ct-ac What do you suggest here? How should we proceed.

rainman110 commented 4 months ago

The easiest way to "fix" it, is to simple copy the task files in "duplicateProject" via

    gt::filesystem::copyDir(
        QDir(oldDirectory.absoluteFilePath(QStringLiteral("tasks"))),
        QDir(newDirectory.absoluteFilePath(QStringLiteral("tasks"))),
        gt::filesystem::Recursive,
        QRegularExpression(R"(.*\.gttask|index.json)"));

The copied files will be automatically read-in when the project is opened again. They won't be copied during clone-only though. It works, but I am not sure though, whether this is the correct way to do. @real-ct-ac Pinging you here ;)

rainman110 commented 4 months ago

One more thing. Only copying the task files does not work: What, if the tasks have been changed or extended.

Then, we need to

Thus, we need to make the processdata node copyable.