Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Command line option -c changes default config file #699

Closed
frankystone opened this issue Nov 19, 2024 · 11 comments
Closed

Command line option -c changes default config file #699

frankystone opened this issue Nov 19, 2024 · 11 comments
Labels
bug Something isn't working

Comments

@frankystone
Copy link

Describe the bug

When switching between v 1.17.1 and the porting_qt6 branch i have always issues with german umlauts which confuses QMS. See an example here: #648 (comment) .
So i wanted to use different config files for both versions. Looking at the command line options i found the -c or --config option. But it seems starting QMS does not respect this option, because the default config file located at ~/.config/QLandkarte/QMapShack.conf will be changed anyway.

What have you done to circle down the problem?

The problem seems to be that the default config file is read and saved when QMS v 1.17.1 is started.

To Reproduce

  1. Open the default config file in a texteditor which is able to check for file changes (i used KDE kate)
  2. Start version 1.17.1 with option -c, e.g. qmapshack -c ~/.config/qmpshack_v1_17.conf
  3. switch to the texteditor
  4. the texteditor might show that the file has changed and ask for reload

In my case of german umlauts e.g. the entry demPaths in the default config file will change just by starting v 1.17.1. (diff):

-demPaths=/home/kaputtnik/Dokumente/qmapshack/Höhendaten
+demPaths=/home/kaputtnik/Dokumente/qmapshack/H\xc3\xb6hendaten

After closing QMS v 1.17.1 the config file given at the command line will be written.

Expected behavior

The commandline option should only touch the new config file given at the command line.

Screenshots

Attachments

Tracebacks

Desktop

  • OS: archlinux
  • QMapShack Version: 1.17.1
  • Window Manager: KDE

Additional context

@frankystone frankystone added the bug Something isn't working label Nov 19, 2024
@kiozen
Copy link
Collaborator

kiozen commented Nov 20, 2024

The default config file is touched but should not be changed. You can test by creating a copy of the default config, start QMS with a local config. After closing QMS you can make a diff of the saved file and the actual config. There should be no difference.

@frankystone
Copy link
Author

Here is the diff:

