mirror of
https://github.com/mitb-archive/filebot
synced 2024-11-11 11:55:03 -05:00
Fix NPE that crashes Swing EDT in Subtitles Panel (when search results includes odd languages)
This commit is contained in:
parent
56204e783f
commit
67e10db23d
@ -1,7 +1,6 @@
|
||||
|
||||
package net.filebot.ui.subtitle;
|
||||
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Insets;
|
||||
|
||||
@ -10,18 +9,17 @@ import javax.swing.JLabel;
|
||||
import javax.swing.JList;
|
||||
import javax.swing.border.CompoundBorder;
|
||||
|
||||
import net.filebot.Language;
|
||||
import net.filebot.ResourceManager;
|
||||
import net.filebot.util.ui.AbstractFancyListCellRenderer;
|
||||
import net.filebot.util.ui.DashedSeparator;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
|
||||
|
||||
class SubtitlePackageCellRenderer extends AbstractFancyListCellRenderer {
|
||||
|
||||
private final JLabel titleLabel = new JLabel();
|
||||
private final JLabel languageLabel = new JLabel();
|
||||
|
||||
|
||||
public SubtitlePackageCellRenderer() {
|
||||
super(new Insets(5, 5, 5, 5));
|
||||
setHighlightingEnabled(false);
|
||||
@ -34,7 +32,6 @@ class SubtitlePackageCellRenderer extends AbstractFancyListCellRenderer {
|
||||
setBorder(new CompoundBorder(new DashedSeparator(2, 4, Color.lightGray, Color.white), getBorder()));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void configureListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||
super.configureListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
@ -45,8 +42,14 @@ class SubtitlePackageCellRenderer extends AbstractFancyListCellRenderer {
|
||||
titleLabel.setIcon(getIcon(subtitle));
|
||||
|
||||
if (languageLabel.isVisible()) {
|
||||
languageLabel.setText(subtitle.getLanguage().getName());
|
||||
languageLabel.setIcon(ResourceManager.getFlagIcon(subtitle.getLanguage().getCode()));
|
||||
Language language = subtitle.getLanguage();
|
||||
if (language != null) {
|
||||
languageLabel.setText(language.getName());
|
||||
languageLabel.setIcon(ResourceManager.getFlagIcon(language.getCode()));
|
||||
} else {
|
||||
languageLabel.setText("Unkown Language");
|
||||
languageLabel.setIcon(ResourceManager.getFlagIcon("undefined"));
|
||||
}
|
||||
}
|
||||
|
||||
titleLabel.setForeground(isSelected ? list.getSelectionForeground() : list.getForeground());
|
||||
@ -56,7 +59,6 @@ class SubtitlePackageCellRenderer extends AbstractFancyListCellRenderer {
|
||||
setBorderPainted(index < list.getModel().getSize() - 1);
|
||||
}
|
||||
|
||||
|
||||
private Icon getIcon(SubtitlePackage subtitle) {
|
||||
switch (subtitle.getDownload().getPhase()) {
|
||||
case PENDING:
|
||||
@ -75,12 +77,10 @@ class SubtitlePackageCellRenderer extends AbstractFancyListCellRenderer {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public JLabel getLanguageLabel() {
|
||||
return languageLabel;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void validate() {
|
||||
// validate children, yet avoid flickering of the mouse cursor
|
||||
|
Loading…
Reference in New Issue
Block a user