On 11/05/2015 04:02 PM, Jean-Marc Lasgouttes wrote:
Le 05/11/15 21:41, Richard Heck a écrit :
Trivial fix:
> case LFUN_CHANGES_TRACK:
> buffer_.params().track_changes =
> !buffer_.params().track_changes;
> + buffer().markDirty();
Va de retro, satanas! Never ever call marDirty explicitly!
Trivial fix is to have a proper proper recordUndo call, which will as
an collateral benefit mark the buffer dirty.
Better fix would be to move this to Buffer::dispatch too, since it
certainly does not require a bufferview.
OK, try this one.
Richard
>From e4f6a052923c4a66e879898eea5edb49f35aa0f0 Mon Sep 17 00:00:00 2001
From: Richard Heck <rgh...@lyx.org>
Date: Thu, 5 Nov 2015 16:42:30 -0500
Subject: [PATCH] Move LFUN_CHANGES_TRACK and LFUN_CHANGES_OUTPUT to
Buffer.cpp, and record an undo call. This deals with the problem of marking
the Buffer dirty, as well.
---
src/Buffer.cpp | 39 +++++++++++++++++++++++++++++++++++++++
src/BufferView.cpp | 37 -------------------------------------
2 files changed, 39 insertions(+), 37 deletions(-)
diff --git a/src/Buffer.cpp b/src/Buffer.cpp
index 847b029..78f3a51 100644
--- a/src/Buffer.cpp
+++ b/src/Buffer.cpp
@@ -2445,6 +2445,16 @@ bool Buffer::getStatus(FuncRequest const & cmd, FuncStatus & flag)
enable = (d->preview_file_).exists() && !(d->preview_file_).isFileEmpty();
break;
+ case LFUN_CHANGES_TRACK:
+ flag.setEnabled(true);
+ flag.setOnOff(params().track_changes);
+ break;
+
+ case LFUN_CHANGES_OUTPUT:
+ flag.setEnabled(true);
+ flag.setOnOff(params().output_changes);
+ break;
+
default:
return false;
}
@@ -2674,6 +2684,35 @@ void Buffer::dispatch(FuncRequest const & func, DispatchResult & dr)
dr.setMessage(_("Error viewing the output file."));
break;
+ case LFUN_CHANGES_TRACK:
+ undo().recordUndoBufferParams(CursorData());
+ params().track_changes = !params().track_changes;
+ break;
+
+ case LFUN_CHANGES_OUTPUT:
+ undo().recordUndoBufferParams(CursorData());
+ params().output_changes = !params().output_changes;
+ if (params().output_changes) {
+ bool dvipost = LaTeXFeatures::isAvailable("dvipost");
+ bool xcolorulem = LaTeXFeatures::isAvailable("ulem") &&
+ LaTeXFeatures::isAvailable("xcolor");
+
+ if (!dvipost && !xcolorulem) {
+ Alert::warning(_("Changes not shown in LaTeX output"),
+ _("Changes will not be highlighted in LaTeX output, "
+ "because neither dvipost nor xcolor/ulem are installed.\n"
+ "Please install these packages or redefine "
+ "\\lyxadded and \\lyxdeleted in the LaTeX preamble."));
+ } else if (!xcolorulem) {
+ Alert::warning(_("Changes not shown in LaTeX output"),
+ _("Changes will not be highlighted in LaTeX output "
+ "when using pdflatex, because xcolor and ulem are not installed.\n"
+ "Please install both packages or redefine "
+ "\\lyxadded and \\lyxdeleted in the LaTeX preamble."));
+ }
+ }
+ break;
+
default:
dispatched = false;
break;
diff --git a/src/BufferView.cpp b/src/BufferView.cpp
index 9a9a77b..7fdfe79 100644
--- a/src/BufferView.cpp
+++ b/src/BufferView.cpp
@@ -1124,16 +1124,6 @@ bool BufferView::getStatus(FuncRequest const & cmd, FuncStatus & flag)
|| getInsetByCode<InsetRef>(cur, REF_CODE));
break;
- case LFUN_CHANGES_TRACK:
- flag.setEnabled(true);
- flag.setOnOff(buffer_.params().track_changes);
- break;
-
- case LFUN_CHANGES_OUTPUT:
- flag.setEnabled(true);
- flag.setOnOff(buffer_.params().output_changes);
- break;
-
case LFUN_CHANGES_MERGE:
case LFUN_CHANGE_NEXT:
case LFUN_CHANGE_PREVIOUS:
@@ -1458,33 +1448,6 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
break;
}
- case LFUN_CHANGES_TRACK:
- buffer_.params().track_changes = !buffer_.params().track_changes;
- break;
-
- case LFUN_CHANGES_OUTPUT:
- buffer_.params().output_changes = !buffer_.params().output_changes;
- if (buffer_.params().output_changes) {
- bool dvipost = LaTeXFeatures::isAvailable("dvipost");
- bool xcolorulem = LaTeXFeatures::isAvailable("ulem") &&
- LaTeXFeatures::isAvailable("xcolor");
-
- if (!dvipost && !xcolorulem) {
- Alert::warning(_("Changes not shown in LaTeX output"),
- _("Changes will not be highlighted in LaTeX output, "
- "because neither dvipost nor xcolor/ulem are installed.\n"
- "Please install these packages or redefine "
- "\\lyxadded and \\lyxdeleted in the LaTeX preamble."));
- } else if (!xcolorulem) {
- Alert::warning(_("Changes not shown in LaTeX output"),
- _("Changes will not be highlighted in LaTeX output "
- "when using pdflatex, because xcolor and ulem are not installed.\n"
- "Please install both packages or redefine "
- "\\lyxadded and \\lyxdeleted in the LaTeX preamble."));
- }
- }
- break;
-
case LFUN_CHANGE_NEXT:
findNextChange(this);
// FIXME: Move this LFUN to Buffer so that we don't have to do this:
--
2.1.0