Re: NSSound Reimplementation

2009-06-27 Thread Wolfgang Lux


Am 27.06.2009 um 18:06 schrieb Stefan Bidigaray:


I know I'm replying a lot to my own posts, but that's just it's me.

Anyway, I've been doing some more testing and the - 
performSelectorOnMainThread:withObject:waitUntilDone: call in - 
_stream is not really getting executed, as far as I can tell.  I  
moved the DESTROY(lock) stuff into -_finished: and was getting a  
seg fault later down the line.  I set a break point inside - 
_finished:, but gdb never got to it, which leads me to believe the  
method is not being called.  I then replaced that call with - 
performSelector:withObject:, which the way understand simply does  
the same thing but on the secondary thread, and it worked.  Is - 
performSelectorOnMainThread:... not working?


I had a look at the code you posted yesterday and I've found two  
dubious points in NSSound_test.m:


First, there is a retain/release error in NSSound's - 
initWithContentsOfFile:byRef: method. The NSData object returned from  
dataWithContentsOfMappedFile: is already autoreleased, but you  
release that object after calling -initWithData: (recall that you  
should only release objects that you own, which in general are only  
objects that you have allocated yourself either with alloc or copy).


Second, I noticed that you call -performSelectorOnMainThread... with  
waitUntilDone = NO. I think you should use waitUntilDone = YES here.  
Note that if waitUntilDone = NO and you call - 
performSelectorOnMainThread... from the main thread the call is  
scheduled to be run at the next iteration of the run loop and not  
performed immediately. In addition, if you really use waitUntilDone =  
NO on purpose you should make sure that the sound object is retained  
until the scheduled method is actually run (i.e., you probably should  
retain self before calling performSelectorOnMainThread and  
autorelease self in _finished). Otherwise, there is a chance that the  
thread which calls the _stream method releases the sound object too  
early and the run loop invokes _finished for an already released object.


Wolfgang



___
Gnustep-dev mailing list
Gnustep-dev@gnu.org
http://lists.gnu.org/mailman/listinfo/gnustep-dev


Re: NSSound Reimplementation

2009-06-27 Thread Stefan Bidigaray
I know I'm replying a lot to my own posts, but that's just it's me.

Anyway, I've been doing some more testing and the
-performSelectorOnMainThread:withObject:waitUntilDone: call in -_stream is
not really getting executed, as far as I can tell.  I moved the
DESTROY(lock) stuff into -_finished: and was getting a seg fault later down
the line.  I set a break point inside -_finished:, but gdb never got to it,
which leads me to believe the method is not being called.  I then replaced
that call with -performSelector:withObject:, which the way understand simply
does the same thing but on the secondary thread, and it worked.  Is
-performSelectorOnMainThread:... not working?

Thanks
Stefan
___
Gnustep-dev mailing list
Gnustep-dev@gnu.org
http://lists.gnu.org/mailman/listinfo/gnustep-dev