harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Chunrong Lai (JIRA)" <j...@apache.org>
Subject [jira] Created: (HARMONY-5066) [classlib][awt] Harmony crashes when LinuxCursorFactory.createCustomCursor
Date Sun, 04 Nov 2007 19:33:50 GMT
[classlib][awt] Harmony crashes when LinuxCursorFactory.createCustomCursor
--------------------------------------------------------------------------

                 Key: HARMONY-5066
                 URL: https://issues.apache.org/jira/browse/HARMONY-5066
             Project: Harmony
          Issue Type: Bug
          Components: Classlib
         Environment: Linux32
            Reporter: Chunrong Lai
         Attachments: 3100.png


 Harmony has bug in raster databuffer allocation.
 Below reproducer crashes (java CursorIconTest 3100.png)
import java.io.*;
import java.awt.*;
import java.awt.image.*;
import javax.swing.*;
import java.awt.event.MouseListener;

public class CursorIconTest extends JFrame {
        public CursorIconTest(String imageName) {
           super("Cursor Icon Test");
           initComponent(imageName);
        }

        public static void  main(String[] args){
                if(args.length <1) {
                  System.out.println("Please input a valid image name");
                  System.exit(0);
                }
                CursorIconTest aTest = new CursorIconTest(args[0]);
                aTest.setVisible(true);
        }

         private void initComponent(String imageName) {
                Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
                setLocation(d.width / 4, d.height / 4);
                setSize(d.width / 2, d.height / 2);
                setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                setResizable(false);
                CursorIconPanel iconPanel = new CursorIconPanel(imageName, d.width / 2, d.height
/ 2);
                getContentPane().add(iconPanel);
         }
}

class CursorIconPanel extends JPanel implements MouseListener{
         public CursorIconPanel(String nameofImage, int width, int height) {
                super(null);
                 imageName = nameofImage;
                tempImage = null;
                cursor = null;
                 textArea = new JTextArea("This is a cursor test!")	;
                 textArea.setBounds(0, 0, width, height);
                 add(textArea);
                 textArea.addMouseListener(this);
          }

          public void getCursorImage() {
                if (tempImage == null) {
                   tempImage = Toolkit.getDefaultToolkit().getImage(imageName);
                   MediaTracker imageTracker = new MediaTracker(this);
                   imageTracker.addImage(tempImage, 0);
                   try {
                     imageTracker.waitForID(0);
                   }catch(InterruptedException e) {
                     e.printStackTrace();
                   }
                }
                if (cursor == null) {
                   cursor = Toolkit.getDefaultToolkit().createCustomCursor(tempImage, new
Point(16, 16), "TextClick right");
                }
          }

         public String imageName;
         public Image tempImage;
         public Cursor cursor;
         private JTextArea textArea;

        public void mouseEntered(java.awt.event.MouseEvent e) {
              getCursorImage();
              textArea.setCursor(cursor);
        }
        public void mouseExited(java.awt.event.MouseEvent e) {}
        public void mousePressed(java.awt.event.MouseEvent e) {}
        public void mouseReleased(java.awt.event.MouseEvent e) {}
        public void mouseClicked(java.awt.event.MouseEvent e) {}
}

  with below trace

java.awt.image.RasterFormatException: dataBuffer is too small
        at java.awt.image.Raster.validateDataBuffer(Raster.java:859)
        at java.awt.image.Raster.<init>(Raster.java:609)
        at java.awt.image.WritableRaster.<init>(WritableRaster.java:33)
        at java.awt.image.WritableRaster.<init>(WritableRaster.java:39)
        at org.apache.harmony.awt.gl.image.OrdinaryWritableRaster.<init>(OrdinaryWritableRaster.java:44)
        at java.awt.image.Raster.createPackedRaster(Raster.java:414)
        at java.awt.image.Raster.createPackedRaster(Raster.java:479)
        at java.awt.image.BufferedImage.<init>(BufferedImage.java:323)
        at org.apache.harmony.awt.wtk.linux.LinuxCursorFactory.convertTo1Bit(LinuxCursorFactory.java:280)
        at org.apache.harmony.awt.wtk.linux.LinuxCursorFactory.createCustomCursor(LinuxCursorFactory.java:99)
        at java.awt.Toolkit.createCustomNativeCursor(Toolkit.java:1208)
        at java.awt.Cursor.getNativeCursor(Cursor.java:235)
        at java.awt.Component.setCursor(Component.java:2795)
        at java.awt.Component.setCursor(Component.java:2771)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message