diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ClassPath.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ClassPath.java index 2d50465bf..6e4396cc3 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ClassPath.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ClassPath.java @@ -12,17 +12,19 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.abc; import com.jpexs.decompiler.graph.DottedChain; +import java.io.Serializable; import java.util.Objects; /** * * @author JPEXS */ -public class ClassPath { +public class ClassPath implements Serializable { public final DottedChain packageStr; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/search/ABCSearchResult.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/search/ABCSearchResult.java index 0c57c7a49..fcf56cc08 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/search/ABCSearchResult.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/search/ABCSearchResult.java @@ -55,11 +55,10 @@ public class ABCSearchResult implements Serializable { private final int traitId; @SuppressWarnings("unchecked") - public ABCSearchResult(SWF swf, InputStream is) throws IOException, ScriptNotFoundException { - ObjectInputStream ois = new ObjectInputStream(is); + public ABCSearchResult(SWF swf, ObjectInputStream ois) throws IOException, ScriptNotFoundException { int versionMajor = ois.read(); ois.read(); //minor - if (versionMajor != -1) { + if (versionMajor != 1) { throw new IOException("Unknown search result version"); } @@ -89,8 +88,7 @@ public class ABCSearchResult implements Serializable { } } - public void save(OutputStream os) throws IOException { - ObjectOutputStream oos = new ObjectOutputStream(os); + public void save(ObjectOutputStream oos) throws IOException { oos.write(1); //version major oos.write(0); //version minor oos.writeObject(scriptPack.getClassPath()); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/search/ActionSearchResult.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/search/ActionSearchResult.java index 3bb05bad5..4e11e7116 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/search/ActionSearchResult.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/search/ActionSearchResult.java @@ -22,6 +22,8 @@ import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.io.InputStream; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; import java.io.OutputStream; import java.util.Map; @@ -37,22 +39,20 @@ public class ActionSearchResult { private final String path; - public ActionSearchResult(SWF swf, InputStream is) throws IOException, ScriptNotFoundException { + public ActionSearchResult(SWF swf, ObjectInputStream ois) throws IOException, ScriptNotFoundException { Map asms = swf.getASMs(false); - DataInputStream dais = new DataInputStream(is); - path = dais.readUTF(); + path = ois.readUTF(); if (asms.containsKey(path)) { src = asms.get(path); } else { throw new ScriptNotFoundException(); } - pcode = dais.readBoolean(); + pcode = ois.readBoolean(); } - public void save(OutputStream os) throws IOException { - DataOutputStream daos = new DataOutputStream(os); - daos.writeUTF(path); - daos.writeBoolean(pcode); + public void save(ObjectOutputStream oos) throws IOException { + oos.writeUTF(path); + oos.writeBoolean(pcode); } public ActionSearchResult(ASMSource src, boolean pcode, String path) { diff --git a/src/com/jpexs/decompiler/flash/gui/MainFrameMenu.java b/src/com/jpexs/decompiler/flash/gui/MainFrameMenu.java index 12f4e740e..1e0a88c69 100644 --- a/src/com/jpexs/decompiler/flash/gui/MainFrameMenu.java +++ b/src/com/jpexs/decompiler/flash/gui/MainFrameMenu.java @@ -1170,14 +1170,15 @@ public abstract class MainFrameMenu implements MenuBuilder { } } + @SuppressWarnings("unchecked") protected void loadRecentSearches(ActionEvent evt) { clearMenu("/tools/" + (supportsMenuAction() ? "search" : "recentsearch")); SWF swf = Main.getMainFrame().getPanel().getCurrentSwf(); List indices = Main.searchResultsStorage.getIndicesForSwf(swf); for (int i = 0; i < indices.size(); i++) { - String searched = Main.searchResultsStorage.getSearchedValueAt(i); - final int fi = i; + final int fi = indices.get(i); + String searched = Main.searchResultsStorage.getSearchedValueAt(fi); ActionListener a = (ActionEvent e) -> { SearchResultsDialog sr; if (swf.isAS3()) { diff --git a/src/com/jpexs/decompiler/flash/gui/MainFrameRibbonMenu.java b/src/com/jpexs/decompiler/flash/gui/MainFrameRibbonMenu.java index f2d699d71..1b8cfb25f 100644 --- a/src/com/jpexs/decompiler/flash/gui/MainFrameRibbonMenu.java +++ b/src/com/jpexs/decompiler/flash/gui/MainFrameRibbonMenu.java @@ -170,10 +170,11 @@ public class MainFrameRibbonMenu extends MainFrameMenu { int j = 0; for (int i = indices.size() - 1; i >= 0; i--) { - String searched = Main.searchResultsStorage.getSearchedValueAt(i); + final int fi = indices.get(i); + String searched = Main.searchResultsStorage.getSearchedValueAt(fi); RecentSearchesButton historyButton = new RecentSearchesButton(j + " " + searched, null); historyButton.search = searched; - final int fi = i; + historyButton.addActionListener((ActionEvent ae) -> { SearchResultsDialog sr; if (swf.isAS3()) { diff --git a/src/com/jpexs/decompiler/flash/gui/SearchResultsStorage.java b/src/com/jpexs/decompiler/flash/gui/SearchResultsStorage.java index 69841c4ab..68af03f00 100644 --- a/src/com/jpexs/decompiler/flash/gui/SearchResultsStorage.java +++ b/src/com/jpexs/decompiler/flash/gui/SearchResultsStorage.java @@ -113,11 +113,11 @@ public class SearchResultsStorage { byte[] itemData = data.get(index); try { - DataInputStream dais = new DataInputStream(new ByteArrayInputStream(itemData)); - int cnt = dais.readInt(); + ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(itemData)); + int cnt = ois.readInt(); for (int i = 0; i < cnt; i++) { try { - result.add(new ABCSearchResult(swf, dais)); + result.add(new ABCSearchResult(swf, ois)); } catch (ScriptNotFoundException ex) { //ignore } @@ -138,11 +138,11 @@ public class SearchResultsStorage { byte[] itemData = data.get(index); try { - DataInputStream dais = new DataInputStream(new ByteArrayInputStream(itemData)); - int cnt = dais.readInt(); + ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(itemData)); + int cnt = ois.readInt(); for (int i = 0; i < cnt; i++) { try { - result.add(new ActionSearchResult(swf, dais)); + result.add(new ActionSearchResult(swf, ois)); } catch (ScriptNotFoundException ex) { //ignore } @@ -190,13 +190,13 @@ public class SearchResultsStorage { isRegExp.add(regExp); unpackedData.put(data.size(), new ArrayList<>(results)); ByteArrayOutputStream baos = new ByteArrayOutputStream(); - DataOutputStream daos = new DataOutputStream(baos); try { - daos.writeInt(results.size()); + ObjectOutputStream oos = new ObjectOutputStream(baos); + oos.writeInt(results.size()); for (ABCSearchResult res : results) { - res.save(daos); + res.save(oos); } - daos.flush(); + oos.flush(); } catch (IOException ex) { Logger.getLogger(SearchResultsStorage.class.getName()).log(Level.SEVERE, null, ex); } @@ -212,13 +212,13 @@ public class SearchResultsStorage { isRegExp.add(regExp); unpackedData.put(data.size(), new ArrayList<>(results)); ByteArrayOutputStream baos = new ByteArrayOutputStream(); - DataOutputStream daos = new DataOutputStream(baos); try { - daos.writeInt(results.size()); + ObjectOutputStream oos = new ObjectOutputStream(baos); + oos.writeInt(results.size()); for (ActionSearchResult res : results) { - res.save(daos); + res.save(oos); } - daos.flush(); + oos.flush(); } catch (IOException ex) { Logger.getLogger(SearchResultsStorage.class.getName()).log(Level.SEVERE, null, ex); }