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

VERIFIED FIXED

Status

()

Core
Printing: Output
VERIFIED FIXED
16 years ago
16 years ago

People

(Reporter: Roland Mainz, Assigned: Simon Fraser)

Tracking

Trunk
PowerPC
All
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

16 years ago
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.

Comment 1

16 years ago
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

Updated

16 years ago
Status: NEW → ASSIGNED
(Reporter)

Comment 2

16 years ago
> 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... ;-/
(Assignee)

Comment 3

16 years ago
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

Comment 4

16 years ago
r=sdagley
(Assignee)

Comment 5

16 years ago
I checked that patch in.
Status: NEW → RESOLVED
Last Resolved: 16 years ago
Resolution: --- → FIXED

Comment 6

16 years ago
Roland/Simon, can one of you verify this fix and mark verified-fixed ?

thanks.
(Reporter)

Comment 7

16 years ago
The patch looks OK for me... but I do not have a Mac to test it... ;-(
(Assignee)

Comment 8

16 years ago
vr.
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.