Details
-
Bug
-
Resolution: Done
-
P4: Low
-
No Version
-
None
-
Windows
-
Fixed in Qt, change ff18b8e80609da91bf9e9134967dcf0d23eca9e (qtbase/dev, 5.2.2015, Qt 5.5)
Description
At least following problems were found when specifying service arguments to a Windows service:
1) When you start the service from Control Panel and the Windows registry ImagePath entry contains service arguments they are not forwarded to the created QCoreApplication. The arguments are forwarded to the service's main() function, but they are overwritten in QtServiceBasePrivate::start() (qt-solutions-qt-solutions\qtservice\src\qtservice_win.cpp, line 811) with the arguments received in WinAPI ServiceMain() callback function just before the QCoreApplication is created.
2) When the service is started from command line with myService.exe -exec /myArg=123, then you cannot use QCoreApplication::arguments(), because the -exec argument is removed in QtServiceBase::exec() function before creating the QCoreApplication. Now, QCoreApplication assumes that the arguments forwarded to its constructor equal with the command line arguments, but they don't and this gives invalid results (and an assert Q_ASSERT(allArguments.size() == origArgc) in debug).
I was reported that both of the above scenarios have previously worked (with Qt 4).
Steps to reproduce:
- Build & deploy \qt-solutions\qtservice\examples\server [with diagnostic patch]
- Open Administrator prompt
- Install service \qt-solutions\qtservice\examples\server\httpservice[4/5] -i
- Open control panel/services
- On Qt HTTP test service, right click properties
- Enter start parameters like p1 p2
- Give commands 1,2, to service: \qt-solutions\qtservice\examples\server\httpservice[4/5] -c [1/2]
- Press "Start" button in group box where parameters are - the setting is not persistent
- Examine log files c:\service-debuglog[qt_version].txt
Attachments
Issue Links
- relates to
-
QTBUG-30330 Windows: assertion if you pass QApplication arguments that are not exactly those retrieved by GetCommandLine()
- Closed