[Linux] Double click fails to open project if path contains non-ASCII characters #1995

Closed
unfa opened this Issue Apr 21, 2015 · 10 comments

Projects

None yet

3 participants

@unfa
Contributor
unfa commented Apr 21, 2015

I'm nurring KX Studio, the file manager is Dolphin (KDE).

When I doubleclick on a project file, LMMS opens but shows this dialog:

lmms-doubleclick-project-load-fail

And creates new session.

Opening the same file via File>Open dialog works fine.

@tresf
Member
tresf commented Apr 21, 2015

At a glance looks related to #1325, where the latin1 version of the text is being processed rather than the utf8, etc

@softrabbit
Member

To rule out an oddly named folder, I'd like to see confirmation that:

  • Dolphin shows the folder name OK
  • Doubleclicking other files in the same folder works fine
  • The folder name looks OK on the command line

And, can the project be opened from the command line using its full path?

@unfa
Contributor
unfa commented Apr 21, 2015

Dolphin show the file name fine.
Doubleclicking other files (WAV for example in the same dir) works.
Running from comandline:

lmms /unfa/Projects/Mieczysław Szymasiewicz/Krainy Oniryczne/Muzyka/Zona/unfa-Zona-01.mmpz

Failed

cd /unfa/Projects/Mieczysław Szymasiewicz/Krainy Oniryczne/Muzyka/Zona/
lmms ./unfa-Zona-01.mmpz

Worked

I guess the Polish diacritics like "ł" are the problem on some level.

@unfa unfa changed the title from [Linux] Double click fails to open project to [Linux] Double click fails to open project if path contains non-ASCII characters Apr 21, 2015
@softrabbit
Member

I guess the Polish diacritics like "ł" are the problem on some level.

Yes, looks like QStrings constructed from char * are converted using fromAscii(). Should probably use fromLocal8Bit() instead.

@tresf
Member
tresf commented Apr 21, 2015

Thanks for the sample text. It is being triggered here: DataFile.cpp#L126 by improper encoding of the dark L or L with stroke, i.e. ł.

Had this been a UTF8 issue, the solutions proposed seemed simple, but to my surprise, I've had no luck getting them to fix the issue.

So I dug a bit deeper and stumbled upon this.... our main constructor casts the char* to QString which may be causing it per:

The default char* => QString conversion uses Latin-1, which is not what you want for file names.

Source: http://stackoverflow.com/questions/1641994/qdir-and-qdiriterator-ignore-files-with-non-ascii-filenames

The proposal is to instead use:

QApplication app(argc, argv);

QStringList args = app.arguments();

for(...)

But this changes our main.cpp logic a bit, so it would require a bit of code refactoring.

@tresf
Member
tresf commented Apr 21, 2015

Looks like @softrabbit and I did similar work here. I'd recommend we don't override the default encoding settings, but rather use the Qt recommended approach for reading application parameters, as if we force UTF8, we may run into issues with Windows-CP1252, etc.

-Tres

@softrabbit
Member

The fromLocal8Bit() idea came straight from here: http://doc.qt.io/qt-5/qcoreapplication.html#arguments so it should be pretty much safe.

@tresf
Member
tresf commented Apr 21, 2015

Good catch, that seems to work.

image

We'll need to patch it into several places due to the command line rendering, etc.

@tresf tresf added a commit to tresf/lmms that referenced this issue Apr 21, 2015
@tresf tresf Load file names with utf chars
Fixes #1995
00aaa65
@tresf
Member
tresf commented Apr 21, 2015

@softrabbit can you take a look at #1998 and see if I missed anything?

@tresf tresf added a commit to tresf/lmms that referenced this issue Apr 21, 2015
@tresf tresf Load file names with utf chars
Fixes #1995
b547f7b
@tresf tresf added a commit to tresf/lmms that referenced this issue Apr 21, 2015
@tresf tresf Load all file names with utf chars
Fixes #1995
66d9196
@tresf tresf added a commit to tresf/lmms that referenced this issue Apr 21, 2015
@tresf tresf Load file names with utf chars
Fixes #1995
3bc10a9
@tresf tresf added a commit to tresf/lmms that referenced this issue Apr 21, 2015
@tresf tresf Load all file names with utf chars
Fixes #1995
13f7065
@tresf tresf closed this in #1998 Apr 24, 2015
@tresf
Member
tresf commented Apr 24, 2015

Closed via #1998. Added to release notes under "Fixes" section.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment