Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 501414

Summary: [GTK][Printer] Snippet318 doesn't work on Linux
Product: [Eclipse Project] Platform Reporter: Niraj Modi <niraj.modi>
Component: SWTAssignee: Platform-SWT-Inbox <platform-swt-inbox>
Status: CLOSED WORKSFORME QA Contact:
Severity: normal    
Priority: P3 CC: akurtakov, arunkumar.thondapu, ericwill, sravankumarl
Version: 4.7Keywords: triaged
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
Updated Snippet318.java none

Description Niraj Modi CLA 2016-09-14 06:59:32 EDT
Tried with Ubuntu16.04:
Eclipse print option is working but Snippet318 doesn't prints the test page.

Note: If printer preferences are not set then we get below error:
Exception in thread "main" org.eclipse.swt.SWTError: No more handles
	at org.eclipse.swt.SWT.error(SWT.java:4559)
	at org.eclipse.swt.SWT.error(SWT.java:4448)
	at org.eclipse.swt.SWT.error(SWT.java:4419)
	at org.eclipse.swt.printing.Printer.checkNull(Printer.java:299)
	at org.eclipse.swt.printing.Printer.<init>(Printer.java:343)
	at org.eclipse.swt.snippets.Snippet318.main(Snippet318.java:34)

Same snippet works on Windows.
Comment 1 Niraj Modi CLA 2016-09-14 07:00:57 EDT
This bug blocks us from verifying fix-patch in bug 498876 on Linux.
Comment 2 Alexander Kurtakov CLA 2016-09-14 14:31:09 EDT
What happens on Windows if you have no printer installed?
Comment 3 Alexander Kurtakov CLA 2016-09-14 14:32:50 EDT
ERROR_NO_HANDLES - if there are no valid printers from Printer(PrinterData) is documented in the javadoc even.
Comment 4 Niraj Modi CLA 2016-09-15 02:17:20 EDT
(In reply to Alexander Kurtakov from comment #2)
> What happens on Windows if you have no printer installed?
I don't have a configuration handy to try this but IMHO it should be throwing exception similar to comment 0

(In reply to Alexander Kurtakov from comment #3)
> ERROR_NO_HANDLES - if there are no valid printers from Printer(PrinterData)
> is documented in the javadoc even.
On Linux, even if a valid printer is configured Snippet318 doesn't print anything(as tried on Ubuntu16.04), whereas same snippet works on Windows.
Comment 5 Alexander Kurtakov CLA 2016-09-15 05:12:35 EDT
I see so with no valid printer there is no exception but nothing is printed. I'll try that.
Comment 6 Alexander Kurtakov CLA 2016-09-15 05:13:10 EDT
I mean with valid printer.
Comment 7 Eric Williams CLA 2016-09-15 10:33:09 EDT
I ran this snippet on my Fedora 24 machine that has a printer configured, but not connected.

The snippet runs and terminates. Nothing happens, nothing printed to console, no exceptions thrown.
Comment 8 Leo Ufimtsev CLA 2016-09-16 11:05:11 EDT
I experienced some breakage in printer in Gtk3.16/Gtk3.18. I wonder if this bug (In reply to Eric Williams from comment #7)
> I ran this snippet on my Fedora 24 machine that has a printer configured,
> but not connected.
> 
> The snippet runs and terminates. Nothing happens, nothing printed to
> console, no exceptions thrown.

I get the same. I get "no more handles" if I run with older version of GTK, ex 3.16.
Comment 9 Niraj Modi CLA 2016-09-19 05:39:51 EDT
Created attachment 264245 [details]
Updated Snippet318.java

(In reply to Eric Williams from comment #7)
(In reply to Leo Ufimtsev from comment #8)
Thanks Eric/Leo for trying.

I updated the Snippet318 to identify when no Default Printer is set and instead print to a PDF file.
Comment 10 Alexander Kurtakov CLA 2018-03-16 16:01:25 EDT
Can this one be closed now?
Comment 11 Eric Williams CLA 2019-01-08 17:07:49 EST
(In reply to Alexander Kurtakov from comment #10)
> Can this one be closed now?

No response in awhile so I am closing it.