Closed Bug 101949 Opened 24 years ago Closed 24 years ago

Make sure that Qt toolkit's |CreateDeviceContextSpec| returns an error code on failure

Categories

(Core :: Printing: Output, defect)

All
Linux
defect
Not set
normal

Tracking

()

VERIFIED FIXED

People

(Reporter: roland.mainz, Assigned: jcgriggs)

Details

Make sure that Qt-toolkit version of |CreateDeviceContextSpec| 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 (Mac is bug 101947).
I think the existing code is OK. It will only return NS_OK if nsComponentManager::CreateInstance manages to create a non-NULL nsIDeviceContextSpec instance and if that instance returns NS_OK from it's Init method (after being cast to an nsDeviceContextSpecQT, of course.) I chased the code into nsDeviceContextSpecQT::Init and it also looks fine - it returns NS_ERROR_FAILURE if there is any problem and NS_OK only if everything works out properly. If CreateDeviceContextSpec encounters any errors creating or Initing the DeviceContextSpec, it returns NS_ERROR_FAILURE as well. Let me know if this needs to be modified.
Note that my new code fires-up an error dialog for every error you return - except for NS_ERROR_ABORT (which means the print dialog itself has been canceled by the user).
I believe that all of the errors that the code currently returns are actually errors - i.e. an error dialog is appropriate. Right now, printing is not implemented in the Qt version of Mozilla, so I will make a note to take care with return codes when I get to that work (which will be a while, since I am currently working on Mozilla in my spare time, which is very limited at the moment). Are there any paritcular failure modes that you are concerned about and where you feel an error dialog is not appropriate?
> Are there any paritcular failure modes that you are concerned about > and where you feel an error dialog is not appropriate? The only thing is NS_ERROR_ABORT which does not trigger an error dialog (it is used to indicate that the user has canceled the print session somehow).
OK. Since printing is not yet implemented in Qt Mozilla, we don't have to worry about cancelled print sessions (yet). I am marking this fixed.
Status: NEW → RESOLVED
Closed: 24 years ago
Resolution: --- → FIXED
Roland/John, please verify and mark verified-fixed...thanks!
VERIFYING per Grigg's comments...
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.