PDA

View Full Version : Multiple signals coming in when I get a QNetworkReply



huguley
26th October 2010, 02:45
I seem to be getting multiples of the same signal when an event happens. I am using a NetworkAccessManager to do a post to a cgi. The post works fine but when I get the signal that the request is done and do my processing on it.

The odd part is that if I do it multiple times I get a signal with an "empty" QNetworkReply. I get an extra for each previous post I have done to the cgi. So on the first one it works as expected. On the second I will get the expected result then an empty. On the third I will get the result and 2 emptys. The QNetworkReply is not really empty that is just what I am calling it.

I am calling deleteLater on the replies. I also downloaded an example and it worked as expected. So it is something in my app but it is driving me crazy trying to find it. I am thinking it is also happening with other signals for probably the same reason.

tbscope
26th October 2010, 05:33
So it is something in my app but it is driving me crazy trying to find it.

Yet, you have the code. Imagine how crazy it will be for anyone else, someone who doesn't have your code, to find the error.

huguley
26th October 2010, 13:23
Yet, you have the code. Imagine how crazy it will be for anyone else, someone who doesn't have your code, to find the error.

I would have posted some code but the relevent parts are scattered all over and it would be a big wall of text. It is likely a very noob mistake.

I thought maybe it was holding onto the slots and signals connections so I put a disconnect in the destructor for the window but that did not change anything.

I have a thread in the app which emits a signal that does not get multipled up so it has something to do with opening a window. If I don't close the window it works as expected. But after I close the window and reopen it then it will multiply again.

What are some boneheaded ways to misuse qt? That is probably what I did.

Added after 17 minutes:

I figured it out. I was doing something boneheaded. I was not deleting the window after closing it. So there was an instance for each time I had opened the window in the background accepting the signal and doing stuff.

Sometimes just having someone else to talk to about a problem be a big help. Thanks!

ChrisW67
26th October 2010, 22:52
Sounds awfully like you are connecting the QNetworkAccessManager::finished() signal to your signal handler each time you create a new request. One connect - one signal, then two connections and two signals, etc.