Skip to content

Synfig may damage the project with exported values on save #3538

Closed

Description

@Svarov-RZM

Description

When we have a bunch of exported values in a project, Synfig may damage it when saving the project to disk. The reason for this is that the order of the nodes gets messed up and we get a bunch of "Unable to resolve" messages on loading the project.

How to reproduce

  • Open the test-case file:

WrongCopyOrder-OK.zip

  • Click on a black outline
  • In layers panel->Vertices (PATH)->Vertex 001->Vertex->Right click->Export Value...->Name: TEST->Export

Image

  • Save the project under a different name
  • Menu->File->Revert and you get a bunch of "Unable to resolve TEST" messages

Reproducible since version 1.0.2.

My thoughts

This is a very serious issue because it leaves the project damaged and non-tech savvy users have no choice to seek help on the forum. Good thing that I finally was able to create a reproducible example but how did I get there? I honestly don't know.

I did the usual thing... You know, exported a bunch of nodes, made some converters, exported some more stuff in a nested manner to make Synfig fail but it all worked fine. I think the problem arrived after I unexported some nodes and then exported them again but I don't know if all that is relevant.

Activity

  1. shreyaspranav commented on Apr 1, 2025

    @shreyaspranav
    Contributor

    @Svarov-RZM, I think I may have found the cause of the bug.

    I have noticed that after exporting a value to the project library and saving the file, the data of the exported value in the save file is at the end of <defs> tag. Like this:

    Assume the name of the exported value to be TEST

    <defs>
        <!-- Stuff that reference 'TEST' -->
        <vector id="TEST">
          <x>-0.1713666469</x>
          <y>0.4293667674</y>
        </vector>
    </defs>

    I just moved the tag block <vector id="TEST"> ... </vector> to the beginning of the <defs> tag such that all the stuff that reference TEST is at the end. This change seems to load the file properly.

    <defs>
        <vector id="TEST">
          <x>-0.1713666469</x>
          <y>0.4293667674</y>
        </vector>
        <!-- Stuff that reference 'TEST' -->
    </defs>

    However, does this break anything? I respectfully request other maintainers to guide me on this so that I can do the code changes and submit a pull request.

  2. added 2 commits that reference this issue on Apr 1, 2025
    0a48d0d
    30fcb6c
  3. Svarov-RZM commented on Apr 2, 2025

    @Svarov-RZM
    ContributorAuthor

    However, does this break anything?

    It doesn't in case of this particular file. You got the cause of the bug right - the problem is that Synfig places TEST node below other ID's that reference this exact node, so after you place it above them you fix the issue.

    I see that you linked a pull request that solves the problem. I am no developer, but I can at least test it on weekends to see if it breaks anything when saving other, more complicated projects.

  4. shreyaspranav commented on Apr 2, 2025

    @shreyaspranav
    Contributor

    I can at least test it on weekends to see if it breaks anything when saving other, more complicated projects.

    Your testing would be greatly appreciated! While I did test the fix for the above linked file and it seemed to have worked fine, it’s always good to check for any unintended side effects in more complex projects. Let me know if you run into any issues, and thanks for taking the time to test it!

    Best,
    Shreyas.

  5. added a commit that references this issue on Apr 27, 2025
    b561d9f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions