Trolltech Home | Qt-jambi-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 1

Qt-jambi-interest Archive, November 2007
java.lang.NullPointerException QPixmap (Mac OSX Leopard)


Message 1 in thread

Hi,

I have a problem to set a QPixmap to QLabel.

First, i defined my Classpath for the Images in global String of my class:

private String rsrcPath = "classpath:org/code79/images";

Then I create the QLabel and want to add a simple Pixmap:

QLabel topImage = new QLabel(this);
topImage.setPixmap(new QPixmap(this.rsrcPath + "/error.gif"));

When I run my Application, a SystemNullPointerException is thrown:


java.lang.NullPointerException
	at 
com.trolltech.qt.QClassPathEngine.findClassPaths(QClassPathFileEngineHandler.java:895)
	at 

com.trolltech.qt.QClassPathEngine.setFileName(QClassPathFileEngineHandler.java:562)
	at 

com.trolltech.qt.QClassPathEngine.<init>(QClassPathFileEngineHandler.java:504)
	at 
com.trolltech.qt.QClassPathFileEngineHandler.create(QClassPathFileEngineHandler.java:936)
	at 

com.trolltech.qt.gui.QPixmap.__qt_QPixmap_String_nativepointer_ImageConversionFlags(Native 
Method)
	at com.trolltech.qt.gui.QPixmap.<init>(QPixmap.java:24)
	at com.trolltech.qt.gui.QPixmap.<init>(QPixmap.java:557)
	at com.trolltech.qt.gui.QPixmap.<init>(QPixmap.java:561)
	at com.trolltech.qt.gui.QPixmap.<init>(QPixmap.java:565)
	at com.trolltech.qt.gui.QPixmap.<init>(QPixmap.java:569)
	at org.code79.classes.gui.QYeahMainWindow.createGUI(QYeahMainWindow.java:50)
	at org.code79.classes.gui.QYeahMainWindow.<init>(QYeahMainWindow.java:24)
	at org.code79.util.Loader.main(Loader.java:20)

My Images are located in the package org.code79.images, so it should be 
in the classpath. If its useful, I use Eclipse on Mac OSX leopard.

Thanks in advance

Daniel


Message 2 in thread

Hi, Daniel.

Daniel Schmidt wrote:
> When I run my Application, a SystemNullPointerException is thrown:
>
>
> java.lang.NullPointerException
>     at 
> com.trolltech.qt.QClassPathEngine.findClassPaths(QClassPathFileEngineHandler.java:895) 
>
>

This is due to a bug with using Qt Jambi on Mac OS X Leopard (on 
Leopard, Thread.getContextClassLoader() returns null.) Setting the 
context class loader on your thread at start up could solve the problem, 
though we haven't tested this. If not, you can replace your class files 
with the updated ones in the following post:

    
http://lists.trolltech.com/qt-jambi-interest/2007-11/msg00013.html#msg00013

The both go in the com.trolltech.qt package. Using these files the bug 
should be fixed. Hope this helps!

-- Eskil



Message 3 in thread

Eskil Abrahamsen Blomfeldt wrote:
> Hi, Daniel.
>
> Daniel Schmidt wrote:
>> When I run my Application, a SystemNullPointerException is thrown:
>>
>>
>> java.lang.NullPointerException
>>     at 
>> com.trolltech.qt.QClassPathEngine.findClassPaths(QClassPathFileEngineHandler.java:895) 
>>
>>
>
> This is due to a bug with using Qt Jambi on Mac OS X Leopard (on 
> Leopard, Thread.getContextClassLoader() returns null.) Setting the 
> context class loader on your thread at start up could solve the 
> problem, though we haven't tested this. If not, you can replace your 
> class files with the updated ones in the following post:
>
>    
> http://lists.trolltech.com/qt-jambi-interest/2007-11/msg00013.html#msg00013 
>
>
>

Oops, sorry about that, I didn't actually test to see that the links for 
the binary files worked, and apparently they don't.

I've attached the two files in question to this mail instead.

-- Eskil

Attachment:

Attachment: Utilities.class
Description: Binary data

Attachment: QClassPathFileEngineHandler.class
Description: Binary data


Message 4 in thread

Hi Eskil,

thanks, I will test this.

Btw, when I replace the Image with an PNG, I can set a QPixmap to a 
QLabel. So,I'm a liitle confused about this. Isn't it possible in 
general to get a QPixmap Object from a gif file ?
(I'm fairly new to Qt and QtJambi.)

Ah, thanks for the files.


On 2007-11-20 10:42:34 +0100, Eskil Abrahamsen Blomfeldt 
<eblomfel@xxxxxxxxxxxxx> said:

> Hi, Daniel.
> 
> Daniel Schmidt wrote:
>> When I run my Application, a SystemNullPointerException is thrown:
>> 
>> 
>> java.lang.NullPointerException
>>     at 
>> com.trolltech.qt.QClassPathEngine.findClassPaths(QClassPathFileEngineHandler.java:895)


This 
>> 
> is due to a bug with using Qt Jambi on Mac OS X Leopard (on Leopard, 
> Thread.getContextClassLoader() returns null.) Setting the context class 
> loader on your thread at start up could solve the problem, though we 
> haven't tested this. If not, you can replace your class files with the 
> updated ones in the following post:
> 
>     http://lists.trolltech.com/qt-jambi-interest/2007-11/msg00013.html#msg00013
> 
> The both go in the com.trolltech.qt package. Using these files the bug 
> should be fixed. Hope this helps!
> 
> -- Eskil



Message 5 in thread

Daniel Schmidt wrote:
> Btw, when I replace the Image with an PNG, I can set a QPixmap to a 
> QLabel. So,I'm a liitle confused about this. Isn't it possible in 
> general to get a QPixmap Object from a gif file ?
> (I'm fairly new to Qt and QtJambi.)

In order to support some file types such as .gif and .jpeg, Qt Jambi 
needs to know the location of a few plugins, as described here:

    
http://doc.trolltech.com/qtjambi-4.3.2_01/com/trolltech/qt/qtjambi-installation.html#manually-launching-qt-jambi-applications

Setting the QT_PLUGIN_PATH environment variable to 
/path/to/jambi/plugins might be most appropriate for development, and 
you can pack the plugins into a .jar file for deployment and use the 
com.trolltech.qt.pluginjars JVM property.

Please note that this will be handled automatically starting with Qt 
Jambi 4.4, but until then you will need these extra steps to get support 
for certain image file types.

-- Eskil


Message 6 in thread

Thanks for this explanation.

On 2007-11-20 11:34:12 +0100, Eskil Abrahamsen Blomfeldt 
<eblomfel@xxxxxxxxxxxxx> said:

> Daniel Schmidt wrote:
>> Btw, when I replace the Image with an PNG, I can set a QPixmap to a 
>> QLabel. So,I'm a liitle confused about this. Isn't it possible in 
>> general to get a QPixmap Object from a gif file ?
>> (I'm fairly new to Qt and QtJambi.)
> 
> In order to support some file types such as .gif and .jpeg, Qt Jambi 
> needs to know the location of a few plugins, as described here:
> 
>     
> http://doc.trolltech.com/qtjambi-4.3.2_01/com/trolltech/qt/qtjambi-installation.html#manually-launching-qt-jambi-applications

Setting 
> 
> the QT_PLUGIN_PATH environment variable to /path/to/jambi/plugins might 
> be most appropriate for development, and you can pack the plugins into 
> a .jar file for deployment and use the com.trolltech.qt.pluginjars JVM 
> property.
> 
> Please note that this will be handled automatically starting with Qt 
> Jambi 4.4, but until then you will need these extra steps to get 
> support for certain image file types.
> 
> -- Eskil