diff /home/kaputtnik/.config/QLandkarte/QMapShack.conf /home/kaputtnik/.config/QLandkarte/QMapShack.conf.bak
42,62c42
< Views\Kont%26uren\dem\active=e5732688ea23503f83776345d1f10e0b
< Views\Kont%26uren\dem\e5732688ea23503f83776345d1f10e0b\doElevationLimit=false
< Views\Kont%26uren\dem\e5732688ea23503f83776345d1f10e0b\doElevationShading=false
< Views\Kont%26uren\dem\e5732688ea23503f83776345d1f10e0b\doHillshading=true
< Views\Kont%26uren\dem\e5732688ea23503f83776345d1f10e0b\doSlopeColor=false
< Views\Kont%26uren\dem\e5732688ea23503f83776345d1f10e0b\doSlopeShading=false
< Views\Kont%26uren\dem\e5732688ea23503f83776345d1f10e0b\elevationShadeLimitHi=0
< Views\Kont%26uren\dem\e5732688ea23503f83776345d1f10e0b\elevationShadeLimitLow=0
< Views\Kont%26uren\dem\e5732688ea23503f83776345d1f10e0b\elevationValue=0
< Views\Kont%26uren\dem\e5732688ea23503f83776345d1f10e0b\factorHillshading=0.1666666716337204
< Views\Kont%26uren\dem\e5732688ea23503f83776345d1f10e0b\factorSlopeShading=1
< Views\Kont%26uren\dem\e5732688ea23503f83776345d1f10e0b\gradeSlopeColor=0
< Views\Kont%26uren\dem\e5732688ea23503f83776345d1f10e0b\maxScale=1e+12
< Views\Kont%26uren\dem\e5732688ea23503f83776345d1f10e0b\minScale=1e+12
< Views\Kont%26uren\dem\e5732688ea23503f83776345d1f10e0b\opacity=17
< Views\Kont%26uren\dem\e5732688ea23503f83776345d1f10e0b\showElevationShadeScale=false
< Views\Kont%26uren\dem\e5732688ea23503f83776345d1f10e0b\slopeCustomValue0=5
< Views\Kont%26uren\dem\e5732688ea23503f83776345d1f10e0b\slopeCustomValue1=10
< Views\Kont%26uren\dem\e5732688ea23503f83776345d1f10e0b\slopeCustomValue2=15
< Views\Kont%26uren\dem\e5732688ea23503f83776345d1f10e0b\slopeCustomValue3=20
< Views\Kont%26uren\dem\e5732688ea23503f83776345d1f10e0b\slopeCustomValue4=25
---
> Views\Kont%26uren\dem\active=@Invalid()
145c125
< demPaths=/home/kaputtnik/Dokumente/qmapshack/H\xc3\xb6hendaten
---
> demPaths=/home/kaputtnik/Dokumente/qmapshack/Höhendaten
157c137
< visibleCanvas=0
---
> visibleCanvas=2
211c191
< state=@ByteArray(\0\0\0\xff\0\0\0\0\xfd\0\0\0\x2\0\0\0\0\0\0\0\xdb\0\0\x3\xb9\xfc\x2\0\0\0\x3\xfb\0\0\0\x10\0\x64\0o\0\x63\0k\0M\0\x61\0p\0s\x1\0\0\0L\0\0\x3\xb9\0\0\0\x9d\0\xff\xff\xff\xfb\0\0\0\xe\0\x64\0o\0\x63\0k\0\x44\0\x65\0m\0\0\0\x2\x15\0\0\x1\xf0\0\0\0\xcd\0\xff\xff\xff\xfb\0\0\0\xe\0\x64\0o\0\x63\0k\0P\0o\0i\0\0\0\x2\x5\0\0\x1\xdc\0\0\0\\\0\xff\xff\xff\0\0\0\x1\0\0\x1G\0\0\x3\xb9\xfc\x2\0\0\0\x4\xfb\0\0\0\x1a\0\x64\0o\0\x63\0k\0W\0o\0r\0k\0s\0p\0\x61\0\x63\0\x65\x1\0\0\0L\0\0\x3\xb9\0\0\0\x8d\0\xff\xff\xff\xfb\0\0\0\x18\0\x64\0o\0\x63\0k\0\x44\0\x61\0t\0\x61\0\x62\0\x61\0s\0\x65\0\0\0\x1V\0\0\0\xba\0\0\0\xb3\0\xff\xff\xff\xfb\0\0\0\xe\0\x64\0o\0\x63\0k\0R\0t\0\x65\0\0\0\x1\x97\0\0\x2n\0\0\0\xf7\0\xff\xff\xff\xfb\0\0\0\x18\0\x64\0o\0\x63\0k\0R\0\x65\0\x61\0l\0t\0i\0m\0\x65\x2\0\0\x4\x87\0\0\x1\xd4\0\0\x2\xf9\0\0\x2M\0\0\x5\\\0\0\x3\xb9\0\0\0\x4\0\0\0\x4\0\0\0\b\0\0\0\b\xfc\0\0\0\x1\0\0\0\x2\0\0\0\x1\0\0\0\xe\0t\0o\0o\0l\0\x42\0\x61\0r\x1\0\0\0\0\xff\xff\xff\xff\0\0\0\0\0\0\0\0)
---
> state=@ByteArray(\0\0\0\xff\0\0\0\0\xfd\0\0\0\x2\0\0\0\0\0\0\0\xdb\0\0\x3\xb9\xfc\x2\0\0\0\x3\xfb\0\0\0\x10\0\x64\0o\0\x63\0k\0M\0\x61\0p\0s\x1\0\0\0L\0\0\x1\xc8\0\0\0\xcd\0\xff\xff\xff\xfb\0\0\0\xe\0\x64\0o\0\x63\0k\0\x44\0\x65\0m\x1\0\0\x2\x15\0\0\x1\xf0\0\0\0\xcd\0\xff\xff\xff\xfb\0\0\0\xe\0\x64\0o\0\x63\0k\0P\0o\0i\0\0\0\x2\x5\0\0\x1\xdc\0\0\0\\\0\xff\xff\xff\0\0\0\x1\0\0\x1G\0\0\x3\xb9\xfc\x2\0\0\0\x4\xfb\0\0\0\x1a\0\x64\0o\0\x63\0k\0W\0o\0r\0k\0s\0p\0\x61\0\x63\0\x65\x1\0\0\0L\0\0\x3\xb9\0\0\0\x8d\0\xff\xff\xff\xfb\0\0\0\x18\0\x64\0o\0\x63\0k\0\x44\0\x61\0t\0\x61\0\x62\0\x61\0s\0\x65\0\0\0\x1V\0\0\0\xba\0\0\0\xb3\0\xff\xff\xff\xfb\0\0\0\xe\0\x64\0o\0\x63\0k\0R\0t\0\x65\0\0\0\x1\x97\0\0\x2n\0\0\0\xf7\0\xff\xff\xff\xfb\0\0\0\x18\0\x64\0o\0\x63\0k\0R\0\x65\0\x61\0l\0t\0i\0m\0\x65\x2\0\0\x4\x87\0\0\x1\xd4\0\0\x2\xf9\0\0\x2M\0\0\x5\\\0\0\x3\xb9\0\0\0\x4\0\0\0\x4\0\0\0\b\0\0\0\b\xfc\0\0\0\x1\0\0\0\x2\0\0\0\x1\0\0\0\xe\0t\0o\0o\0l\0\x42\0\x61\0r\x1\0\0\0\0\xff\xff\xff\xff\0\0\0\0\0\0\0\0)
229c209
< source0\filename=Eine Datei f\xc3\xbcr die Aufzeichnung ausw\xc3\xa4hlen.
---
> source0\filename=Eine Datei für die Aufzeichnung auswählen.
319c299
< webServices\6\name=Campingpl\xc3\xa4tze
---
> webServices\6\name=Campingplätze
433c413
< sourcePath=/home/kaputtnik/Dokumente/qmapshack/H\xc3\xb6hendaten/sonny
---
> sourcePath=/home/kaputtnik/Dokumente/qmapshack/Höhendaten/sonny
435c415
< targetPath=/home/kaputtnik/Dokumente/qmapshack/H\xc3\xb6hendaten
---
> targetPath=/home/kaputtnik/Dokumente/qmapshack/Höhendaten

