[Qt Message] exception on 3 [will close the socket handle - hack]
-
I got such an exception above. It seems the app will close the socket handle instead of closing by me.
I use the get() function of QNetworkAccessManager to get a url. and then deal with the data the url return.
@
void MainWindow::on_cityComboBox_currentIndexChanged(int index)
{
QTextCodec::setCodecForCStrings(QTextCodec::codecForName("GB2312"));
QString url="http://www.google.com/ig/api?hl=zh_cn&weather=";
QString localPlace=ui->cityComboBox->currentText();
ui->locaPlace->setText(localPlace);//add the place to the label-localPlace
url.append(localPlace);
manager =new QNetworkAccessManager(this);
manager->get(QNetworkRequest(QUrl(url)));
connect(manager,SIGNAL(finished(QNetworkReply*)),this,SLOT(replyFinish(QNetworkReply*)));}
@I connect my Nokia 5230 to my computer and the app run on it.
It seems work well on it when my app is running.But when I close the app,the application output window come to such "[Qt Message] exception on 3 [will close the socket handle - hack]"Any one meet such a problem? Any suggestion?
-
Thanks for your reply.
How to close the socket?
I only use the QNetworkAccessManager and QNetworkReply of the network classes.
As said above,I only use the get() function of QNetworkAccessManager to get a url,and deal with the data that the url reply with the QNetworkReply.and I don't know how to locate the message,either because I don't know how the problem appeared
-
[quote author="hisong1988" date="1290359270"]How to close the socket?[/quote]
Quote from Qt documentation:
Note: After the request has finished, it is the responsibility of the user to delete the QNetworkReply object at an appropriate time. Do not directly delete it inside the slot connected to finished(). You can use the deleteLater() function.
Maybe, QNetworkAccessManager also should be deleted on application close, I am not sure.
[quote author="hisong1988" date="1290359270"]and I don't know how to locate the message,either because I don't know how the problem appeared[/quote]
Just search all files in the Qt sources - it is Open Source benefit :-)
-
Sorry to reply to you so late. I used the deletelater() funtion in the slot function. But it dos not work.I know the deletelater() function is the release the data I get from the reply. I also try to use the close() function too, but with the same result. The network of the app runs well on the device,but I really want to find the cause of the problem.
-
I've faced same problem. It looks like qt network access backend doesn't handle sockets properly.
I suppose root cause is same as reported in:
http://bugreports.qt.nokia.com/browse/QTBUG-12686 -
I don't really understand the root cause with the link you give.
Thanks very much. I hope the exception will be solved by next Qt version.