I'm not a Cocoa developer, so I rarely have to touch the stuff. This code used to work, and I'm not sure when or why it got broken. It previously did not have the NSApplicationLoad or NSAutoreleasePool, so I added those in hopes that that was the problem. Before adding those 2 things, I would get a crash down in some Cocoa stuff (see stack after routine). After adding those 2 things, it crashes at [localPool release]. I was told to use those 2 things in a few other Cocoa routines we have in our Carbon app, and they still work (using NSCursor and NSAnimationEffectPoof).

Any ideas on what might be wrong? I appreciate any help.

void ConvertWordDataIntoRTFData(const Byte* const data, const UInt32 len, fAutoBuffer<char>& outData)
{
        outData.clear();
        
        if(data != nil && len > 0) {
                if(NSApplicationLoad()) {
                        NSAttributedString*             attrStr;
                        NSData*                                 nsdata;
                        NSDictionary*                   attr = nil;
                        NSAutoreleasePool*              localPool;
                        
                        localPool = [[NSAutoreleasePool alloc] init];
                        
                        // Convert the Word doc data into an attributed string:
                        nsdata = [NSData dataWithBytes:data length:len];
                        
                        if(nsdata != nil) {
attrStr = [[NSAttributedString alloc] initWithDocFormat:nsdata documentAttributes:&attr];
                                [nsdata release];
                                
                                if(attrStr != nil) {
                                        // Create rtf data from the attributed 
string:
                                        NSRange                 range = 
NSMakeRange(0, [[attrStr string] length]);
                                        
                                        nsdata = [attrStr RTFFromRange:range 
documentAttributes:attr];
                                        [attrStr release];
                                        
                                        if(nsdata != nil) {
                                                outData.append([nsdata length], 
(char*)[nsdata bytes]);
                                                [nsdata release];
                                        }
                                }
                        }
                        
                        [localPool release];
                }
        }
}

Crash stack before adding NSApplicationLoad dnd NSAutoreleasePool:

#0      0x94022688 in objc_msgSend
#1      0x926bf08f in NSPopAutoreleasePool
#2      0x9600779f in _wrapRunLoopWithAutoreleasePoolHandler
#3      0x90b319a2 in __CFRunLoopDoObservers
#4      0x90b32c40 in CFRunLoopRunSpecific
#5      0x90b33cd8 in CFRunLoopRunInMode
#6      0x912712c0 in RunCurrentEventLoopInMode
#7      0x912710d9 in ReceiveNextEventCommon
#8      0x912cfc6e in _AcquireNextEvent
#9      0x912ce3cb in RunApplicationEventLoop
#10     0x00204edf in fApp::Run at fApp.cp:2432
#11     0x001eed79 in main at DogbertMain.cp:146

_________________________________________________________
Steve Mills                              Me: 952-401-6255
Senior Software Architect                         MultiAd
smi...@multiad.com                       www.multi-ad.com


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to