So I have an application that has been bedeviled by a nasty, nasty bug for years that manifests itself as an exception being thrown with:

Error (1007) creating CGSWindow

At that point, the user has no choice but to reboot the machine - the Window Server is pretty much hoarked.

Since the app is so complex, and the code path for tickling this bug is so arbitrary, I've been loathe to file a bug on it, since I didn't have a simple example to repro it.

Completely separately, I decided this AM to write a simple Cocoa app to generate a bunch of test files for my group. Lo and behold, I managed to tickle the bug.

Error (1007) creating CGSWindow

I just filed the radar bug as  6498067

but if anyone wants to take a look, I'm happy to send you the source for the app - it's only 60KB, but the core of the thing looks like this (it falls apart after making about 340 images, on my machine with 32GB of RAM, and a NVidia FX5600 w/1.5GB of VRAM):

where we're going from 0 to 1,000, and the width and height are 1920x1080 - seems to crap out after 340 files for me.



// eventually put this in a background thread with a cancel button on a progress sheet
- (IBAction)generateFiles:(id)sender {
        int start = [self.startingNumber intValue];
        int howMany = 1 + [self.endingNumber intValue] - start;
        NSSize imgSize = [self size];   
        int i, digits = [self.endingNumber digits];

        int fontSize = [self determineFontSizeForNumber:self.endingNumber];
NSString* formatString = [NSString stringWithFormat:@"%%0%dd", digits]; // end up with "%03d"
        NSRect rect = NSMakeRect(0, 0, imgSize.width, imgSize.height);
        for (i = 0; i < howMany; i++) {
                NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
                NSString* str = [NSString stringWithFormat:formatString, i];
                NSFont* font = [NSFont systemFontOfSize:fontSize];
NSDictionary* dict = [NSDictionary dictionaryWithObjectsAndKeys:font, NSFontAttributeName, self.textColor, NSForegroundColorAttributeName, nil]; NSAttributedString* aStr = [[[NSAttributedString alloc] initWithString:str attributes:dict] autorelease];
                
                NSImage* image = [[NSImage alloc] initWithSize:imgSize];
                [image lockFocus];
                [aStr drawInRect:rect];
                [image unlockFocus];
                
NSString* imgFormatString = [NSString stringWithFormat:@"%...@_% %0%dd.tif", digits]; // end up with "%03d" NSString* imgName = [NSString stringWithFormat:imgFormatString, self.prefix, i]; NSString* imgPath = [self.directory stringByAppendingPathComponent:imgName]; NSData* tiffData = [image TIFFRepresentationUsingCompression:NSTIFFCompressionLZW factor:1.0];
                [tiffData writeToFile:imgPath atomically:YES];
                
                [pool drain];
        }
}




Thanks for any insight.



--> Michael B. Johnson, PhD
--> http://homepage.mac.com/drwave (personal)
--> http://xenia.media.mit.edu/~wave (alum)
--> MPG Lead
--> Pixar Animation Studios




_______________________________________________

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