Closed Bug 424751 Opened 16 years ago Closed 16 years ago

On Linux/Unix, landscape mode setting failed if there is no CUPS printer configured.

Categories

(Core :: Printing: Output, defect)

x86
SunOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla1.9

People

(Reporter: leon.sha, Assigned: leon.sha)

Details

Attachments

(1 file, 1 obsolete file)

I am trying to reproduce bug 389949 on solaris. I found that landscape mode in File->Page Setup is ignored. Even in print preview, I can only preview in Portrait. This also happened on linux if there is no printer setup in system. I got a javascript error. 

getPrintSettings: [Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIPrintSettingsService.initPrintSettingsFromPrinter]"  nsresult: "0x80004005 (NS_ERROR_FAILURE)"  location: "JS frame :: chrome://global/content/printUtils.js :: anonymous :: line 123"  data: no]

The reason here is for those who has no CUPS printer configured, the default printer name is "Postscript/default". In the function nsPrintSettingsGTK::SetPrinterName, this default printer name was cut of to "". Which makes aPrintSettings.printerName in printUtils.js:160 is NULL and cause the javascript error.
Attached patch patch (obsolete) — Splinter Review
Attachment #311342 - Flags: review?
Attachment #311342 - Flags: review? → review?(kherron+mozilla)
I have talked to KH. He think that there should be other way to fix this bug and the psshared directory should be removed. But before that happend, I'd like to consider my patch as a workaround.
Also I have checked the functions in psshared directory, the main function is to get the printer list. Gtk printing module has a function gtk_enumerate_printers. Although this function has some problems, this is the more correct way to get printer list than using CUPS directly.
Flags: blocking1.9?
I'm confused, is this code you're patching actually still used?
(In reply to comment #3)
> I'm confused, is this code you're patching actually still used?
> 
Yes. It is still used.
In my original GTK printing patch, printingui would fall back to the old XUL print dialog if it couldn't display the GTK dialog. Michael's work was based on that patch, and it looks like the fallback behavior was left in. See <http://mxr.mozilla.org/seamonkey/source/embedding/components/printingui/src/unixshared/nsPrintingPromptService.cpp#108>.

I think the real question here is why the GTK print dialog can't be displayed. Leon, what version of GTK+ do you have on your system? The printing subsystem was first added to GTK+ 2.10.
Michael, can you look at this? Comment 5 implies that it doesn't block ...
Flags: blocking1.9? → blocking1.9-
There is probably a lot of code still laying around that accesses CUPS directly, though its too much of a risky change to refactor it all for 1.9.
(In reply to comment #5)

> I think the real question here is why the GTK print dialog can't be displayed.
> Leon, what version of GTK+ do you have on your system? The printing subsystem
> was first added to GTK+ 2.10.
> 

You mis-understand this problem. The GTK print dialog is OK and can be displayed.
But the psshared directory is still used. When you set the orientation, you need a default printer. Default printer came from printer list which is got from psshared (not gtk print dialog). So if you do not have cups printer, you will get the default printer "POSTSCRIPT/default". And when you set the printer name, this "POSTSCRIPT/default" printer has been filtered out because it contains "POSTSCRIPT". My patch is to change the default printer name to "default" so that it will not be filtered out.
In that case, wouldn't it be better to remove the code that does the filtering?

Change nsPrintSettingsGTK::SetPrinterName() so it doesn't filter on Postscript/ and tell me if it accomplishes the same thing (also, if you can could you test it on a machine that does have a printer configured? Both an existing Fx3 profile and a new one, just to see if it doesn't regress)
Attached patch patch v2Splinter Review
This patch accomplishes the same thing as my last patch. Also there is no regression if you have a printer configured. The only thing I concerned is that if use set "printer_list" in the preference by himself, the printer list in page setup and print dialog will no match. This may cause some problems. But I think this situation will seldom happen.
Attachment #311342 - Attachment is obsolete: true
Attachment #315722 - Flags: review?(ventnor.bugzilla)
Attachment #311342 - Flags: review?(kherron+mozilla)
Comment on attachment 315722 [details] [diff] [review]
patch v2

r=me, but this will require a superreview either from roc@ocallahan.org or vladimir@pobox.com. I'm also assuming you've tested it in many cases, including a new profile and a profile that has already printed something at least once.

I don't think there is a way to automatically test this, is there?
Attachment #315722 - Flags: review?(ventnor.bugzilla) → review+
(In reply to comment #11)
> (From update of attachment 315722 [details] [diff] [review])
> r=me, but this will require a superreview either from roc@ocallahan.org or
> vladimir@pobox.com. I'm also assuming you've tested it in many cases, including
> a new profile and a profile that has already printed something at least once.
> 
Yes, I have already done these tests on both linux and solairs.
> I don't think there is a way to automatically test this, is there?
> 
No, I believe.

Attachment #315722 - Flags: superreview?(roc)
Attachment #315722 - Flags: superreview?(roc) → superreview+
Comment on attachment 315722 [details] [diff] [review]
patch v2

Drivers: do small bug fixes require tests (litmus or not) to land?
Attachment #315722 - Flags: approval1.9?
Comment on attachment 315722 [details] [diff] [review]
patch v2

a=beltzner

ventron: a litmus test would be nice, yes.
Attachment #315722 - Flags: approval1.9? → approval1.9+
Leon, do you have the ability to check in CVS? (if so, you can do so now)

As for Litmus test, I believe it goes like this:
Without any kind of CUPS printer installed on the system, go to File > Page Setup, and change the orientation to Landscape. Click OK, reopen the dialog, and verify it hasn't changed back to Portrait.
Flags: in-litmus?
Checking in nsPrintSettingsGTK.cpp;
/cvsroot/mozilla/widget/src/gtk2/nsPrintSettingsGTK.cpp,v  <--  nsPrintSettingsGTK.cpp
new revision: 1.9; previous revision: 1.8
done
Status: NEW → RESOLVED
Closed: 16 years ago
Resolution: --- → FIXED
Assignee: nobody → leon.sha
Target Milestone: --- → mozilla1.9
https://litmus.mozilla.org/show_test.cgi?id=5270
Flags: in-litmus? → in-litmus+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: