ADC Home > Reference Library > Technical Q&As > Legacy Documents > Graphics & Imaging >

Legacy Documentclose button

Important: This document is part of the Legacy section of the ADC Reference Library. This information should not be used for new development.

Current information on this Reference Library topic can be found here:

-51 or -39 Error Code with GX Printing


Important for all Apple Printing and Graphics Developers:

The information in this Technical Q & A is still relevant up to and including Mac OS 7.6 with QuickDraw GX 1.1.5. Beginning with the release of Mac OS 8.0, however, Apple plans to deliver a system which incorporates QuickDraw GX graphics and typography only. QuickDraw GX printer drivers and GX printing extensions will not be supported in Mac OS 8.0 or in future Mac OS releases. Apple's goal is to simplify the user experience of printing by unifying the Macintosh graphic and printing architectures and standardizing on the classic Printing Manager.

For details on Apple's official announcement, refer to </dev/technotes/gxchange.html>

Q: I'm using GXInstallQDTranslator to turn all my QuickDraw calls into GX Shapes, and the like. As far as I can tell, this works fine, and when I'm done, I call GXRemoveQDTranslator, but it returns an error code of -51, which isn't mentioned in any of the GX Printing documentation I have. What's happening?

A: When there is a -51 or -39 error from within an application using GX, it is usually caused by double disposing a GX object (e.g., a shape, ink, style, or transform).

The -51 error is generated because the shape is located in the disk-based backing-store file. After the first dispose, the backing-store file is deleted (as it should be), but after the second dispose, the shape's backing-store file is gone, so the file manager returns a -51= rfNumErr (reference number invalid) error.

Make sure you're not disposing of the GX shape created in your QDTranslator handler. Contrary to the sample code on page 1-22 of Inside Macintosh: QuickDraw GX Environment & Utilities, GX does dispose of the shape for you.

If this doesn't solve the problem, install the "GXGraphics (debug) init" and turn on validation to make it easier to find the origin of the double-dispose. Start with the following validation setting:

    GXSetValidation (gxPublicValidation + gxTypeValidation)

If your application continues to run without any validation errors from GX, turn up validation by adding the following flag:

    gxAllObjectValidation
If that still works, add the following flags to the mix:
    gxApBlockValidation + gxApHeapValidation.

If everything continues to work, add the following flag to the mix:

    gxCheckApHeapValidation

As you increase the amount of validation, you'll see an increasing slowdown, but hopefully, validation will catch the problem.

For additional details about GX validation, see the chapter on GX validation in GX Environment & Utilities.

[May 01 1995]


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.