[Qt-interest] Can you spot my mistake.
Constantin Makshin
dinosaur-rus at users.sourceforge.net
Mon Aug 24 18:24:01 CEST 2009
IMHO, "ignore what you don't understand" is a bad idea.
Imagine that the user made a typo in one of the command line arguments. If
your application displays a message like "Invalid command line argument:
foo" and exits without changing anything, the user can check what [s]he
entered and fix the typo. But if the application ignores wrong arguments,
even if it displays a warning message and continues, the application may
do something that the used didn't want to do and that may lead to data
corruption (from the user's point of view, changing his/her data in an
unexpected way is equal to corruption) or even data loss.
On Mon, 24 Aug 2009 20:07:43 +0400, Andrew Hodgkinson
<ahodgkinson at endurancetech.co.uk> wrote:
> On 24/08/2009 15:53, Thomas Dähling wrote:
>> Personally I am even curious why it is not doing a simple value copy
>> of argc anyway? I do not see a specific reason for passing a reference
>> there.
>
> Since QApplication can modify the argument list, it can't do a simple
> copy, given that, as presently designed, it wants to make sure that the
> calling application gets a sanitised list of arguments afterwards.
> Otherwise, if it deletes arguments (which it does), the value of argc
> would no longer match the corresponding argv and code examining the
> arguments after the QApplication object instantiation would end up
> running off the end of the now-shorter list.
>
> An arguably cleaner alternative might have been to pass read-only
> arguments to QApplication. If the caller wanted to examine the arguments,
> they'd always get all of them - both Qt-understood and self-defined
> arguments all mixed together. Big deal; ignore options you don't
> understand. But QApplication could also provide an interface to getting
> at any of the arguments it didn't consume, making life easier for the
> application developer, perhaps using an approach similar to some of the
> C++ getopt()-on-steroids libraries out there.
--
Constantin "Dinosaur" Makshin
More information about the Qt-interest-old
mailing list