Hello Mihai,
The list is never empty, it have at least 1. argument - it is always executable name. I'll leave my solution here, because in a case of linux or mac if x2goclient started without arguments list don't need to be initialized. Actually, I can change argc<=1 to argc ==1 but in this case it make no difference.
regards, Alex
Am 27.06.2014 16:30, schrieb Mihai Moldovan:
I would so reject this patch. It's logically flawed.
First: 106 QStringList args; 107 if ( argc > 1 ) 108 args=app.arguments();
Later: 154 if(argc <=1) 155 { 156 args=app.arguments(); 157 }
Remove those two occurrences and use: 106 QStringList args; 107 args=app.arguments();
The baseline issue has been args not populated with app.arguments(). It wasn't uninitialized, but empty.
An empty list is basically fine, but this will crash: 161 QString executable=args[0]; 162 args.pop_front();
args[0] is not defined in that case.
Even worse: the Qt documentation for pop_front() specifies: "The list must not be empty."
Please, use proper logic and always set args to app.arguments() without this nonsensical if (argc > 1) ... if (argc <= 1) tautology in two different places.
- On 27.06.2014 03:38 pm, Michael DePaulo wrote:
However, Ionic and I were taking a look at the code last night, and we did not understand why "--child-process" is being added to the args list. It looks like you are adding it when it does not exist in the list. If so, why not just hardcode the behavior that --child-process invokes?
Having had a closer look at the code in question, adding --child-process is fine. It's only added to the forked process's argument list. You can't hardcode the behavior of --child-process, as it's not supposed to be used when you start x2goclient.exe "normally". In contrast, --child-process lets you determine whether a process is the forked child process, or rather the manually by the user started main process.
Feel free to ignore this section, Alex.
Mihai
Oleksandr Shneyder | Email: o.shneyder@phoca-gmbh.de phoca GmbH | Tel. : 0911 - 14870374 0 Ludwig-Feuerbach-str. 18 | Fax. : 0911 - 14870374 9 D-90489 Nürnberg | Mobil: 0163 - 49 64 461
Geschäftsführung: Dipl.-Inf. Oleksandr Shneyder