sendChangeMessage() and pointers


#1

i’m using some code that in short looks like this

in the changeMessageSource

event *ev = new event()
sendChangeMessage(ev);

and in the Listener

use(ev);
deleteAndZero (ev);

is this ok ? cause i’m getting memory leaks from the ev pointer (i used the WATCHer in VC and ev has the same memory adress as the reported leaked memory by juce).

what other way is to send short messages between classes, i can’t think of anything, and this is a single thread (a VST plugin), no new threads are started (not by my code anyway).


#2

Ah, that pointer isn’t supposed to be used for passing objects - the changebroadcaster coalesces multiple change requests together. So even if you call sendChangeMessage 1000 times, the listeners will only get one callback.

An actionlistener might be a better class for you. Or just send a Message object to a MessageListener.


#3

allright i’ll forget that, i thought this might be a bad idea.


#4

The idea’s ok, you just shouldn’t use changelistener for it.