[LyX/master] Unify handling in dispatchVC.

Pavel Sanda sanda at lyx.org
Sat Feb 15 19:38:33 UTC 2020


commit 2db6a81156a13a8265457b1eb6ec40d58b43c0eb
Author: Pavel Sanda <sanda at lyx.org>
Date:   Sat Feb 15 20:55:14 2020 +0100

    Unify handling in dispatchVC.
    
    All these check could be actually dropped, because unless dispatchVC
    is called directly, getstatus would already handle it.
---
 src/frontends/qt/GuiView.cpp |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/src/frontends/qt/GuiView.cpp b/src/frontends/qt/GuiView.cpp
index eec1b7a..29f97e7 100644
--- a/src/frontends/qt/GuiView.cpp
+++ b/src/frontends/qt/GuiView.cpp
@@ -3518,8 +3518,7 @@ void GuiView::dispatchVC(FuncRequest const & cmd, DispatchResult & dr)
 		break;
 
 	case LFUN_VC_LOCKING_TOGGLE:
-		LASSERT(buffer, return);
-		if (!ensureBufferClean(buffer) || buffer->hasReadonlyFlag())
+		if (!buffer || !ensureBufferClean(buffer) || buffer->hasReadonlyFlag())
 			break;
 		if (buffer->lyxvc().inUse()) {
 			string res = buffer->lyxvc().lockingToggle();
@@ -3534,7 +3533,8 @@ void GuiView::dispatchVC(FuncRequest const & cmd, DispatchResult & dr)
 		break;
 
 	case LFUN_VC_REVERT:
-		LASSERT(buffer, return);
+		if (!buffer)
+			break;
 		if (buffer->lyxvc().revert()) {
 			reloadBuffer(*buffer);
 			dr.clearMessageUpdate();
@@ -3542,6 +3542,8 @@ void GuiView::dispatchVC(FuncRequest const & cmd, DispatchResult & dr)
 		break;
 
 	case LFUN_VC_UNDO_LAST:
+		if (!buffer)
+			break;
 		LASSERT(buffer, return);
 		buffer->lyxvc().undoLast();
 		reloadBuffer(*buffer);
@@ -3549,7 +3551,8 @@ void GuiView::dispatchVC(FuncRequest const & cmd, DispatchResult & dr)
 		break;
 
 	case LFUN_VC_REPO_UPDATE:
-		LASSERT(buffer, return);
+		if (!buffer)
+			break;
 		if (ensureBufferClean(buffer)) {
 			dr.setMessage(buffer->lyxvc().repoUpdate());
 			checkExternallyModifiedBuffers();
@@ -3603,10 +3606,11 @@ void GuiView::dispatchVC(FuncRequest const & cmd, DispatchResult & dr)
 			lyx::dispatch(FuncRequest(LFUN_DIALOG_SHOW, "comparehistory"));
 			break;
 		}
+		if (!buffer)
+			break;
 
 		string rev1 = cmd.getArg(0);
 		string f1, f2;
-		LATTEST(buffer)
 
 		// f1
 		if (!buffer->lyxvc().prepareFileRevision(rev1, f1))


More information about the lyx-cvs mailing list