* catch and ignore JUnRar OutOfMemoryErrors
This commit is contained in:
parent
1640041266
commit
0c698902df
|
@ -17,25 +17,22 @@ import net.sourceforge.filebot.ResourceManager;
|
|||
|
||||
class LanguageComboBoxCellRenderer implements ListCellRenderer {
|
||||
|
||||
private final Border padding = new EmptyBorder(2, 4, 2, 4);
|
||||
|
||||
private final Border favoritePadding = new EmptyBorder(0, 6, 0, 6);
|
||||
|
||||
private final ListCellRenderer base;
|
||||
|
||||
private Border padding = new EmptyBorder(2, 2, 2, 2);
|
||||
|
||||
private Border favoritePadding = new EmptyBorder(0, 6, 0, 6);
|
||||
|
||||
private ListCellRenderer base;
|
||||
|
||||
|
||||
public LanguageComboBoxCellRenderer(final ListCellRenderer base) {
|
||||
this.base = base;
|
||||
this.padding = new CompoundBorder(padding, ((JLabel) base).getBorder());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||
JLabel c = (JLabel)base.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
JLabel c = (JLabel) base.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
|
||||
Language language = (Language) value;
|
||||
c.setText(language.getName());
|
||||
|
@ -58,5 +55,4 @@ class LanguageComboBoxCellRenderer implements ListCellRenderer {
|
|||
|
||||
return c;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,6 +6,8 @@ import java.io.IOException;
|
|||
import java.nio.ByteBuffer;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.sourceforge.tuned.ByteBufferOutputStream;
|
||||
|
||||
|
@ -37,11 +39,17 @@ class RarArchive implements Archive {
|
|||
|
||||
ByteBufferOutputStream buffer = new ByteBufferOutputStream(header.getDataSize());
|
||||
|
||||
// write contents to buffer
|
||||
rar.extractFile(header, buffer);
|
||||
|
||||
// add memory file
|
||||
vfs.put(header.getFileNameString(), buffer.getByteBuffer());
|
||||
try {
|
||||
// write contents to buffer
|
||||
rar.extractFile(header, buffer);
|
||||
|
||||
// add memory file
|
||||
vfs.put(header.getFileNameString(), buffer.getByteBuffer());
|
||||
} catch (OutOfMemoryError e) {
|
||||
// ignore, there seems to be bug with JUnRar allocating lots of memory for no apparent reason
|
||||
// @see https://sourceforge.net/forum/forum.php?thread_id=2773018&forum_id=706772
|
||||
Logger.getLogger(getClass().getName()).log(Level.WARNING, "Cannot extract " + header.getFileNameString());
|
||||
}
|
||||
}
|
||||
} catch (RarException e) {
|
||||
throw new IOException(e);
|
||||
|
|
|
@ -2,9 +2,8 @@
|
|||
package net.sourceforge.filebot.ui.panel.subtitle;
|
||||
|
||||
|
||||
import static net.sourceforge.filebot.Settings.getApplicationName;
|
||||
import static net.sourceforge.filebot.Settings.getApplicationVersion;
|
||||
import static net.sourceforge.filebot.ui.panel.subtitle.LanguageComboBoxModel.ALL_LANGUAGES;
|
||||
import static net.sourceforge.filebot.Settings.*;
|
||||
import static net.sourceforge.filebot.ui.panel.subtitle.LanguageComboBoxModel.*;
|
||||
|
||||
import java.awt.event.ItemEvent;
|
||||
import java.net.URI;
|
||||
|
@ -45,7 +44,7 @@ public class SubtitlePanel extends AbstractSearchPanel<SubtitleProvider, Subtitl
|
|||
JComboBox languageComboBox = new JComboBox(languageModel);
|
||||
|
||||
languageComboBox.setRenderer(new LanguageComboBoxCellRenderer(languageComboBox.getRenderer()));
|
||||
|
||||
|
||||
// restore state
|
||||
languageModel.setSelectedItem(persistentSelectedLanguage.getValue());
|
||||
languageModel.favorites().addAll(0, persistentFavorites.getValue());
|
||||
|
|
Loading…
Reference in New Issue