ContactInfoWindow: fix NPE when window was disposed

This commit is contained in:
Sergey Ponomarev
2026-07-11 17:34:11 +02:00
parent fe0dc3a0d3
commit 3934d5a77f
2 changed files with 25 additions and 23 deletions

View File

@ -333,10 +333,12 @@ public class ContactGroup extends CollapsiblePane implements MouseListener {
for (Component comp : comps) {
if (comp instanceof JPanel) {
JPanel panel = (JPanel) comp;
ContactGroup group = (ContactGroup) panel.getComponent(0);
if (group == contactGroup) {
listPanel.remove(panel);
break;
if (panel.getComponentCount() > 0) {
ContactGroup group = (ContactGroup) panel.getComponent(0);
if (group == contactGroup) {
listPanel.remove(panel);
break;
}
}
}
}
@ -841,7 +843,7 @@ public class ContactGroup extends CollapsiblePane implements MouseListener {
public void mouseEntered(MouseEvent mouseEvent) {
canShowPopup = true;
timerTask = new DisplayWindowTask(mouseEvent);
TaskEngine.getInstance().schedule(timerTask, 500, 1000);
TaskEngine.getInstance().schedule(timerTask, 750, 1000);
}
@Override
@ -918,17 +920,18 @@ public class ContactGroup extends CollapsiblePane implements MouseListener {
* Displays the <code>ContactInfoWindow</code>.
*/
private void displayWindow(MouseEvent e) {
if (preferences.areVCardsVisible()) {
final ContactGroup parent = this;
final SwingWorker worker = new SwingWorker() {
@Override
public Object construct() {
UIComponentRegistry.getContactInfoWindow().display(parent, e);
return null;
}
};
worker.start();
if (!preferences.areVCardsVisible()) {
return;
}
ContactGroup parent = this;
SwingWorker worker = new SwingWorker() {
@Override
public Object construct() {
UIComponentRegistry.getContactInfoWindow().display(parent, e);
return null;
}
};
worker.start();
}
private boolean needToChangePopup(MouseEvent e) {

View File

@ -162,9 +162,7 @@ public class ContactInfoWindow extends JPanel {
int x = (int)mainWindowLocation.getX() + mainWindow.getWidth();
int y = (int) listLocation.getY() + (int) point.getY();
setWindowLocation(x, y);
if (!window.isVisible()) {
window.setVisible(true);
}
window.setVisible(true);
}
public void setWindowLocation(int x, int y) {
@ -188,6 +186,10 @@ public class ContactInfoWindow extends JPanel {
}
public void customizeUI() {
// When the window was closed the contactItem is cleared
if (contactItem == null) {
return;
}
nicknameLabel.setText(contactItem.getDisplayName());
boolean isOnLeave = contactItem.getPresence() == null || contactItem.getPresence().getType() == Presence.Type.unavailable;
@ -242,7 +244,7 @@ public class ContactInfoWindow extends JPanel {
}
private void retrieveIdleTime(boolean isOnLeave) {
//FIXME sometimes the contactItem is null
// When the window was closed the contactItem is cleared
if (contactItem == null) {
return;
}
@ -288,9 +290,6 @@ public class ContactInfoWindow extends JPanel {
public void setContactItem(ContactItem contactItem) {
this.contactItem = contactItem;
if (contactItem == null) {
return;
}
customizeUI();
}
@ -299,8 +298,8 @@ public class ContactInfoWindow extends JPanel {
}
public void dispose() {
window.setVisible(false);
contactItem = null;
window.setVisible(false);
window.dispose();
}