[Qt-interest] Synchronous signals, is that possible?
Andrea Franceschini
therealmorpheu5 at gmail.com
Sun Feb 15 14:28:51 CET 2009
Hello everybody,
I'm facing a little dilemma about elegance and pointers. I have a
class which at some time takes a pointer to an object. I can obviously
take that pointer and do the dirty work inside this class but instead
I decided to make a proxy/adapter layer that takes those pointers and
emits them as signals carrying them as parameters, to which the rest
of my application connects.
The thing I didn't know in advance is that the original developer of
the underlaying system assumed that all this process was synchronous,
so he calls the takeThis(Pointer*) method of a bunch of listeners and
assumes that when every single call returned, it was time to delete
the pointer. Unfortunately this crashes against the asynchronous
nature of the Qt's signal/slot system -- i.e. I got strange behaviour
past the proxy/adapter layer and working with those pointers inside
the rest of the application.
The dilemma is that I really love the elegance and logical abstraction
provided by signals and slots and, unless there's a way to make them
work in a synchronous fashion, I'll have to directly pass the pointers
to my application, and that's frankly quite ugly.
Ideas?
More information about the Qt-interest-old
mailing list