pescuma / swt-paperclips

Automatically exported from code.google.com/p/swt-paperclips
0 stars 0 forks source link

[GTK] PaperClips Linux/GTK errors #3

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Copied from
https://sourceforge.net/tracker/index.php?func=detail&aid=1767045&group_id=14850
9&atid=771872

Refer to:
http://sourceforge.net/forum/forum.php?thread_id=1791252&forum_id=496490

I'm connected to paperclips subversion (Eclipse Europa (3.3), jdk 1.6.0_02,
fedora 7, gnome 2.18.3) and download version 265.

Results are:
- Snippet1 works;
- Snippet2 works;
- Snippet3 works;
- Snippet4 works;
- Snippet5 works;
- Snippet6 works;
- ColumnPrintExample works;
- GridPrintCellClippingExample works;
- GridPrintExample works;
- GridPrintVerticalAlignmentExample works;
- PagePrintExample works;

- Snippets7 hangs with:
Exception in thread "main" java.lang.RuntimeException: Unable to layout
page 1
at net.sf.paperclips.PaperClips.getPages(PaperClips.java:259)
at net.sf.paperclips.PaperClips.getPages(PaperClips.java:232)
at net.sf.paperclips.ui.PrintPreview.getPages(PrintPreview.java:373)
at net.sf.paperclips.ui.PrintPreview.getPageCount(PrintPreview.java:151)
at net.sf.paperclips.examples.Snippet7$1.run(Snippet7.java:108)
at net.sf.paperclips.examples.Snippet7.main(Snippet7.java:331)

- All other example hangs with: (variable parameters)
#
# An unexpected error has been detected by Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x06219976, pid=6000, tid=3086556048
#
# Java VM: Java HotSpot(TM) Client VM (1.6.0_02-b05 mixed mode, sharing)
# Problematic frame:
# V [libjvm.so+0x219976]
#
# An error report file with more information is saved as hs_err_pid6000.log

#
# If you would like to submit a bug report, please visit:
# http://java.sun.com/webapps/bugreport/crash.jsp
#

Same situation in Windows XP Professional with jdk 1.5.0_10 work perfectly.

I have investigated on Linux/Windows and on jdk 1.5/1.6 :
- in Windows with a jre 1.6.0_02 all works fine;
- in linux with a jdk 1.5.0_12 same problems.
So, no problem with java version, but with linux.

About Snippet7, I have already tried with PaperClips.setDebug(true): CPU to
100%, snippet runs forever without no results or errors.

Attach one hs_err_*.log for error on others examples.

----

= Comments =

----

Date: 2007-08-03 09:21
Sender: qualidafialProject AdminAccepting Donations
Logged In: YES 
user_id=168544
Originator: NO

This is two problem reports in one so I'll address them separately:
1) Snippet7 hangs: for some reason Snippet7 is unable to layout on the
printer.  Is the default paper size on your printer unusually small?

The reason setDebug(true) doesn't help in this case is that the we are
artificially validating the layout.  Unfortunately it appears that none of
the main content in the print job can print, therefore we don't even get an
intermediate result.

This is made worse by the fact that PaperClips.getPages() wants to layout
the whole job at once rather than iterating one page at a time, as needed. 
Since debug mode artificially validates the layout even though nothing
fits, we are just endlessly creating empty pages until we run out of memory
or you kill the app.

This could be fixed by changing PaperClips to iterate one page at a time
ratheras they are fetched.  This would allow PrintPreview to only fetch one
page at a time, which will allow you to see where the layout cuts off
abrubtly while in debug mode.

This approach would affect the way that page numbers are handled.  The
PageNumber instance would have to return some value (say,
PageNumber.UNKNOWN) for a page count until the total page count was known. 
Existing PageNumberFormat classes would have to be adapted to handle this
case.

2) SIGSEGV

This is either SWT's fault or the JVM's fault.  From the stack trace in
the error log it seems to be the JVM, but it could be choking on a bad
pointer passed to it from SWT.

You should submit this issue as a bug report to SWT.  Make sure to include
"SIGSEGV" in the summary line, that'll get their attention. 
http://bugs.eclipse.org/bugs/

----

Date: 2007-08-28 15:45
Sender: qualidafialProject AdminAccepting Donations
Logged In: YES 
user_id=168544
Originator: NO

Per the discussion in
https://bugs.eclipse.org/bugs/show_bug.cgi?id=201373: the crashes appear to
be caused by attempting to access the printer API before a Display has been
initialized.

The example snippets are now updated to ensure that a Display is
initialized before attempting to print anything.  Please check out the
latest sources from the experimental StyledTextPrint branch and see if this
addresses the crashing problems:

https://paperclips.svn.sourceforge.net/svnroot/paperclips/branches/experimental/
styledtextprint/net.sf.paperclips
https://paperclips.svn.sourceforge.net/svnroot/paperclips/branches/experimental/
styledtextprint/net.sf.paperclips.examples
https://paperclips.svn.sourceforge.net/svnroot/paperclips/branches/experimental/
styledtextprint/net.sf.paperclips.ui

Matthew

----

Date: 2007-08-29 00:44
Sender: mikydv
Logged In: YES 
user_id=1857408
Originator: YES

The simple initialization of a Display does not resolve the problem.

I investigated and the problem was solved when API was called from a
button selection listener of a visible shell.

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setLayout(new GridLayout());

    Button button = new Button(shell, SWT.NONE);
    button.setText("&Test");
    button.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            Printer printer = new Printer();
            printer.startJob("anewjob");
            printer.startPage();

            //Some draw on printer's gc

            printer.endPage();
            printer.endJob();
            printer.dispose();
        }
    });

    shell.pack();
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}

This code works.

----

