I have a document based application which uses QTMovieView to display a movie. The view in which the movie is displayed is hooked to MovieViewController (a subclass of NSViewController). At first, I used QTMovieViews default controls, but once everything was running, I decided to implement my own controls. To update the play/pause button, I added added the some code to
Now, when I close the window, the MovieViewControllers dealloc is never called and the movie keeps playing (at least the sound - since the window is closed, I can't see it anymore). If I comment out the
and
calls, everything works as expected again, and dealloc is called.
I have tried registering for NSWindowWillCloseNotification and removing myself from there using
but that didn't help either.
All other view controllers and the window controller are being deallocated as expected.
Any ideas on where the problem is?
Code:
// Following method is called when a new path for the movie was set
- (void)handleMoviePathDidChange
{
if (self.movie) //movie holds an instance of QTMovie
[[NSNotificationCenter defaultCenter] removeObserver:self name:QTMovieRateDidChangeNotification object:self.movie];
// "Old" code that didn't cause any trouble before
NSError *error = nil;
self.movie = [QTMovie movieWithURL:self.moviePath error:&error];
if (error)
[self handleError:error];
[self.movieView setMovie:self.movie];
// End of "old" code.
if (self.movie)
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(movieRateChanged:) name:QTMovieRateDidChangeNotification object:self.movie];
}
Code:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(movieRateChanged:) name:QTMovieRateDidChangeNotification object:self.movie];
Code:
[[NSNotificationCenter defaultCenter] removeObserver:self name:QTMovieRateDidChangeNotification object:self.movie];
I have tried registering for NSWindowWillCloseNotification and removing myself from there using
Code:
[[NSNotificationCenter defaultCenter] removeObserver:self]
All other view controllers and the window controller are being deallocated as expected.
Any ideas on where the problem is?