From 0c698902df7a866893f7fe6133daf46a8f228cf0 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Tue, 2 Jun 2009 17:14:54 +0000 Subject: [PATCH] * catch and ignore JUnRar OutOfMemoryErrors --- .../subtitle/LanguageComboBoxCellRenderer.java | 18 +++++++----------- .../filebot/ui/panel/subtitle/RarArchive.java | 18 +++++++++++++----- .../ui/panel/subtitle/SubtitlePanel.java | 7 +++---- 3 files changed, 23 insertions(+), 20 deletions(-) diff --git a/source/net/sourceforge/filebot/ui/panel/subtitle/LanguageComboBoxCellRenderer.java b/source/net/sourceforge/filebot/ui/panel/subtitle/LanguageComboBoxCellRenderer.java index 7e080204..72bb8a07 100644 --- a/source/net/sourceforge/filebot/ui/panel/subtitle/LanguageComboBoxCellRenderer.java +++ b/source/net/sourceforge/filebot/ui/panel/subtitle/LanguageComboBoxCellRenderer.java @@ -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; } - } diff --git a/source/net/sourceforge/filebot/ui/panel/subtitle/RarArchive.java b/source/net/sourceforge/filebot/ui/panel/subtitle/RarArchive.java index 55aa0575..26e3521b 100644 --- a/source/net/sourceforge/filebot/ui/panel/subtitle/RarArchive.java +++ b/source/net/sourceforge/filebot/ui/panel/subtitle/RarArchive.java @@ -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); diff --git a/source/net/sourceforge/filebot/ui/panel/subtitle/SubtitlePanel.java b/source/net/sourceforge/filebot/ui/panel/subtitle/SubtitlePanel.java index f07370d7..c691e09a 100644 --- a/source/net/sourceforge/filebot/ui/panel/subtitle/SubtitlePanel.java +++ b/source/net/sourceforge/filebot/ui/panel/subtitle/SubtitlePanel.java @@ -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