Date: 2007-08-29 10:00
Sender: qualidafialProject AdminAccepting Donations
Logged In: YES 
user_id=168544
Originator: NO

Just for fun, could you run this snippet and tell me if it crashes?

public static void main(String[] args) {
  Display.getDefault();
  Printer.getPrinterList();
}

----

Date: 2007-08-29 10:34
Sender: mikydv
Logged In: YES 
user_id=1857408
Originator: YES

No, it doesn't crash anymore.

Bhà ... :-|

----

Date: 2007-08-29 10:43
Sender: qualidafialProject AdminAccepting Donations
Logged In: YES 
user_id=168544
Originator: NO

I just made a small fix in SVN, try the snippets again.

----

Date: 2007-08-30 01:20
Sender: mikydv
Logged In: YES 
user_id=1857408
Originator: YES

Snippets give me these results:

-- SIGSEV
  - AlignPrintExample (after select a printer)
  - ImageCaptureExample
  - TutorialExample1 (after select a printer)
  - TutorialExample2 (after select a printer)

- BreakPrintExample (No shell and no print)
- ColumnPrintExample (Shell OK, no print)
- GridPrintCellClippingExample (Shell OK, blank print)
- GridPrintExample (Shell OK, no print)
- GridPrintVerticalAlignmentExample (Shell OK, print OK)
- NoBreakPrintExample (No shell and no print, Eclipse freeze!!!)
- PagePrintExample (Shell OK, print OK)
- PaperClipsExample (No shell and no print)
- StyledTextPrintExample (Shell OK, print OK)
- Snippet1 (Shell OK, print OK)
- Snippet2 (Shell OK, print OK)
- Snippet3 (Shell OK, print OK, another blank print)
- Snippet4 (Shell OK, print OK, another blank print)
- Snippet5 (Shell OK, print OK)
- Snippet6 (Shell OK, print OK)

- Snippet7
Exception in thread "main" java.lang.RuntimeException: Unable to layout
page 1
    at net.sf.paperclips.PaperClips.getPages(PaperClips.java:284)
    at net.sf.paperclips.PaperClips.getPages(PaperClips.java:252)
    at net.sf.paperclips.ui.PrintPreview.getPages(PrintPreview.java:402)
    at net.sf.paperclips.ui.PrintPreview.getPageCount(PrintPreview.java:161)
    at net.sf.paperclips.examples.Snippet7$1.run(Snippet7.java:111)
    at net.sf.paperclips.examples.Snippet7.main(Snippet7.java:334)

----

Date: 2007-08-30 12:54
Sender: qualidafialProject AdminAccepting Donations
Logged In: YES 
user_id=168544
Originator: NO

For all the snippets that don't crash, but don't print either, try
commenting out the call to GC.setAdvanced(true) in
PaperClips.createConfiguredGC() and try again.  That's the only recent
change that I can think of that might be the cause.

Also, what SWT version are you using?

Matthew

----

Date: 2007-08-31 01:30
Sender: mikydv
Logged In: YES 
user_id=1857408
Originator: YES

SWT version 3.346

Commenting code GC.setAdvanced(true) does not solve the problem.
I have attached a snippet that might help you.
File Added: Test1.java

----

Date: 2007-08-31 01:31
Sender: mikydv
Logged In: YES 
user_id=1857408
Originator: YES

File Added: Test1.java

----

Date: 2007-09-04 09:21
Sender: qualidafialProject AdminAccepting Donations
Logged In: YES 
user_id=168544
Originator: NO

This back and forth for testing is really dragging down the resolution of
this issue.  Right now I'm trying to get myself set up with a Linux box so
I can try out different approaches without the back and forth delay.  I'll
keep you informed.

Matthew

----

Date: 2007-10-17 09:17
Sender: qualidafialProject AdminAccepting Donations
Logged In: YES 
user_id=168544
Originator: NO

This issue was supposed to be fixed by SWT in 3.4M2.  Can anyone on Linux
verify this?

The workaround is to ensure that a Display is initialized before using
Printer (and by extension, PaperClips).

----

Date: 2007-10-25 01:15
Sender: mikydv
Logged In: YES 
user_id=1857408
Originator: YES

I'm working with Fedora 7; problem is corrected with SWT 3.4M2:

    System.out.println(Display.getCurrent());
    Printer.getDefaultPrinterData();
    System.out.println(Display.getCurrent());

    ** Console: **
    null
    null

No Display is created and no error is occured :-)

----

Date: 2007-12-13 09:49
Sender: qualidafialProject AdminAccepting Donations
Logged In: YES 
user_id=168544
Originator: NO

I've submitted a patch to SWT that fixes the problem with the snippets
that don't print at all.  Turns out that printing is done asynchronously
after Printer.endJob() is called, but the snippets would terminate
immediately which was interrupting the delivery of the print jobs.

https://bugs.eclipse.org/bugs/show_bug.cgi?id=212849

With this patch and a few uncommitted updates in PaperClips itself, most
of the snippets work now.

I also found that the font size when printing is directly related to
Gnome's DPI setting in Settings -> Preferences -> Appearances, Fonts ->
Advanced (Ubuntu).  The higher your DPI setting the bigger your text
prints.  Very odd.

Original issue reported on code.google.com by qualidaf...@gmail.com on 9 Oct 2008 at 5:19

GoogleCodeExporter commented 9 years ago

Original comment by qualidaf...@gmail.com on 9 Oct 2008 at 7:57

GoogleCodeExporter commented 9 years ago

Original comment by qualidaf...@gmail.com on 17 Dec 2008 at 5:45

GoogleCodeExporter commented 9 years ago
PaperClips is migrating to the Eclipse project.

This bug is now being tracked at http://bugs.eclipse.org/291863

Original comment by qualidaf...@gmail.com on 9 Oct 2009 at 5:47