November 21, 2010

hisong1988 hisong1988
Lab Rat
72 posts

[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.

  1. void MainWindow::on_cityComboBox_currentIndexChanged(int index)
  2. {
  3.     QTextCodec::setCodecForCStrings(QTextCodec::codecForName("GB2312"));
  4.     QString url="http://www.google.com/ig/api?hl=zh_cn&weather=";
  5.     QString localPlace=ui->cityComboBox->currentText();
  6.     ui->locaPlace->setText(localPlace);//add the place to the label-localPlace
  7.     url.append(localPlace);
  8.     manager =new QNetworkAccessManager(this);
  9.     manager->get(QNetworkRequest(QUrl(url)));
  10.     connect(manager,SIGNAL(finished(QNetworkReply*)),this,SLOT(replyFinish(QNetworkReply*)));
  11.  
  12. }

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?

 Signature 

I am still searching for….

8 replies

November 21, 2010

blex blex
Lab Rat
191 posts

Is socket closed in your code?

Try to locate the message in Qt sources and set the break-point on it – this may help you to understand what happens.

 Signature 

————————————

Oleksiy Balabay

November 21, 2010

hisong1988 hisong1988
Lab Rat
72 posts

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

 Signature 

I am still searching for….

November 21, 2010

blex blex
Lab Rat
191 posts
hisong1988 wrote:
How to close the socket?

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.

hisong1988 wrote:
and I don’t know how to locate the message,either because I don’t know how the problem appeared

Just search all files in the Qt sources – it is Open Source benefit :-)

 Signature 

————————————

Oleksiy Balabay

November 22, 2010

hisong1988 hisong1988
Lab Rat
72 posts
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.
 Signature 

I am still searching for….

November 22, 2010

blex blex
Lab Rat
191 posts

To find the cause of the problem try to follow my second suggestion: locate in the Qt or Qt Mobility sources the string from the message window and set breakpoint at that place.

Good Luck

 Signature 

————————————

Oleksiy Balabay

November 24, 2010

jonexi jonexi
Lab Rat
2 posts

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

November 25, 2010

hisong1988 hisong1988
Lab Rat
72 posts

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.

 Signature 

I am still searching for….

December 4, 2010

Deleted Member # 14e8 Deleted Member # 14e8
Lab Rat
355 posts

Hello,
I am the next one – I also get exception on 3 [will close the socket handle – hack] but on a XM5800 with Qt 4.7.1.

The phone also always bugs me about reconnecting – so it looks like the socket is somehow being killed all the time.

P.S: This also happens in QFtp

 
  ‹‹ Qt on the Caanoo      How to change audio output device in qmediaplayer ››

You must log in to post a reply. Not a member yet? Register here!