Problem with PaperClips on OS X

3 views
Skip to first unread message

Bjorn Gustafsson

unread,
Aug 31, 2009, 6:33:19 PM8/31/09
to SWT PaperClips
Hi,
first off: thanks for a good feature. Much appreciated.

I use PaperClips in my Win application without problems, but I'm
encountering problems on OS X.

I'm seeing the exact same problem in e.g. Snippet7 in the bundled
examples: I'm getting an exception in the creation of a new GC in
PrintPreview.getGC()
(I'm using PaperClips 1.0.4)

Any ideas as to how to make it work?

Thanks in advance,
Bjorn Gustafsson


Matthew Hall

unread,
Sep 1, 2009, 9:36:57 AM9/1/09
to swt-pap...@googlegroups.com
Bjorn Gustafsson wrote:
> Hi,
> first off: thanks for a good feature. Much appreciated.
>
You're welcome, and thanks for using PaperClips!

> I use PaperClips in my Win application without problems, but I'm
> encountering problems on OS X.
>
> I'm seeing the exact same problem in e.g. Snippet7 in the bundled
> examples: I'm getting an exception in the creation of a new GC in
> PrintPreview.getGC()
> (I'm using PaperClips 1.0.4)
>
Would you send a stack trace?

Also, which version of SWT are you using? (i.e. the bundle version,
including the build date in the jar filename) It would also help to
know whether you are using the Cocoa or Carbon port.

Matthew

Bjorn Gustafsson

unread,
Sep 1, 2009, 10:44:50 AM9/1/09
to swt-pap...@googlegroups.com
Thanks for looking into this Matthew,
I'm using SWT Cocoa and the jars are the following versions:
org.eclipse.swt_3.5.0.v3550b.jar
org.eclipse.swt.cocoa.macosx_3.5.0.v3550b.jar

thanks in advance,
/Bjorn Gustafsson

Stack trace:
Snippet7 [Java Application]
net.sf.paperclips.examples.Snippet7 at localhost:49285
Thread [main] (Running)
Daemon Thread [Thread-0] (Suspended (exception NullPointerException))
Printer.internal_new_GC(GCData) line: 307
GC.<init>(Drawable, int) line: 169
GC.<init>(Drawable) line: 132
PrintPreview.getGC() line: 507
PrintPreview.fetchPages(int) line: 535
PrintPreview.getPageCount() line: 188
Snippet7$UI.updatePageNumber() line: 440
Snippet7$UI.createShell() line: 103
Snippet7.main(String[]) line: 523
/System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/bin/java (Sep 1, 2009 7:26:39 AM)

This is where the error occurs (high-lighted):
(The 'operation' field is non-null, so it must be the context returned by  operation.context() that is null)
public int /*long*/ internal_new_GC(GCData data) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
NSAutoreleasePool pool = null;
if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init();
try {
if (data != null) {
if (isGCCreated) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
data.device = this;
data.background = getSystemColor(SWT.COLOR_WHITE).handle;
data.foreground = getSystemColor(SWT.COLOR_BLACK).handle;
data.font = getSystemFont ();
float scaling = scalingFactor();
Point dpi = getDPI (), screenDPI = getIndependentDPI();
NSSize size = printInfo.paperSize();
size.width = (size.width * (dpi.x / screenDPI.x)) / scaling;
size.height = (size.height * dpi.y / screenDPI.y) / scaling;
data.size = size;
isGCCreated = true;
}
return operation.context().id;
} finally {
if (pool != null) pool.release();
}
}

Matthew Hall

unread,
Sep 2, 2009, 4:21:02 PM9/2/09
to swt-pap...@googlegroups.com
Bjorn,

This appears looks like a SWT bug in the Cocoa port.  If you file a bug really, really quickly you could possibly get it fixed in time for 3.5.1 maintenance release coming soon.

Matthew

Bjorn Gustafsson

unread,
Sep 2, 2009, 6:16:33 PM9/2/09
to swt-pap...@googlegroups.com
Thanks Matthew,

just filed a bug - #288414

thanks,
Bjorn
Reply all
Reply to author
Forward
0 new messages