Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 65b3a573 authored by cketti's avatar cketti
Browse files

Clone LocalSearch object before modifying it for unread/starred search

parent faa66639
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -64,7 +64,6 @@ import com.fsck.k9.Preferences;
import com.fsck.k9.R;
import com.fsck.k9.activity.misc.ExtendedAsyncTask;
import com.fsck.k9.activity.misc.NonConfigurationInstance;
import com.fsck.k9.activity.setup.AccountSettings;
import com.fsck.k9.activity.setup.AccountSetupBasics;
import com.fsck.k9.activity.setup.Prefs;
import com.fsck.k9.activity.setup.WelcomeMessage;
@@ -1788,7 +1787,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
            LocalSearch search = null;

            if (account instanceof SearchAccount) {
                search = ((SearchAccount) account).getRelatedSearch();
                search = ((SearchAccount) account).getRelatedSearch().clone();
                search.setName(description);
            } else {
                search = new LocalSearch(description);
+29 −0
Original line number Diff line number Diff line
@@ -124,6 +124,35 @@ public class ConditionsTreeNode implements Parcelable {
    }


    /* package */ ConditionsTreeNode cloneTree() {
        if (mParent != null) {
            throw new IllegalStateException("Can't call cloneTree() for a non-root node");
        }

        ConditionsTreeNode copy = new ConditionsTreeNode(mCondition.clone());

        copy.mLeftMPTTMarker = mLeftMPTTMarker;
        copy.mRightMPTTMarker = mRightMPTTMarker;

        copy.mLeft = (mLeft == null) ? null : mLeft.cloneNode(copy);
        copy.mRight = (mRight == null) ? null : mRight.cloneNode(copy);

        return copy;
    }

    private ConditionsTreeNode cloneNode(ConditionsTreeNode parent) {
        ConditionsTreeNode copy = new ConditionsTreeNode(parent, mValue);

        copy.mCondition = mCondition.clone();
        copy.mLeftMPTTMarker = mLeftMPTTMarker;
        copy.mRightMPTTMarker = mRightMPTTMarker;

        copy.mLeft = (mLeft == null) ? null : mLeft.cloneNode(copy);
        copy.mRight = (mRight == null) ? null : mRight.cloneNode(copy);

        return copy;
    }

    ///////////////////////////////////////////////////////////////
    // Public modifiers
    ///////////////////////////////////////////////////////////////
+9 −0
Original line number Diff line number Diff line
@@ -80,6 +80,15 @@ public class LocalSearch implements SearchSpecification {
        }
    }

    @Override
    public LocalSearch clone() {
        ConditionsTreeNode conditions = (mConditions == null) ? null : mConditions.cloneTree();

        LocalSearch copy = new LocalSearch(mName, conditions, null, mPredefined);
        copy.mAccountUuids = new HashSet<String>(mAccountUuids);

        return copy;
    }

    ///////////////////////////////////////////////////////////////
    // Public manipulation methods
+5 −0
Original line number Diff line number Diff line
@@ -134,6 +134,11 @@ public interface SearchSpecification extends Parcelable {
            this.field = Searchfield.values()[in.readInt()];
        }

        @Override
        public SearchCondition clone() {
            return new SearchCondition(field, attribute, value);
        }

        public String toHumanString() {
            return field.toString() + attribute.toString();
        }