• 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
Re: _NSWarnForDrawingImageWithNoCurrentContext
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: _NSWarnForDrawingImageWithNoCurrentContext


  • Subject: Re: _NSWarnForDrawingImageWithNoCurrentContext
  • From: Leonardo <email@hidden>
  • Date: Tue, 17 Dec 2013 10:28:06 +0100
  • Thread-topic: _NSWarnForDrawingImageWithNoCurrentContext

I have found that if I use

   [mImage setCacheMode:NSImageCacheNever];

The trouble never occurs. It occurs when I use

   [mImage setCacheMode:NSImageCacheAlways];

I don¹t know whether that¹s a Cocoa¹s bug.
Do you think I have to file a bug to Apple?


Regards
-- Leonardo



Da: "Stephen J. Butler" <email@hidden>
Data: Mon, 16 Dec 2013 17:57:30 -0600
A: Leonardo <email@hidden>
Cc: Cocoa Development <email@hidden>
Oggetto: Re: _NSWarnForDrawingImageWithNoCurrentContext

Did you try the suggestion the warning listed? Breaking on "void
_NSWarnForDrawingImageWithNoCurrentContext()"? Because a stack trace for
when the error occurs would be helpful.


On Sat, Dec 14, 2013 at 6:32 AM, Leonardo <email@hidden> wrote:
> 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
> <http://lists.apple.com>
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden



_______________________________________________

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


References: 
 >Re: _NSWarnForDrawingImageWithNoCurrentContext (From: "Stephen J. Butler" <email@hidden>)

  • Prev by Date: Re: Best solution for game loop on OSX?
  • Next by Date: NSDistributedNotificationCenter Strangeness
  • Previous by thread: Re: _NSWarnForDrawingImageWithNoCurrentContext
  • Next by thread: Unit testing Cocoa application
  • Index(es):
    • Date
    • Thread