In my project, I have a QTMovieView, and m_movieView is an outlet
pointing to it. When I run the following code, my application
crashes:
NSError* err = nil;
QTMovie* my_movie = [QTMovie movieWithFile: kPathToMyMovie error:
&err];
[m_movieView setMovie: my_movie];
[m_movieView display];
[m_movieView setMovie: nil];
[m_movieView display];
My question is: what am I doing wrong? Why does my app crash here?
How can I avoid such crashes?
By default, a QTMovie is loaded asynchronously. That is,
movieWithFile:error: will return very quickly, even if the movie is
not fully loaded. This might be what's causing problems here. Try
maybe loading the movie synchronously:
NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys:
kPathToMyMovie,
QTMovieFileNameAttribute,
[NSNumber numberWithBool:NO],
QTMovieOpenAsyncOKAttribute, nil];
QTMovie *myMovie = [QTMovie movieWithAttributes:attributes
error:&err];
Does that help? Even if it does help, you should file a bug report.