Re: NSTextView crashes with web content
Re: NSTextView crashes with web content
- Subject: Re: NSTextView crashes with web content
- From: Mike Wright <email@hidden>
- Date: Mon, 4 Oct 2004 15:46:31 -0700
On Oct 4, 2004, at 07:47, Renaud Boisjoly wrote:
I tried using the @try, @catch and @finally but my problem does not
seem to get cought.. I crash and I never see the exception.
Here is some sample code:
NSMutableAttributedString *rtfdString;
NSData *rtfdData;
NSLog(@"Types on pasteboard: %@",[[NSPasteboard generalPasteboard]
types]);
//Priority should be: RTFD, RTF, String, PICT
@try {
NSLog(@"Trying to paste");
//Get contents of pasteboard, set content of selection to this data
rtfdData = [NSData dataWithData: [[NSPasteboard generalPasteboard]
dataForType:NSRTFDPboardType]] ;
rtfdString = [[[NSMutableAttributedString alloc]
initWithRTFD:rtfdData documentAttributes:NULL] autorelease] ;
//NSLog(@"RTFD : %@",rtfdString);
//Replace current selection with this data
[self insertText:rtfdString];
}
@catch (NSException *exception) {
NSLog(@"main: Caught %@: %@", [exception name], [exception reason]);
}
@finally {
NSLog(@"Done Pasting");
}
Unfortunately, I'm not very knowledgeable about this sort of thing.
Perhaps someone else here is.
Have you tried setting a break point ahead of the @try line and
stepping through the code to see exactly where it's crashing?
I tried also by not using autoreleased objects, but that seemed to
fail as well...
Am I using this correctly? At some point I got some malloc errors,
sometimes it quits with signal 10, sometimes other ones.
It looks like the time it takes for the NSTextView to actually insert
the data (the color wheel appears when there is lots of data) makes it
crash... which is why I tried retaining and releasing my objects
myself... the malloc error seemed to say some object seemed to have
been modified after it had been released...
On Oct 3, 2004, at 2:19 PM, email@hidden wrote:
Date: Sun, 3 Oct 2004 11:00:55 -0700
From: Mike Wright <email@hidden>
Subject: Re: NSTextView crashes with web content
To: email@hidden
Message-ID: <email@hidden>
Content-Type: text/plain; charset=US-ASCII; format=flowed
On Oct 2, 2004, at 9:30 PM, Renaud Boisjoly wrote:
1. In Safari (not sure about other browsers), go to
https://optionslink.etrade.com/e/t/applogic/OlNonLoginHome
2. Select the whole page(Command-A) and Copy
3. Switch to TextEdit and Paste in a new document
4. Select All, Copy and Paste twice
5. Select All, Copy and Paste a few times
After 6 or 7 times, TextEidt or the other App will crash.
I've seen something similar. I've also seen it with certain types of
email content--especially advertising with combined text and images.
The code where the error occurred looked something like this:
BOOL goodPBoard ;
NSPasteboard *pboard = [NSPasteboard generalPasteboard];
goodPBoard = [myTextView readSelectionFromPasteboard:pboard];
Originally, the error caused the routine containing this code to exit
prematurely, often causing a crash.
Now I use @try, @catch, and @finally to make sure the routine
containing these lines is completed.
Here are some actual examples of exceptions raised by various
pasteboard content as they appeared in the debugger:
*** NSRunStorage, _NSBlockNumberForIndex(): index (3980) beyond array
bounds (1000)
*** NSRunStorage, _NSBlockNumberForIndex(): index (152166) beyond
array
bounds (2000)
*** NSRunStorage, _NSBlockNumberForIndex(): index (40555) beyond array
bounds (4000)
*** NSRunStorage, _NSBlockNumberForIndex(): index (4363) beyond array
bounds (3000)
The first one comes from going to
http://www.digitaleyes.net/Details.cfm?info=PIO012301 and copying
everything from "eX Driver The Movie" down to "Production Art" at the
end, then pasting it.
The interesting thing is that, in spite of the exception, the copied
material seems to paste in just fine. It doesn't appear to be
corrupted, displays okay, and can be saved.
I've wondered whether this qualifies as a bug in the
-readSelectionFromPasteboard routine.
_______________________________________________
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