[MacRuby-devel] FYI - Update on NSView printing problem

Robert Rice rice.audio at pobox.com
Tue Sep 14 09:35:32 PDT 2010


Hi Laurent:

Thanks for your reply.

I created a scaled down version of my app using the same print mechanism and it didn't reproduce the problem.
Rebuilding the app into a new project did not eliminate the problem.

The problem doesn't cause my app to crash, just error messages for the invalid graphics context and the print operation fails.

I get the same error for all of my views including some very simple ones.

There may be something I'm doing wrong initializing my views but it seems to be affecting only the small preview window in the PrintPanel - an option that I can turn off.

My views define the knowsPageRange, rectForPage, and locationOfPrintRect methods to adjust the position for overprinting pre-printed forms. Possibly PrintPanel does like my drawing going beyond the printer's clip view bounds, but I still get the errors commenting out these methods.

In any case, PrintPanel should be outputting a message and canceling the print operation if it can't create a valid graphics context.

Thanks,
Bob Rice


On Sep 13, 2010, at 11:53 PM, Laurent Sansonetti wrote:

> Hi Robert,
> 
> Interesting. Do you reproduce the crash when you use this code into a new Xcode project?
> 
> If it only crashes in your app, maybe it's related to your view. How complex is the view?
> 
> Laurent
> 
> On Sep 10, 2010, at 9:30 AM, Robert Rice wrote:
> 
>> I tracked down my NSView printing problem to the NSPrintPanel preview view. My view printing now works again by overriding the default option to display the small preview view:
>> 
>> def print
>> 	po = NSPrintOperation.printOperationWithView( @printableView )
>> 	po.printPanel.setOptions( 0 )
>> 	po.setShowsPrintPanel( true )
>> 	po.runOperationModalForWindow( @printableView.window, delegate:self,
>> 		didRunSelector:"printOperationDidRun:success:contextInfo:", contextInfo:nil )
>> end
>> 
>> def printOperationDidRun( printOperation, success:success, contextInfo:contextInfo )
>> 	puts "printOperationDidRun #{ success }"
>> end
>> 
>> or I can bypass the printPanel entirely.
>> 
>> It will take more experimenting to find out why NSPrintPanel is not creating a graphics context for my NSView or why it would call my drawRect with an invalid context; it works with my PDFView. But now 
>> it's a low priority for me since I don't really need the NSPrintPanel preview.
>> 
>> Bob Rice
>> 
>> _______________________________________________
>> MacRuby-devel mailing list
>> MacRuby-devel at lists.macosforge.org
>> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
> 
> _______________________________________________
> MacRuby-devel mailing list
> MacRuby-devel at lists.macosforge.org
> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-devel/attachments/20100914/98366764/attachment.html>


More information about the MacRuby-devel mailing list