From 3ab3b25fad54d5f251a329fd23c8a1e60e14a368 Mon Sep 17 00:00:00 2001 From: Ehsan Akhgari Date: Wed, 9 Aug 2017 19:17:22 -0400 Subject: [PATCH] Bug 1388917 - Fix moving of SelectionState in PlaceholderTransaction's constructor; r=masayuki --- editor/libeditor/EditorBase.cpp | 1 + editor/libeditor/PlaceholderTransaction.cpp | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/editor/libeditor/EditorBase.cpp b/editor/libeditor/EditorBase.cpp index 88372a78c50e..c0ff3142f81c 100644 --- a/editor/libeditor/EditorBase.cpp +++ b/editor/libeditor/EditorBase.cpp @@ -677,6 +677,7 @@ EditorBase::DoTransaction(Selection* aSelection, nsITransaction* aTxn) if (mPlaceholderBatch && !mPlaceholderTransaction) { mPlaceholderTransaction = new PlaceholderTransaction(*this, mPlaceholderName, Move(mSelState)); + MOZ_ASSERT(mSelState.isNothing()); // We will recurse, but will not hit this case in the nested call DoTransaction(mPlaceholderTransaction); diff --git a/editor/libeditor/PlaceholderTransaction.cpp b/editor/libeditor/PlaceholderTransaction.cpp index 8f1fb812d30a..1b9ac6bbcfd3 100644 --- a/editor/libeditor/PlaceholderTransaction.cpp +++ b/editor/libeditor/PlaceholderTransaction.cpp @@ -24,9 +24,12 @@ PlaceholderTransaction::PlaceholderTransaction( , mForwarding(nullptr) , mCompositionTransaction(nullptr) , mCommitted(false) - , mStartSel(Move(*aSelState)) , mEditorBase(&aEditorBase) { + // Make sure to move aSelState into a local variable to null out the original + // Maybe variable. + Maybe selState(Move(aSelState)); + mStartSel = *selState; mName = aName; }