@frankystone
Copy link
Author

It even get worth if i switch between v 1.17.1 and porting_qt6 often. The lines get longer.

  • start v1.17.1 with -c
  • start porting_qt6
  • start v1.17.1 with -c again

The diff becomes:

$:> diff /home/kaputtnik/.config/QLandkarte/QMapShack.conf /home/kaputtnik/.config/QLandkarte/QMapShack.conf.bak
125c125
< demPaths=/home/kaputtnik/Dokumente/qmapshack/H\xc3\x83\xc2\xb6hendaten
---
> demPaths=/home/kaputtnik/Dokumente/qmapshack/Höhendaten
209c209
< source0\filename=Eine Datei f\xc3\x83\xc2\xbcr die Aufzeichnung ausw\xc3\x83\xc2\xa4hlen.
---
> source0\filename=Eine Datei für die Aufzeichnung auswählen.
299c299
< webServices\6\name=Campingpl\xc3\x83\xc2\xa4tze
---
> webServices\6\name=Campingplätze
413c413
< sourcePath=/home/kaputtnik/Dokumente/qmapshack/H\xc3\x83\xc2\xb6hendaten/sonny
---
> sourcePath=/home/kaputtnik/Dokumente/qmapshack/Höhendaten/sonny
415c415
< targetPath=/home/kaputtnik/Dokumente/qmapshack/H\xc3\x83\xc2\xb6hendaten
---
> targetPath=/home/kaputtnik/Dokumente/qmapshack/Höhendaten

@kiozen
Copy link
Collaborator

kiozen commented Nov 20, 2024

I can't reproduce. If I do

qmapshack -c test.cf

The file in

~/.config/QLandkarte/QMapShack.conf

does not change

@frankystone
Copy link
Author

Hm, either i am doing something terribly wrong, or my system is somehow broken.

But thanks for testing…

@frankystone
Copy link
Author

Can't help myself, the file get changed. I've tried it now the other way around. Before this test i renamed the default config to have a clean one.

  • started v1.17.1
  • added a realtime source, nothing else
  • closed v.1.17.1

The default config is written and contains the section [Realtime], the content is as follows:

[Realtime]
numberOfSources=1
source0\callsign=
source0\checkState=2
source0\filename=Eine Datei f\xfcr die Aufzeichnung ausw\xe4hlen.
[...]

Made a backup of the conf file named ~/.config/QLandkarte/QMapShack1_17_1.conf.
Then started the porting_qt6 branch. Probably important: the new config file, qm.conf in this case, shouldn't exist at this time:

$:> build_QMapShack/bin/qmapshack -c ~/qm.conf

After closing QMS the default config has changed, while my text editor says the file has changed just after starting QMS from porting_qt6:

$:> diff QMapShack1_17_1.conf QMapShack.conf
83c83
< source0\filename=Eine Datei f\xfcr die Aufzeichnung ausw\xe4hlen.
---
> source0\filename=Eine Datei für die Aufzeichnung auswählen.

Can you at least confirm the sentence Eine Datei f\xfcr die Aufzeichnung ausw\xe4hlen.?

@frankystone
Copy link
Author

Used QTCreator and debugged step by step. The default config will be written along those lines:

QSettings cfg;
cfg.setValue("Units/type", t);

unfortunately i can't look into cfg because QtCreator says it is unreachable… and i do not understand why this variable should contain any values, isn't it just an empty QSettings object at this time?

@frankystone
Copy link
Author

ok, with this changes the default config will not be written anymore:

diff --git a/src/qmapshack/units/IUnit.cpp b/src/qmapshack/units/IUnit.cpp
index 96b7a454..1cca304a 100644
--- a/src/qmapshack/units/IUnit.cpp
+++ b/src/qmapshack/units/IUnit.cpp
@@ -21,6 +21,7 @@
 #include "CMainWindow.h"
 #include "gis/GeoMath.h"
 #include "gis/proj_x.h"
+#include "helpers/CSettings.h"
 #include "units/CUnitAviation.h"
 #include "units/CUnitImperial.h"
 #include "units/CUnitMetric.h"
@@ -603,7 +604,7 @@ void IUnit::setUnitType(type_e t, QObject* parent) {
       break;
   }
 
-  QSettings cfg;
+  SETTINGS;
   cfg.setValue("Units/type", t);
 }

@kiozen
Copy link
Collaborator

kiozen commented Nov 21, 2024

Oops. What a bug. Nice catch! Can you provide a pull request please?

@frankystone
Copy link
Author

Will do this evening.

@kiozen
Copy link
Collaborator

kiozen commented Nov 21, 2024

Do the fix on the based on the dev branch (create branch from dev in your repository ) When merged I will rebase the porting_qt6 branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants