Bug report #3714

Qt arguments are not supported

Added by Martin Dobias over 13 years ago. Updated over 5 years ago.

Status:Closed
Priority:Low
Assignee:-
Category:GUI
Affected QGIS version:master Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:Yes Resolution:end of life
Crashes QGIS or corrupts data:No Copied to github as #:13773

Description

QApplication is able to parse some useful command line arguments such as -style, -stylesheet, -session or -graphicssystem, but QGIS does not support them because it parses arguments before Qt has a chance to check (and remove) them. Instead it complains about invalid arguments.

(Additionally it would be good to unify handling of arguments for unix and windows.)

Associated revisions

Revision 42ea15b3
Added by Martin Dobias almost 9 years ago

Merge pull request #2496 from SebDieBln/App_OptionsAsFiles

Accept option '--' to mark all following arguments as files (refs #3714)

History

#1 Updated by Giovanni Manghi almost 13 years ago

  • Target version changed from Version 1.7.0 to Version 1.7.4

#2 Updated by Paolo Cavallini over 12 years ago

  • Target version changed from Version 1.7.4 to Version 1.8.0
  • Affected QGIS version set to master
  • Crashes QGIS or corrupts data set to No

#3 Updated by Paolo Cavallini about 12 years ago

  • Target version changed from Version 1.8.0 to Version 2.0.0

#4 Updated by Jürgen Fischer over 10 years ago

  • Target version changed from Version 2.0.0 to Future Release - Lower Priority

#5 Updated by Médéric RIBREUX almost 9 years ago

  • % Done changed from 0 to 50
  • Status changed from Open to Feedback
  • Assignee deleted (nobody -)
  • Pull Request or Patch supplied set to No

Hello, bug triage...

something has been done on this bug because I am able to launch QGIS 2.13 master with the -reverse QApplication argument. With this option, QGIS menus and panels are oriented from right to left (or inverse). So it seems that QApplication arguments are used by QGIS application.

But with this option, QGIS still complains about the fact that the layer ~/-reverse is not valid !

We need a better QApplication argument detection (and management)...

#6 Updated by Sebastian Dietrich almost 9 years ago

If I am right, the cause for this issue is some two step initialization: So when given the -reverse argument, it is:
  • ignored by QCoreApplication
  • evaluated by QGIS, leading to the mentioned complaint
  • accepted by QgsApplication via inheritance of QApplication

thus leading to a complaint and the expected behaviour.

See PR 2491 for a possible solution.

#7 Updated by Sebastian Dietrich almost 9 years ago

There are two other interesting questions here:
  • How do I specify a layer by the name of -reverse (preventing QApplication from interpreting it)?
  • How do I specify a layer by the name of --help (preventing QGIS from interpreting it)?

#8 Updated by Sebastian Dietrich almost 9 years ago

Looking at the Qt sources it appears there is no simple solution for -reverse and other Qt options. QApplication always parses all arguments, eating up all it can handle.

For --help and other QGIS options see PR 2496, introducing '--' as an additional option to mark all following arguments as files.

#9 Updated by Giovanni Manghi almost 9 years ago

  • Status info deleted (0)
  • Status changed from Feedback to Open
  • Operating System deleted (All)

#10 Updated by Sebastian Dietrich almost 9 years ago

  • % Done changed from 50 to 70
  • Pull Request or Patch supplied changed from No to Yes

#11 Updated by Martin Dobias almost 9 years ago

Thanks for the work, Sebastian!

I think my preference would be to defer solving this to QGIS 3 for two reasons:

- Qt5 comes with nice and shiny QCommandLineParser class to do parsing for us
- bootstrapping of QGIS is already quite complicated. I would like to simplify it, see https://github.com/qgis/qgis3.0_api/issues/9

#12 Updated by Sebastian Dietrich almost 9 years ago

QCommandLineParser really looks promising!

How do you feel about merging only PR 2496? It implements the same behaviour like QCommandLineParser, which will treat everything after the option -- (double dash) as positional arguments.

#13 Updated by Martin Dobias almost 9 years ago

Sounds good - I have merged PR 2469 and let's keep the other PR open...

#14 Updated by Sebastian Dietrich almost 9 years ago

Martin Dobias wrote:

Sounds good - I have merged PR 2469 and let's keep the other PR open...

Thanks, that makes sense.

#15 Updated by Giovanni Manghi over 7 years ago

  • Regression? set to No
  • Easy fix? set to No

#16 Updated by Giovanni Manghi over 5 years ago

  • Status changed from Open to Closed
  • Resolution set to end of life

Also available in: Atom PDF