PDA

View Full Version : Signal emitted more than once?



dbrmik
13th March 2009, 12:28
Hi

I have a GUI front end controlling MyClass. MyClass is created when I load an input file and the signal/slot connections are made. A push button is used to run a function from my object.

This works fine , i.e the function only runs once when the button is pushed.

If I then create another instance of MyClass by loading a new data file, I delete the current instance of MyClass and create a new one. Now when I click the push button, the function runs twice.

Any ideas why this is?

Regards

JimDaniel
13th March 2009, 12:35
Without seeing your code, I'd say you probably need to call disconnect() for the object you're deleting. If you keep deleting and creating instances, does the number of signals emitted increase proportionally?

spirit
13th March 2009, 12:38
maybe in generated ui_xxx.h contains autoconnection and you add a new one in your code. anyway, as said above without code it's hard to say

dbrmik
13th March 2009, 12:44
Thanks Jim for the quick reply, yes the number of times the signal is emitted is equal to the number of times the object is created/deleted.

Yes I do need disconnect().

I have found the problem. The push button was connected to a function in my GUI which calls the MyClass member function. I need to disconnect this signal

Thanks Jim
:)