Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » SWT and shell.setImage() under Win98
SWT and shell.setImage() under Win98 [message #460358] Wed, 24 August 2005 11:17 Go to next message
Eclipse UserFriend
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 #460375 is a reply to message #460358] Wed, 24 August 2005 13:39 Go to previous messageGo to next message
Olivier Chalouhi is currently offline Olivier ChalouhiFriend
Messages: 10
Registered: July 2009
Junior Member
What version of SWT are you using?
I'd try with a .png instead of a gif.

Olivier.

Torsten Schmidt wrote:
>
> 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 #460396 is a reply to message #460358] Wed, 24 August 2005 14:29 Go to previous messageGo to next message
Alex Blewitt is currently offline Alex BlewittFriend
Messages: 946
Registered: July 2009
Senior Member
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.
Re: SWT and shell.setImage() under Win98 [message #460397 is a reply to message #460396] Wed, 24 August 2005 14:41 Go to previous messageGo to next message
Eclipse UserFriend
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 Go to previous messageGo to next message
Eclipse UserFriend
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 #460441 is a reply to message #460410] Fri, 26 August 2005 15:25 Go to previous messageGo to next message
Steve Northover is currently offline Steve NorthoverFriend
Messages: 1636
Registered: July 2009
Senior Member
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?!
>
>
> -Torsten Schmidt-
>
>
Re: SWT and shell.setImage() under Win98 [message #460446 is a reply to message #460441] Fri, 26 August 2005 15:59 Go to previous message
Eclipse UserFriend
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
Previous Topic:swt 64bit keeps crashing in SuSE 64
Next Topic:Running Eclipse with my own SWT jar
Goto Forum:
  


Current Time: Wed Apr 14 05:39:37 GMT 2021

Powered by FUDForum. Page generated in 0.01997 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top