Crash in NSTextView with embedded QuickTime file
Crash in NSTextView with embedded QuickTime file
- Subject: Crash in NSTextView with embedded QuickTime file
- From: Keith Blount <email@hidden>
- Date: Wed, 27 Sep 2006 13:51:38 -0700 (PDT)
Hi,
I have a program that has two text views in a split
view. The text storages of these text views can be
swapped in and out arbitrarily, so that the user can
look at two parts of the same document or at different
documents altogether.
However, I am experiencing a crash when the text
storage has an embedded QuickTime file. I created a
test app to narrow this down, and it was easily
reproducable. Basically, if the two text views share
the same text storage, and that text storage has an
embedded QT file, if you then swap out one of the text
storages for a different one, the program will crash.
The stack trace gives a lot of internal and private
methods, a lot of which seem to stem from QTMovie and
QTMovieView methods such as +_idleMovies.
(There are also lots of drawing issues when two text
views share a text storage with a QuickTime file
embedded - the QT file flickers on and off and may
even be invisible for a while.)
It seems to me that this is an AppKit bug, and I am
about to file it. However, that doesn't help me right
now, as I have an app in public beta that will crash
if the user embeds QT files and starts swapping
documents. Does anybody know of a way around this?
For the record, I have attached the code from my test
app that shows how I am swapping the documents in and
out. Like I say, this code will crash during text
storage switching if one of the swapped text storages
contains a movie attachment.
Thanks in advance for any advice or help,
Keith
- (id)init
{
if (self = [super init])
{
firstTextStorage = [[NSTextStorage alloc] init];
NSFileWrapper *wrapper = [[NSFileWrapper alloc]
initWithPath:@"/users/myhomefolder/MovieTest.rtfd"];
secondTextStorage = [[NSTextStorage alloc]
initWithRTFDFileWrapper:wrapper
documentAttributes:nil];
[wrapper release];
}
return self;
}
- (void)dealloc
{
[firstTextStorage release];
[secondTextStorage release];
[super dealloc];
}
- (NSString *)windowNibName
{
// Override returning the nib file name of the
document
// If you need to use a subclass of
NSWindowController or if your document supports
multiple NSWindowControllers, you should remove this
method and override -makeWindowControllers instead.
return @"MyDocument";
}
- (void)windowControllerDidLoadNib:(NSWindowController
*) aController
{
[super windowControllerDidLoadNib:aController];
// Add any code here that needs to be executed
once the windowController has loaded the document's
window.
NSLayoutManager *lm = [topTextView layoutManager];
NSTextStorage *text = [topTextView textStorage];
[text removeLayoutManager:lm];
[topTextView setSelectedRange:NSMakeRange(0,0)];
[firstTextStorage addLayoutManager:lm];
lm = [bottomTextView layoutManager];
text = [bottomTextView textStorage];
[text removeLayoutManager:lm];
[bottomTextView setSelectedRange:NSMakeRange(0,0)];
[secondTextStorage addLayoutManager:lm];
}
- (IBAction)changeTopTextStorage:(id)sender
{
NSTextStorage *oldText = [topTextView textStorage];
NSLayoutManager *lm = [topTextView layoutManager];
[oldText removeLayoutManager:lm];
[topTextView setSelectedRange:NSMakeRange(0,0)];
if (oldText == firstTextStorage)
[secondTextStorage addLayoutManager:lm];
else
[firstTextStorage addLayoutManager:lm];
}
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden