SWT and shell.setImage() under Win98 [message #460358] |
Wed, 24 August 2005 11:17 |
Eclipse User |
|
|
|
Originally posted by: ts.lkv-sh.de
We're developing under Linux and under this OS (and under XP) the
SWT-Programs runs fine.
Sometimes we need to execute the same source under Win98SE and we've the
problem that we got a "no more handles"-error of the internal SWT-Classes:
...
> final Image image2 = new Image(shell.getDisplay(),
> SWTTest.class.getResourceAsStream("lkv.gif"));
>
> // this instruction produces the error!
> shell.setImage(image2);
> ^----------------------
...
>>C:\TMP>java SWTTest
>>Exception in thread "main" org.eclipse.swt.SWTError: No more handles
>> at org.eclipse.swt.SWT.error(SWT.java:2968)
>> at org.eclipse.swt.SWT.error(SWT.java:2865)
>> at org.eclipse.swt.SWT.error(SWT.java:2836)
>> at org.eclipse.swt.graphics.Image.init(Image.java:1777)
>> at org.eclipse.swt.graphics.Image.init(Image.java:1875)
>> at org.eclipse.swt.graphics.Image.<init>(Image.java:596)
>> at
org.eclipse.swt.widgets.Decorations.createIcon(Decorations.j ava:371)
>> at
org.eclipse.swt.widgets.Decorations.setImages(Decorations.ja va:975)
>> at org.eclipse.swt.widgets.Decorations.setImage(Decorations.jav a:930)
>> at SWTTest.main(SWTTest.java:37)
After a close look at the SWT-Docs and after Googling we decide to contact
this forum. Hoping, that there is a solution!
Much thanks,
T.Schmidt, Germany.
|
|
|
|
|
Re: SWT and shell.setImage() under Win98 [message #460397 is a reply to message #460396] |
Wed, 24 August 2005 14:41 |
Eclipse User |
|
|
|
Originally posted by: richkulp.us.NO_SPAM.ibm.com
One other thing about the new Image(display, stream) is that looking at
the code in SWT, I don't see the stream ever being closed. This is also
a handle, so you should do instead:
InputStream in = SWTTest.class.getResourceAsStream("lkv.gif");
if (in != null) {
try {
final Image image2 = new Image(shell.getDisplay(), in);
...
} finally {
try {
in.close();
} catch(IOException e) {
}
}
Also make sure that you are disposing of any image you create when it is
no longer needed.
Alex Blewitt wrote:
> Images are an expensive resource and that not all operating systems support an unlimited number of images. It may be that you just can't keep loading that many images without .dispose()ing of them first of all.
>
> There's a class called ImageDescriptor (it's in JFace.ui) that can help to some extent by only creating images upon demand.
> http://help.eclipse.org/help30/topic/org.eclipse.platform.do c.isv/reference/api/org/eclipse/jface/resource/ImageDescript or.html
>
> I don't know what the limits are like on the Win98 systems, but I think that the only way that you will be able to fix this is to create less images or be very careful that you dispose/recreate them on demand.
--
Thanks,
Rich Kulp
|
|
|
Re: SWT and shell.setImage() under Win98 [message #460410 is a reply to message #460396] |
Thu, 25 August 2005 08:17 |
Eclipse User |
|
|
|
Originally posted by: ts.lkv-sh.de
Much thanks for your answer!
The SWT-Version is actual (V.3.1 from February'05).
The image-resource is as necessary also later disposed. Furthermore we
also tried it with png and ico-Images, the problem reoccurs.
The problem isn't depending on the amount of allocated (image-)resources.
It occurs at _any_, also on the first(!), setImage()-Instruction?!
-Torsten Schmidt-
|
|
|
|
Re: SWT and shell.setImage() under Win98 [message #460446 is a reply to message #460441] |
Fri, 26 August 2005 15:59 |
Eclipse User |
|
|
|
Originally posted by: sunil_kamath.nohotspammail.com
"Steve Northover" <steve_northover@ca.ibm.com> wrote in message
news:denc9b$dht$1@news.eclipse.org...
> Does a simple, stand alone SWT program that creates exactly one shell and
> one image fail? If so, please enter a bug report with the test code.
> Thanks.
>
> "Torsten Schmidt" <ts@lkv-sh.de> wrote in message
> news:bf9d7994ad4f906511e64826dcf1edaa$1@www.eclipse.org...
>>
>> Much thanks for your answer!
>>
>> The SWT-Version is actual (V.3.1 from February'05).
>>
>> The image-resource is as necessary also later disposed. Furthermore we
>> also tried it with png and ico-Images, the problem reoccurs.
>>
>> The problem isn't depending on the amount of allocated (image-)resources.
>> It occurs at _any_, also on the first(!), setImage()-Instruction?!
>>
My $0.02: I have used Shell setImage() on Win 98, Win ME, Win NT, Win 2K and
Win XP without any problems.
---
Sunil
|
|
|
Powered by
FUDForum. Page generated in 0.02841 seconds