Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    (BUG) Img.getImageWidth() gives nullpointer exception

    (SC_SNAPSHOT-2011-02-07/PowerEdition Deployment 2011-02-07)
    Browser: mozilla firefox, 3.6.13

    I think there is a bug with the Img class.

    Can be reproduced in the standalone testcase:
    Code:
    package test;
    
    import com.google.gwt.core.client.EntryPoint;
    import com.smartgwt.client.util.SC;
    import com.smartgwt.client.widgets.Img;
    import com.smartgwt.client.widgets.layout.VLayout;
    
    public class ImgStandaloneTestcase implements EntryPoint {
    	private VLayout mainPanel = new VLayout();
    
    	public void onModuleLoad() {
    		mainPanel.setHeight100();
    		mainPanel.setWidth100();
    
                    
                    //replace by some image on your disk, any image crashes. 
                    //Image exists, removing the int imgWidth... line shows the image.
    		Img i = new Img("uploads/Category/Category_image_3.png"); 
    		mainPanel.addMember(i);
    		int imgWidth = i.getImageWidth(); //NullpointerException at this line
    		SC.say("image width: "+imgWidth);
    		mainPanel.show();
    
    	}
    
    }
    I get a nullpointer exception like so (package names are wrong, but this was the quickest way to setup a standalone testcase, instead of creating new project):
    Code:
    18:27:47.288 [ERROR] [generatedcode] Unable to load module entry point class nl.sytematic.projects.LikeManagementSystem.client.LikeManagementSystemMain (see associated exception for details)
    
    java.lang.NullPointerException: null
        at nl.sytematic.projects.LikeManagementSystem.client.LikeManagementSystemMain.onModuleLoad(LikeManagementSystemMain.java:57)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:369)
        at com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:185)
        at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:380)
        at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:222)
        at java.lang.Thread.run(Thread.java:680)

    #2
    In the Power nightly of 03-05-2011 this still happens. Will this be fixed? I would like to request the original img dimensions..

    Otherwise I would have to write a servlet to request that information, which is not what I want. Are there other options? Or could you just fix it ? :-)

    Comment


      #3
      This API shouldn't crash, but all it would give you back is whatever you passed to setImageWidth() - null in this case. Determining native image size can be done with GWT's core Image class.

      Comment


        #4
        Ah that makes sense, thank you.

        Comment

        Working...
        X