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
For Gerrit Dashboard: QTSOLBUG-184 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
103240,7 | Windows: Allow for passing a modified argv to QCoreApplication. | dev | qt/qtbase | Status: MERGED | +2 | 0 |
103460,6 | Qt Service: Fix compilation with Qt 5 with define QTSERVICE_DEBUG. | master | qt-solutions/qt-solutions | Status: MERGED | +2 | 0 |
103496,2 | Qt Service/Windows: Fix compilation with Qt 5 / QTSERVICE_DEBUG. | master | qt-solutions/qt-solutions | Status: MERGED | +2 | 0 |