Bug 477039 - lokalize does not open project file using --project <project_file>
Summary: lokalize does not open project file using --project <project_file>
Status: RESOLVED FIXED
Alias: None
Product: lokalize
Classification: Applications
Component: project management (show other bugs)
Version: 23.08.3
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Simon Depiets
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-11-15 11:58 UTC by Freek de Kruijf
Modified: 2024-02-07 22:58 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Freek de Kruijf 2023-11-15 11:58:08 UTC
SUMMARY
***
lokalize does not open project file using --project <project_file>
***


STEPS TO REPRODUCE
When I invoke lokalize using "lokalize --project <project_file>", either on a console or via a mime definition and clicking on a .lokalize file, it shows an empty tab "Project Overview". When I use, after in this way starting lokalize, the menu item "Open Project" and select a project file the tab "Project overview" shows the content of the project.

OBSERVED RESULT
Empty tab "Project Overview"

EXPECTED RESULT
Filled tab "Project Overview"

SOFTWARE/OS VERSIONS
Windows: 
macOS: 
Linux/KDE Plasma: 
(available in About System)
KDE Plasma Version: 5.27.9
KDE Frameworks Version: 5.112.0
Qt Version: 5.15.11

ADDITIONAL INFORMATION
Comment 1 Albert Astals Cid 2023-11-27 15:59:36 UTC
Is this the same thing you reported on the mailing list?

Did you see my follow up there?
Comment 2 Freek de Kruijf 2023-11-28 10:02:38 UTC
(In reply to Albert Astals Cid from comment #1)
> Is this the same thing you reported on the mailing list?
> 
> Did you see my follow up there?

You wrote on the mailing list:
There's no code changes between 23.08.2 and 23.08.3 in lokalize. [Unless maybe 
you're using Ubunut+snaps]

Are you sure it's not a different update that broke this? Maybe KDE 
Frameworks? Is your distribution powerful enough that lets you back some 
updates to try to find which update broke it?

I am using openSUSE Tumbleweed, currently snapshot 20231126.
I went back to snapshot 20231101 and installed the version 23.08.2, which showed the same behavior.
Most likely it is a KDE Framework module that causes this problem. So now I am going back to snapshot 20231101 with all the software.
Now it works OK.
Trying snapshot 20231110. Frameworks 5.111.0. Works OK.
Trying snapshot 20231113. Frameworks 5.112. 0. Not OK.
Comment 3 Albert Astals Cid 2023-12-01 10:31:23 UTC
Caused by https://invent.kde.org/frameworks/kio/-/merge_requests/1457
Comment 4 Bug Janitor Service 2023-12-10 08:59:31 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/kio/-/merge_requests/1508
Comment 5 Kevin Ottens 2023-12-10 09:10:27 UTC
So now we got a MR for KIO which should fix this. Indeed, Lokalize seems to exploit a corner case in KDirModel's API and the previous patch slightly changed the behavior for this particular case.

This being said, it's one of those where I think we can consider the bug "shared" between KDirModel and Lokalize. It looks like this just uncovered another bug in Lokalize itself, I suspect it didn't really work as it should previously and might have cases where it'd break anyway. 

Indeed, the project model wrapping KDirModel in Lokalize seems to use rowCount but not canFetchMore/fetchMode to decide to go one level down the hierarchy. This is a bit optimistic in the general case since models (like KDirModel) can decide to not eagerly fetch children nodes. Also it set an invalid url as the root of the model which is allowed but I think a bit fishy.

I don't know Lokalize enough to feel confident investing the time to look deeper into how this project model works, I'd probably just unwillingly break it. Also, the MR in KIO does the job for now... still revisiting the project model in Lokalize might be worth it at some point.
Comment 6 Freek de Kruijf 2024-01-22 16:02:52 UTC
(In reply to Kevin Ottens from comment #5)
> So now we got a MR for KIO which should fix this. Indeed, Lokalize seems to
> exploit a corner case in KDirModel's API and the previous patch slightly
> changed the behavior for this particular case.
> 
> This being said, it's one of those where I think we can consider the bug
> "shared" between KDirModel and Lokalize. It looks like this just uncovered
> another bug in Lokalize itself, I suspect it didn't really work as it should
> previously and might have cases where it'd break anyway. 
> 
> Indeed, the project model wrapping KDirModel in Lokalize seems to use
> rowCount but not canFetchMore/fetchMode to decide to go one level down the
> hierarchy. This is a bit optimistic in the general case since models (like
> KDirModel) can decide to not eagerly fetch children nodes. Also it set an
> invalid url as the root of the model which is allowed but I think a bit
> fishy.
> 
> I don't know Lokalize enough to feel confident investing the time to look
> deeper into how this project model works, I'd probably just unwillingly
> break it. Also, the MR in KIO does the job for now... still revisiting the
> project model in Lokalize might be worth it at some point.

The problem is still present in the current version of openSUSE Tumbleweed with KDE Frameworks 
Version 5.114.0
Comment 7 Kevin Ottens 2024-01-22 16:15:10 UTC
To be expected, nobody reviewed the patch, feels like it fell through the cracks. I'll poke.
Comment 8 Kevin Ottens 2024-01-23 08:58:21 UTC
Git commit 01a9c8c06dec7d748ed964c9e2f2c4091f9c125a by Kevin Ottens, on behalf of Kevin Ottens.
Committed on 23/01/2024 at 09:46.
Pushed by ervin into branch 'master'.

KDirModel: Consider invalid roots are local fs

If the item set on a node (typically the root node) was null it was
implicitly considered local fs. But if the item was not null and the
url invalid, it'd be considered network fs.

In the context of KDirModel caching of the fs type guessing this would
mean we'd wrongly assume the whole tree is network fs even if it's not.

That's why we change this to consider non-null items with invalid URLs
as local fs.

M  +5    -1    src/widgets/kdirmodel.cpp

https://invent.kde.org/frameworks/kio/-/commit/01a9c8c06dec7d748ed964c9e2f2c4091f9c125a
Comment 9 Albert Astals Cid 2024-01-25 21:23:51 UTC
Git commit 9d69638746703ee2f59d3d5e986edfb172960bb6 by Albert Astals Cid, on behalf of Kevin Ottens.
Committed on 25/01/2024 at 22:23.
Pushed by aacid into branch 'kf5'.

KDirModel: Consider invalid roots are local fs

If the item set on a node (typically the root node) was null it was
implicitly considered local fs. But if the item was not null and the
url invalid, it'd be considered network fs.

In the context of KDirModel caching of the fs type guessing this would
mean we'd wrongly assume the whole tree is network fs even if it's not.

That's why we change this to consider non-null items with invalid URLs
as local fs.
(cherry picked from commit 01a9c8c06dec7d748ed964c9e2f2c4091f9c125a)

M  +5    -1    src/widgets/kdirmodel.cpp

https://invent.kde.org/frameworks/kio/-/commit/9d69638746703ee2f59d3d5e986edfb172960bb6
Comment 10 Freek de Kruijf 2024-02-07 16:37:15 UTC
The problem still exists. Maybe my setup is the culprit.
I have in $HOME a symbolic link to the real location of the folder with the KDE translation folders.
Comment 11 Albert Astals Cid 2024-02-07 20:35:34 UTC
Are you using KIO 5.115 or newer?
Comment 12 Freek de Kruijf 2024-02-07 22:13:34 UTC
I am using kio-5.114.0-2.2 from the repository of openSUSE Tumbleweed
Comment 13 Albert Astals Cid 2024-02-07 22:58:40 UTC
Then you don't have the fix.