Closed Bug 101947 Opened 23 years ago Closed 23 years ago

Make sure that |CreateDeviceContextSpec| Mac platforms returns an error code on failure

Categories

(Core :: Printing: Output, defect)

PowerPC
All
defect
Not set
normal

Tracking

()

VERIFIED FIXED

People

(Reporter: roland.mainz, Assigned: sfraser_bugs)

Details

Make sure that |CreateDeviceContextSpec| Mac platforms returns an error code on
failure. Recently I fixed the error handling in nsDocumentViewer.cpp incl. the
following two lines:
-- snip --
-    factory->CreateDeviceContextSpec(mWindow, devspec, aSilent);
-    if (nsnull != devspec) {
+    rv = factory->CreateDeviceContextSpec(mWindow, devspec, aSilent);
+    if (NS_SUCCEEDED(rv)) {
-- snip --
which means that it isn't "legal" anymore to turn a random value (incl. NS_OK)
on failure as error code. The new code _only_ looks at the error code (and
fires-up an error dialog except for NS_ERROR_ABORT (which indicates that the
print dialog has been canceled... - see bug 101289)) and does not make any
further checks. 
Unix/Linux(GTK+/Xlib) and Windows (bug 101221) have already been fixed.
Is it not working correctly on the Mac? I looked at the code and it appears to 
be giving back error codes (I can't test for this, I don't have a Mac)
Assignee: dcone → rods
Status: NEW → ASSIGNED
> Is it not working correctly on the Mac?

No idea. I don't have a Mac. But various people asked me to file a bug to "make
sure that mac platform returns the correct error codes [for the print error
dialog stuff]"

> I looked at the code and it appears to be giving back error codes

Yup... except that I cannot find where it returns NS_ERROR_ABORT to indicate
that the print dialog has been canceled... ;-/
Here's the patch for Mac classic:

Index: mozilla/gfx/src/mac/nsDeviceContextSpecMac.cpp
===================================================================
RCS file: /cvsroot/mozilla/gfx/src/mac/nsDeviceContextSpecMac.cpp,v
retrieving revision 1.9
diff -b -u -5 -r1.9 nsDeviceContextSpecMac.cpp
--- nsDeviceContextSpecMac.cpp	2001/09/26 00:15:24	1.9
+++ nsDeviceContextSpecMac.cpp	2001/10/10 02:17:11
@@ -373,10 +373,11 @@
         mPrtRec = hPrintRec;
       }else{
         // don't print
         ::DisposeHandle((Handle)hPrintRec);
         ::SetPort(oldport); 
+        theResult = NS_ERROR_ABORT;
       }
       
       // clean up our dialog routines
       DisposePItemUPP(PrtJobDialog->pItemProc);
       PrtJobDialog->pItemProc = prPItemProc;        // put back the old just in 
case

Mac OS X does the right thing.
Assignee: rods → sfraser
Status: ASSIGNED → NEW
r=sdagley
I checked that patch in.
Status: NEW → RESOLVED
Closed: 23 years ago
Resolution: --- → FIXED
Roland/Simon, can one of you verify this fix and mark verified-fixed ?

thanks.
The patch looks OK for me... but I do not have a Mac to test it... ;-(
vr.
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.