Three points in u_dzDefaultMain:
In Main, an exception from MainClass.Create or from the destructor is logged with LogError('Exception in function Main: ...') and then passed to TDefaultMain.ReportException, which logs it again (LogError('Exception: ...')). Every such exception appears twice in the log. Expected: one entry.
The doc comment of RegisterConsoleOption says that an option --console registered by the program itself "then wins". But Create sets ConsoleOnly from ConsoleSwitchPassed regardless, so a program whose own --console means something else still gets ConsoleOnly = True. Either the doc or the behaviour should change.
HasConsoleSwitch also finds --console after the first plain parameter, e.g. prog input.txt --console, where TGetOpt no longer accepts options: it raises ETooManyParams for it, or, if a parameter takes any number of values, passes --console on as a parameter value while ConsoleOnly is still set. The test TestAmongOtherParams expects exactly this, so it may be intended (a misplaced --console should still keep the error message out of a dialog). If so, it would be worth a sentence in the doc comment of HasConsoleSwitch.
Found by a code review.
Fixed in revision [r2490].
Related
Commit: [r2490]
Note on the change in [r2490] and [r2492]:
--consoleonly counts whereTGetOpttakes options, i.e. before the first parameter. A misplaced switch such asprog input.txt --consoleno longer setsConsoleOnly, so the errorTGetOptreports for it is shown in a dialog, also by a console program. Before, it only went to the console, so an unattended run with such a command line can now block. This is intended and is documented in the doc comments ofHasConsoleSwitchandConsoleOnly.Related
Commit: [r2490]
Commit: [r2492]