classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cp-patches] Patch: Constructor fixes


From: Mark Wielaard
Subject: Re: [cp-patches] Patch: Constructor fixes
Date: Fri, 13 Jan 2006 08:19:41 +0100

Hi,

On Tue, 2006-01-03 at 13:42 -0500, Lillian Angel wrote:
> I fixed some constructor problems in several swing classes. These were
> pointed out by several mauve tests.
> 
> 2006-01-03  Lillian Angel  <address@hidden>
>
>         * javax/swing/JMenuItem.java
>         (JMenuItem): Set all defaults if the action passed in is not 
>       null.
> [...]
> diff -u -r1.23 JMenuItem.java
> --- javax/swing/JMenuItem.java  14 Nov 2005 20:23:56 -0000      1.23
> +++ javax/swing/JMenuItem.java  3 Jan 2006 18:37:47 -0000
> @@ -117,6 +117,13 @@
>      super();
>      super.setAction(action);
>      init(null, null);
> +    if (action != null)
> +      {
> +        setName((String) action.getValue(Action.NAME));
> +        setAccelerator((KeyStroke) action.getValue(Action.ACCELERATOR_KEY));
> +        setMnemonic(((Integer) 
> action.getValue(Action.MNEMONIC_KEY)).intValue());
> +        setActionCommand((String) 
> action.getValue(Action.ACTION_COMMAND_KEY));
> +      }
>    }

This part causes a NullPointerException when the the mnemonic isn't set.
Fixed as follows:

2006-01-13  Mark Wielaard  <address@hidden>

        * javax/swing/JMenuItem.java (JMenuItem(Action)): Check whether
        name, accel, mnemonic and command are defined before setting.

Committed,

Mark
Index: javax/swing/JMenuItem.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/JMenuItem.java,v
retrieving revision 1.25
diff -u -r1.25 JMenuItem.java
--- javax/swing/JMenuItem.java  4 Jan 2006 16:06:17 -0000       1.25
+++ javax/swing/JMenuItem.java  13 Jan 2006 07:19:11 -0000
@@ -1,5 +1,5 @@
 /* JMenuItem.java --
-   Copyright (C) 2002, 2004, 2005  Free Software Foundation, Inc.
+   Copyright (C) 2002, 2004, 2005,2006  Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -119,10 +119,21 @@
     init(null, null);
     if (action != null)
       {
-        setName((String) action.getValue(Action.NAME));
-        setAccelerator((KeyStroke) action.getValue(Action.ACCELERATOR_KEY));
-        setMnemonic(((Integer) 
action.getValue(Action.MNEMONIC_KEY)).intValue());
-        setActionCommand((String) action.getValue(Action.ACTION_COMMAND_KEY));
+       String name = (String) action.getValue(Action.NAME);
+       if (name != null)
+          setName(name);
+
+       KeyStroke accel = (KeyStroke) action.getValue(Action.ACCELERATOR_KEY);
+       if (accel != null)
+          setAccelerator(accel);
+
+       Integer mnemonic = (Integer) action.getValue(Action.MNEMONIC_KEY);
+       if (mnemonic != null)
+          setMnemonic(mnemonic.intValue());
+
+       String command = (String) action.getValue(Action.ACTION_COMMAND_KEY);
+       if (command != null)
+          setActionCommand(command);
       }
   }
 

Attachment: signature.asc
Description: This is a digitally signed message part


reply via email to

[Prev in Thread] Current Thread [Next in Thread]