From 17e747b2fc3fbcce793f379df48ffc5d6989df84 Mon Sep 17 00:00:00 2001 From: Floens Date: Mon, 29 Jun 2015 19:55:53 +0200 Subject: [PATCH] Copy the loadable when adding to history Otherwise the database will possible use the loadable from a pin, and when clearing the history also deleting the loadable from the pin. --- .../src/main/java/org/floens/chan/core/model/Loadable.java | 2 +- .../java/org/floens/chan/core/presenter/ThreadPresenter.java | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Clover/app/src/main/java/org/floens/chan/core/model/Loadable.java b/Clover/app/src/main/java/org/floens/chan/core/model/Loadable.java index ca2ccdb1..60331747 100644 --- a/Clover/app/src/main/java/org/floens/chan/core/model/Loadable.java +++ b/Clover/app/src/main/java/org/floens/chan/core/model/Loadable.java @@ -28,7 +28,7 @@ import com.j256.ormlite.table.DatabaseTable; @DatabaseTable public class Loadable { @DatabaseField(generatedId = true) - private int id; + public int id; @DatabaseField public int mode = Mode.INVALID; diff --git a/Clover/app/src/main/java/org/floens/chan/core/presenter/ThreadPresenter.java b/Clover/app/src/main/java/org/floens/chan/core/presenter/ThreadPresenter.java index 5ccf6aa5..208afae3 100644 --- a/Clover/app/src/main/java/org/floens/chan/core/presenter/ThreadPresenter.java +++ b/Clover/app/src/main/java/org/floens/chan/core/presenter/ThreadPresenter.java @@ -571,7 +571,10 @@ public class ThreadPresenter implements ChanLoader.ChanLoaderCallback, PostAdapt if (!historyAdded && ChanSettings.historyEnabled.get() && loadable.isThreadMode()) { historyAdded = true; History history = new History(); - history.loadable = loadable; + // Copy the loadable when adding to history + // Otherwise the database will possible use the loadable from a pin, and when clearing the history also deleting the loadable from the pin. + history.loadable = loadable.copy(); + history.loadable.id = 0; history.thumbnailUrl = chanLoader.getThread().op.thumbnailUrl; databaseManager.addHistory(history); }