[jitsi-dev] [jitsi-commits] master: Fixes possible NPE. (285bad6)


#1

b/src/net/java/sip/communicator/plugin/desktoputil/plaf/SearchFieldUI.jav
a @@ -482,11 +482,9 @@ public class SearchFieldUI
         int x = evt.getX();
         int y = evt.getY();
- Rectangle callButtonRect = getCallButtonRect();
-
         boolean outsideButtons = true;
- if (isCallIconVisible && callButtonRect.contains(x, y))
+ if (isCallIconVisible && getCallButtonRect().contains(x, y))
         {
             JTextComponent c = getComponent();
             String searchText = c.getText();

I don't see how this change should avoid an NPE...?

Ingo


#2

Well inside the calls of getCallButtonRect(); a component for call
button is used which throws NPE and that component is not null when
isCallIconVisible is true.
I mean calling getCallButtonRect() only if isCallIconVisible is true.
Sorry for not putting any comment in the code with explanation.

···

On Tue, Mar 11, 2014 at 4:58 PM, Ingo Bauersachs <ingo@jitsi.org> wrote:

b/src/net/java/sip/communicator/plugin/desktoputil/plaf/SearchFieldUI.jav
a @@ -482,11 +482,9 @@ public class SearchFieldUI
         int x = evt.getX();
         int y = evt.getY();
- Rectangle callButtonRect = getCallButtonRect();
-
         boolean outsideButtons = true;
- if (isCallIconVisible && callButtonRect.contains(x, y))
+ if (isCallIconVisible && getCallButtonRect().contains(x, y))
         {
             JTextComponent c = getComponent();
             String searchText = c.getText();

I don't see how this change should avoid an NPE...?

Ingo

_______________________________________________
dev mailing list
dev@jitsi.org
Unsubscribe instructions and other list options:
http://lists.jitsi.org/mailman/listinfo/dev


#3

Well inside the calls of getCallButtonRect(); a component for call
button is used which throws NPE and that component is not null when
isCallIconVisible is true.
I mean calling getCallButtonRect() only if isCallIconVisible is true.

Okay, but the change doesn't do anything in this regard - it was already the
case.

Sorry for not putting any comment in the code with explanation.

b/src/net/java/sip/communicator/plugin/desktoputil/plaf/SearchFieldUI.jav

···

On Tue, Mar 11, 2014 at 4:58 PM, Ingo Bauersachs <ingo@jitsi.org> wrote:

a @@ -482,11 +482,9 @@ public class SearchFieldUI
         int x = evt.getX();
         int y = evt.getY();
- Rectangle callButtonRect = getCallButtonRect();
-
         boolean outsideButtons = true;
- if (isCallIconVisible && callButtonRect.contains(x, y))
+ if (isCallIconVisible && getCallButtonRect().contains(x, y))
         {
             JTextComponent c = getComponent();
             String searchText = c.getText();

I don't see how this change should avoid an NPE...?


#4

No it wasn't :slight_smile: Call of getCallButtonRect() was before checking
isCallIconVisible.

···

On Tue, Mar 11, 2014 at 5:29 PM, Ingo Bauersachs <ingo@jitsi.org> wrote:

Well inside the calls of getCallButtonRect(); a component for call
button is used which throws NPE and that component is not null when
isCallIconVisible is true.
I mean calling getCallButtonRect() only if isCallIconVisible is true.

Okay, but the change doesn't do anything in this regard - it was already the
case.

Sorry for not putting any comment in the code with explanation.

On Tue, Mar 11, 2014 at 4:58 PM, Ingo Bauersachs <ingo@jitsi.org> wrote:

b/src/net/java/sip/communicator/plugin/desktoputil/plaf/SearchFieldUI.jav

a @@ -482,11 +482,9 @@ public class SearchFieldUI
         int x = evt.getX();
         int y = evt.getY();
- Rectangle callButtonRect = getCallButtonRect();
-
         boolean outsideButtons = true;
- if (isCallIconVisible && callButtonRect.contains(x, y))
+ if (isCallIconVisible && getCallButtonRect().contains(x, y))
         {
             JTextComponent c = getComponent();
             String searchText = c.getText();

I don't see how this change should avoid an NPE...?

_______________________________________________
dev mailing list
dev@jitsi.org
Unsubscribe instructions and other list options:
http://lists.jitsi.org/mailman/listinfo/dev


#5

No it wasn't :slight_smile: Call of getCallButtonRect() was before checking
isCallIconVisible.

Well, okay. I thought getCallButtonRect() was returning null and the
.contains call was throwing. Excuse me if I'm blunt now, but I think this is
bad style. The NPE should be handled where it occurs.

Ingo


#6

Hum, I don't think so, It looks ok to me. The fact that the second
statement in the if clause is not evaluated when using && is used in
many places in the code.
Then adding one more if will do the same, but having more if
statements one into another is more unreadable then this.

        if (isCallIconVisible)
        {
            Rectangle callButtonRect = getCallButtonRect();

            if(callButtonRect.contains(x, y))
            {

Here is the exception:

     [java] java.lang.NullPointerException
     [java] at net.java.sip.communicator.plugin.desktoputil.plaf.SearchFieldUI.getCallButtonRect(SearchFieldUI.java:235)
     [java] at net.java.sip.communicator.plugin.desktoputil.plaf.SearchFieldUI.updateIcon(SearchFieldUI.java:485)
     [java] at net.java.sip.communicator.impl.gui.main.contactlist.ContactSearchFieldUI.updateIcon(ContactSearchFieldUI.java:167)
     [java] at net.java.sip.communicator.plugin.desktoputil.plaf.SearchFieldUI.mouseEntered(SearchFieldUI.java:385)
     [java] at java.awt.AWTEventMulticaster.mouseEntered(AWTEventMulticaster.java:300)