Skip to content

Use Canonical Paths for Relative Paths Calculations#4211

Merged
tresf merged 3 commits into
LMMS:stable-1.2from
tresf:relative
Mar 4, 2018
Merged

Use Canonical Paths for Relative Paths Calculations#4211
tresf merged 3 commits into
LMMS:stable-1.2from
tresf:relative

Conversation

@tresf

@tresf tresf commented Mar 3, 2018

Copy link
Copy Markdown
Member

Forces strange paths like /path/.///to/../from/foo///// to be /path/from/foo.

Closes #4173

Comment thread tests/src/core/RelativePathsTest.cpp Outdated

QString absPath = fi.absoluteFilePath();
QString relPath = "drums/kick01.ogg";
QString fuzPath = absPath.replace(relPath, "drums/.///kick01.ogg");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Current one won't work because this line modifies absPath. This one will work:

QString fuzPath = absPath;
fuzPath.replace(relPath, "drums/.///kick01.ogg");

@tresf tresf Mar 4, 2018

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes, forgot Strings are mutable in Qt. Thanks.

QString are mutable objects.  Call replace on the clone, not on the original.
@tresf tresf merged commit 1d63bd3 into LMMS:stable-1.2 Mar 4, 2018
@tresf tresf deleted the relative branch March 4, 2018 03:46
@tresf tresf restored the relative branch March 22, 2018 16:52
sdasda7777 pushed a commit to sdasda7777/lmms that referenced this pull request Jun 28, 2022
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