Bug 361132 - kmahjongg 16.04 fails to start after migrating KDE4 configuration
Summary: kmahjongg 16.04 fails to start after migrating KDE4 configuration
Alias: None
Product: kmahjongg
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR major with 1 vote (vote)
Target Milestone: ---
Assignee: Unassigned bugs mailing-list
: 364646 (view as bug list)
Depends on:
Reported: 2016-03-29 10:28 UTC by Antonio Rojas
Modified: 2016-07-01 13:13 UTC (History)
11 users (show)

See Also:
Latest Commit:
Version Fixed In: 16.04.3

Minimal config file (74 bytes, text/plain)
2016-03-30 10:21 UTC, Antonio Rojas

Note You need to log in before you can comment on or make changes to this bug.
Description Antonio Rojas 2016-03-29 10:28:00 UTC
If you have configuration files from the KDE4 version of kmahjongg, the KF5 version will fail to start. The terminal is flooded with 

log_kmahjongg: Set a new Background: "/usr/share/apps/kmahjongglib/backgrounds/default.desktop"
log_libkmahjongg: Using background at "/usr/share/kmahjongglib/backgrounds/egyptian.svgz"
log_kmahjongg: Error loading the layout. Try to load the default layout.
log_kmahjongg: Inside LoadDefault(), located layout at "/usr/share/kmahjongg/layouts/default.desktop"
log_kmahjongg: Using layout at "/usr/share/kmahjongg/layouts/default.layout"
log_kmahjongg: Set a new Background: "/usr/share/apps/kmahjongglib/backgrounds/default.desktop"

It seems that the config migration doesn't take into account the different location of the data files in the kf5 version of libkmahjongg. After migration, ~/.config/kmahjonggrc contains the lines:


But in KF5 those files are located in /usr/share/kmahjongg{lib} instead. This seems to confuse the application.

Reproducible: Always

Steps to Reproduce:
1. Upgrade from kmahjongg 15.12 to 16.04 (make sure kmahjongg has been started so there is a config file in ~/.kde)
2. Start kmahjongg
Comment 1 Frederik Schwarzer 2016-03-30 10:10:12 UTC
Uh, that's bad. :(

Can you (or somebody else) please attach kde4 config files for me to test?
Comment 2 Antonio Rojas 2016-03-30 10:21:52 UTC
Created attachment 98152 [details]
Minimal config file

Put this file in ~/.kde4/share/config/ and remove ~/.config/kmahjonggrc, then try to start kmahjongg
Comment 3 Frederik Schwarzer 2016-03-30 11:37:44 UTC
Hmm, for me that works just fine.
On first start I get similar output as yours but the game starts. On second start, the output shrinks down a few error messages and the game also starts.
If the paths are wrong, the loading falls back to a default. It should load the game fine, though.

After the first start my config file starts with:
  1 [General]
  2 Background_file=/home/fs/kde5apps/share/kmahjongglib/backgrounds/egyptian.desktop
  3 Layout_file=/home/fs/kde5apps/share/kmahjongg/layouts/default.desktop
  4 Tileset_file=/home/fs/kde5apps/share/kmahjongglib/tilesets/default.desktop

I changed some background-related stuff in libkmahjongg in November.

Might that be related?

Since I do not have access to a distro package of the new KMahjongg yet, I can only test with the Git version. And there I cannot yet reproduce the problem.

Can someone else please check on their system?
Comment 4 Antonio Rojas 2016-03-30 19:00:53 UTC
Strange, this is with plain 16.04 beta, no patches, so it shouldn't be much different from current git. Other Arch users have reported the same issue.
Comment 5 Michael Palimaka 2016-04-02 13:51:25 UTC
I was able to reproduce using the git version.
Comment 6 Frederik Schwarzer 2016-04-02 17:54:21 UTC
What am I doing wrong?

I do:
- copy the file attached earlier to ~.kde/share/config/kmahjonggrc,
- change the path inside the file to the location of the desktop file on my system (resides under $HOME),
- remove .config/kmahjonggrc and then
- start KMahjongg.

KMahjongg starts fine and the new kmahjonggrc file is created in .config/ with the correct layout.
Comment 7 Frederik Schwarzer 2016-04-02 18:06:31 UTC
Now I removed the whole install dir and the build dirs of libkdegames, libkmahjongg and kmahjongg, rebuilt everything and still the same. Here it starts fine.
Comment 8 Antonio Rojas 2016-04-02 21:21:44 UTC
Simpler steps to reproduce: open ~/.config/kmahjonggrc, and point Layout_file to a non-existant path. The KDE4 settings migration is just the trigger here.
Comment 9 Frederik Schwarzer 2016-04-02 21:50:56 UTC
Ah, thanks. Now I can reproduce.
Comment 10 Wolfgang Bauer 2016-06-23 16:59:12 UTC
*** Bug 364646 has been marked as a duplicate of this bug. ***
Comment 11 Frederik Schwarzer 2016-06-23 19:26:08 UTC
I am sorry about this problem. It did not occur on my box when I ported KMahjongg.

Two months ago I tried to debug this but got confused by all the locations stuff can be put to (by CMake) and looked for (by Qt). Currenty I am in the process of finding a flat in another city and starting a new job so in the coming weeks (or small number of months) I am likely not able to sit down for this again.
Comment 12 Wolfgang Bauer 2016-06-23 20:07:01 UTC
I had a look at the problem today, and this should fix it:

Ideally, kmahjongg would try to adjust the path though IMHO, e.g. try to load $XDG_DATA_DIRS/kmahjongg/layouts/FILENAME_WITHOUT_PATH before falling back to the default.
Currently, the KDE4 migration basically resets the layout, background and tileset because the paths have changed.
Comment 13 Wolfgang Bauer 2016-07-01 11:31:49 UTC
Git commit 22600c69edbf59bc83377e3b96e3899ba935b1a3 by Wolfgang Bauer.
Committed on 01/07/2016 at 11:30.
Pushed by wbauer into branch 'Applications/16.04'.

Fix endless loop when configured layout cannot be loaded

Adjust the configured layout when the default is loaded as fallback.
Otherwise loadSettings() will think that the layout has been changed in
the settings, load the layout again and call startNewGame(), which in
turn calls loadSettings() again, resulting in an endless loop.
FIXED-IN: 16.04.3
REVIEW: 128279

M  +1    -0    kmahjongg.cpp