Skip to content

[Synfig Studio] fix file path on rendering file with relative path - #1952

Closed
rodolforg wants to merge 1 commit into
synfig:masterfrom
rodolforg:fix-canvas-filename
Closed

rodolforg wants to merge 1 commit into
synfig:masterfrom
rodolforg:fix-canvas-filename

Conversation

@rodolforg

@rodolforg rodolforg commented Dec 26, 2020 •

Copy link
Copy Markdown
Contributor

Issue:

  1. User launches a file via Synfig Studio from command line with a relative path
    (examples:
    $ synfigstudio mydir/myfile.sif
    or
    $ synfigstudio myfile.sif
    )

  2. Synfig Studio opens and loads the file normally (as always)

  3. User opens Render dialog.

  4. The filename entry text points to home dir + relative path!
    (examples:
    /home/user/mydir/myfile.sif // Problem: does mydir exist?
    or
    /home/user/myfile.sif // It may be ok, but shouldn't it point to same folder of sif file?
    )

@rodolforg

Copy link
Copy Markdown
Contributor Author

The problem comes from synfig::open_canvas_as(const FileSystem::Identifier &identifier,const String &as,String &errors,String &warnings ), that doesn't store the absolute filepath in Canvas object.

Another solution would be:

/// File: loadcanvas.cpp
Canvas::Handle
synfig::open_canvas_as(const FileSystem::Identifier &identifier,const String &as,String &errors,String &warnings)
{
	String filename = FileSystem::fix_slashes(as);
	// Add these lines below:
	if (!etl::is_absolute_path(filename))
		filename = etl::absolute_path(filename);

but I was afraid that could break another stuff due to etl::absolute_path() trusting on getcwd(), that doesn't handle the famous encoding problems.

@ice0

ice0 commented Dec 27, 2020 •

Copy link
Copy Markdown
Collaborator

but I was afraid that could break another stuff due to etl::absolute_path() trusting on getcwd(), that doesn't handle the famous encoding problems.

This can be resolved by using g_path_is_absolute (const gchar *file_name) instead of etl::absolute_path().

P.S. Glib::path_is_absolute(const std::string& filename) in case of glibmm

@rodolforg rodolforg changed the title fix file path on rendering file with relative path [Synfig Studio] fix file path on rendering file with relative path Jan 16, 2021
Issue:
1. User launches a file via Synfig Studio from command line with a relative path
(examples:
$ synfig-studio mydir/myfile.sif
 or
$ synfig-studio myfile.sif
)

2. Synfig Studio opens and loads the file normally (as always)

3. User opens Render dialog.

4. The filename entry text points to home dir + relative path!
(examples:
/home/user/mydir/myfile.sif // Problem: does mydir exist?
 or
/home/user/myfile.sif // It may be ok, but shouldn't it point to same folder of sif file?
)
@ice0

ice0 commented May 13, 2022

Copy link
Copy Markdown
Collaborator

@rodolforg
Is that still an issue on current master? I can't reproduce.

@rodolforg

Copy link
Copy Markdown
Contributor Author

Neither do I. How was it fixed? Mistery? :D

@ice0

ice0 commented May 28, 2022

Copy link
Copy Markdown
Collaborator

Neither do I. How was it fixed? Mistery? :D

I think it maybe was fixed after switching to Gio::Application

@rodolforg

Copy link
Copy Markdown
Contributor Author

Right now I can't test on 1.4.x though... Does it work there?
AppImage packages have an issue with relative paths...

@rodolforg

Copy link
Copy Markdown
Contributor Author

Closed as it works fine on master branch.

@rodolforg rodolforg closed this May 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants