• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
_NSWarnForDrawingImageWithNoCurrentContext
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

_NSWarnForDrawingImageWithNoCurrentContext


  • Subject: _NSWarnForDrawingImageWithNoCurrentContext
  • From: Leonardo <email@hidden>
  • Date: Sat, 14 Dec 2013 13:32:29 +0100
  • Thread-topic: _NSWarnForDrawingImageWithNoCurrentContext

Hi, when I rotate my NSView, my image disappears for a second from the
screen and I get this error message

It does not make sense to draw an image when [NSGraphicsContext
currentContext] is nil.  This is a programming error. Break on void
_NSWarnForDrawingImageWithNoCurrentContext() to debug.  This will be logged
only once.  This may break in the future.

So I have put a symbolic breakpoint there and I have found the line causing
the error, which is in NSView's drawRect method:

[mImage drawInRect:inRect fromRect:fillRect operation:NSCompositeSourceOver
fraction:mOpacity];

When the image disappears, I can quite see a white rectangle coming from my
line

NSRectFillUsingOperation(myBounds, NSCompositeSourceOver);

So I'm sure myBounds rect is ok. To tune up my test I made sure that mImage
is never nil and has positive size, iRect and fillRect have always positive
size too and they never change, mOpacity is always 1.0 and the current
context is always not nil. As my log says:

imageSize 1251 x 705, inRect {{0, 0}, {300, 200}}, fillRect {{97, 0}, {1057,
705}}, mOpacity 1.0, frameCenterRotation 2.647995, current context is not
nil

The error occurs when I rotate the view with frameCenterRotation, but not at
any degree.

- (void)setMAngle:(CGFloat)value
{
    mAngle = value;
    [self setFrameCenterRotation:mAngle];
    [self setNeedsDisplay:YES];
}

For example, if I still rotate the NSView to frameCenterRotation 4.689613 I
can quite see the image and I don't get the error.
Furthermore, if I replace mOpacity with a fixed value 1.0 in the code

[mImage drawInRect:inRect fromRect:fillRect operation:NSCompositeSourceOver
fraction:1.0];

the error NEVER occurs. However even using the CGFload variable mOpacity
always = 1.0, the problem sometimes occurs when I rotate the view.
Just to be sure I have even overrided the isOpaque method returning NO. Same
trouble.
I'm really puzzled. Any idea?


Regards
-- Leonardo


_______________________________________________

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


  • Follow-Ups:
    • Re: _NSWarnForDrawingImageWithNoCurrentContext
      • From: "Stephen J. Butler" <email@hidden>
  • Prev by Date: Best solution for game loop on OSX?
  • Next by Date: NSDistributedNotificationCenter Strangeness
  • Previous by thread: Re: Best solution for game loop on OSX?
  • Next by thread: Re: _NSWarnForDrawingImageWithNoCurrentContext
  • Index(es):
    • Date
    • Thread