Re: screen dump crash with out sleep
Re: screen dump crash with out sleep
- Subject: Re: screen dump crash with out sleep
- From: Raul Fiedler <email@hidden>
- Date: Sat, 23 Jun 2007 12:37:43 +0200
First thanks for all your valuable help.
(asm and C++ is 5 years ago, been on java since then.) And now
learning cocoa with this example.
The code is a method called from the UI controller. Therefore I
assume it is single threaded.
Answer to question: rect is a signature parameter to the method.
Here is the stack trace
#0 0x906bb444 in interceptorDatagramHandler
#1 0x9040cac4 in CGSDispatchDatagramsFromStream
#2 0x9040c178 in snarfEvents
#3 0x9329e488 in MessageHandler
#4 0x907ec850 in __CFMachPortPerform
#5 0x907ec764 in __CFRunLoopDoSource1
#6 0x907dee7c in __CFRunLoopRun
#7 0x907de4ac in CFRunLoopRunSpecific
#8 0x9329bb20 in RunCurrentEventLoopInMode
#9 0x9329b12c in ReceiveNextEventCommon
#10 0x9329b020 in BlockUntilNextEventMatchingListInMode
#11 0x937a1ae4 in _DPSNextEvent
#12 0x937a17a8 in -[NSApplication
nextEventMatchingMask:untilDate:inMode:dequeue:]
#13 0x9379dcec in -[NSApplication run]
#14 0x9388e87c in NSApplicationMain
#15 0x00011fa8 in main at main.m:13
spoiled from java I still have a learning curve on understanding the
details on the trace.
By trial and error I have noticed that the exception is throw at the
line
(please see modified code bellow)
rep = [[NSBitmapImageRep alloc] initWithFocusedViewRect:bRect];
I thought that the commands in the methods where single threaded and
executed in a sequence.
I thought that the bit map was allocated and inited. Then the next
code line where the window is released are done after the bit map was
safely ready to use.
Question: What is my misunderstanding here?
Thank you
- (NSImage *)captureImageForRect:(NSRect)rect
{
NSWindow *window;
NSBitmapImageRep *rep;
NSImage *image;
window = [[NSWindow alloc] initWithContentRect:rect
styleMask:NSBorderlessWindowMask
backing:NSBackingStoreNonretained defer:NO];
[window setBackgroundColor:[NSColor blueColor]];
[window setLevel:NSScreenSaverWindowLevel];
[window setHasShadow:NO];
[window setAlphaValue:0.2];
[window setOpaque:NO];
[window orderFront:self];
//sleep(2);
NSView* contentView = [window contentView];
[contentView lockFocus];
NSRect bRect = [[window contentView] bounds];
rep = [[NSBitmapImageRep alloc] initWithFocusedViewRect:bRect]; //
this line bombs out
[contentView unlockFocus];
[window orderOut:self];
[window release];
return image;
}
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden