NSMovieView causes crash

seb2

Registered
Hi everybody,

I'm having a problem with an NSMovieView. My App shows previews for files which are selected which works fine. The previews can either be images or movies, that's why I don't use a statically typed IBOutlet but id. The method that causes trouble is passed two arguments: the NSMovieView or NSImageView to display and a short string to show with some further information.

The views I pass are autoreleased and the view is not being altered/changed elsewhere.

Here's the method:

- (void)setPreview:(id)prev withInfoString:(NSString *)theInfo
{
[previewLock lock];
if ([fileSelectedPreview isKindOfClass:[NSMovieView class]])
{
if ([fileSelectedPreview isPlaying])
{
[fileSelectedPreview stop:self];
}
}
[prev setFrame:[fileSelectedPreview frame]];
[previewView replaceSubview:fileSelectedPreview with:prev];
[fileSelectedPreview autorelease];
fileSelectedPreview = [prev retain];
[fileSelectedOtherInfo setStringValue:theInfo];
[fileSelectedOtherInfo display];
[fileSelectedPreview setNeedsDisplay:YES];
/*if ([fileSelectedPreview isKindOfClass:[NSMovieView class]])
{
[fileSelectedPreview gotoBeginning:self];
}*/
[previewLock unlock];
}

The weird thing is that it only crashes when the movie is playing. I also noted that the retaincount of an NSMovieView that is playing or was playing is one higher than that of an NSMovieView that has never started playing. Does this have anything to do with that?

Also, I noticed that when I compile without code optimiztion and run it in the debugger, stuff works. My guess is that this has to do with the fact that Quicktime has enough time to do its initializations since the app runs slower.

Is my assumption correct? And if it is, what do I do? I'm no big pure c programmer and don't feel like digging that much into Quicktime.

Any help would be highly appreciated

[edit: turned off smilies]
 
it looks like to me that this


if ([fileSelectedPreview isKindOfClass:[NSMovieView class]])
{
if ([fileSelectedPreview isPlaying])
{
[fileSelectedPreview stop:self];
}



might be the problem, try [fileSelectedPreview stop:fileSelectedPreview] because usually "self" is referring to the implementation file you are currently in.

also, isKindOfClass: method might be the wrong method. I think there is another method called isTypeOfClass:. That is a little different.

I hope I'm not misunderstanding anything.
Hope that helps.

-whitesaint
 
thanks, whitesaint.

unfortunately, i have tried all that before; it didn't work. as sender, i have tried nil, self and the view itself, though that really shouldn't matter from what i understand. somehow it has to do with the fact that quicktime needs time to initialize the movie for diplay as i have found out in the meantime.

i tried getting the movie's load state via getmovieloadstate, i tried preprerolling and prerolling it, i tried removing the old view and adding the new view instead of exchanging the views, i tried different methods of displaying the new view... i even tried to explicitly retain the nsmovie in the nsmovieview and to use an own subclass of nsmovieview in which i overrode dealloc and then released it there.

as i said, this has kept me busy for two weeks now; i finally gave up and just show the file's icon until i find a reliable way to do this.

amazing that some of the things in cocoa leave gaps that wide. :(
 
Back
Top