The document iterator now skips math insets and insets like notes where spell check is disabled.
The continuous spell checking is part of the row painter drawing and the spell check disabled state
has to be passed down recursively while doing the inset painting.
As Enrico said, the user might have installed a package that was
missing (in which case the .tex file would not have changed).
Another reason is that changing some document settings did not
automatically lead to a fresh compile after an error (#9061).
Our old mechanism for detemining whether there was an error was to
check if the dependent file existed in the temporary directory. If
it did not exist, that meant it was removed, presumably because
there was an error during compilation. That mechanism cannot be used
anymore because we keep the files around even after error because of
the "Show Output Anyway" button (09700d5b). This commit implements a
more straightforward way of checking whether there was an error in
the previous preview by simply storing the success of last compile
in a buffer variable.
Building on cd8be655, we still allow viewing a produced PDF even if
there were compilation errors. However, now the user must click the
"Show Output Anyway" button in the LaTeX Errors dialog. The reason
is that before, there was a chance that the user would not realize
there was an error (because the PDF would be shown over the error
dialog). The approach in this commit makes it more clear that there
is an error.
A new LFUN is introduced, LFUN_BUFFER_VIEW_CACHE. It is useful not
just for the implementation of the "Show Output Anyway" button, but
also to show the last compiled version of a document, which can save
time if a document takes a long time to compile (e.g. heavy use of
knitr).
The only real user was Text::insertStringAsLine, but this got changed
in commit 2c7152ab.
While not other place did read the value, there is a side effect of
setAutobreakRow that merges exiting paragraphs. However, this is used
in two situations
* some constructors, where the inset is empty;
* InsetTabular::toggleFixedWidth, which actually contains itself some
code to merge paragraphs.
Therefore the member and all associated code can be removed safely.
If LyX thinks the export was successful but no output file was
produced for preview, then something is wrong (most likely LyX
did not detect an error that occurred during export).
Also clean up some logic.
A PDF is often still produced after a LaTeX error.
If there was an error when exporting a PDF, we now give an error
and the PDF (if it exists), where before we gave the error and
not the PDF. The GUI and command line behaviors are consistent:
in the GUI an error is given and the PDF is viewed; on the
command line, a non-zero exit code is given and a PDF is created.
This also solves what was in my mind an inconsistency: if the user
"updated" a document and there was an error, the resulting
PDF would be shown; but if the user viewed a document and there
was an error, the document would not be shown.
Note that this applies to all output formats, not just PDF.
For discussion, see:
https://www.mail-archive.com/lyx-devel@lists.lyx.org/msg186454.html
Rename recordUndoFullDocument to recordUndoFullBuffer.
Separate the notion of recording changes to paragraphs and recording changes in buffer parameters.
Audit every user of recordUndoFullDocument and replace it with either recordUndoBufferParams or recordUndoFullBuffer. Add comments to identify remaining work.
Our TempFile class uses QTemporaryFile internally, and, on Windows,
this keeps the file locked so that we cannot rename it. So we have
to release the lock.
Add display_pixel_ratio to buffer params to use it for displays with high resolution.
It holds the highest ratio between physical pixels and device-independent pixels of the LyX application.
Preview snippets will be generated using this value to get high resolution preview.
FileName::tempName() created a new temp file name by using qt to create a
temporary file with a unique name, and then deleting that file and returning
the name. This was unsafe, since other processes or even other threads of the
running LyX could create files with the same name between deletion and then
using the temp name.
This is fixed by using the TempFile class instead. As a side effect, a few
cases where the temp files were not deleted after usage were fixed as well.
The only place that is still unsafe is createTmpDir().
- The TempFile class guarantees to generate a file name, we are not limited to
100 tries of a predictable scheme anymore, which could break if LyX
frequently crashes.
- The temp file name generation has no race condition against another LyX
instance in the same directory anymore.
- Symlinks survive saving again (regression of 10364082c8).
* remove unused class TexStream.
* remove unused virtual method Inset::cellXOffset
* remove second argument of FileDialog constructor, which was actually
not used
* remove some dead local code
* remove some unused private members of classes
* in InsetMathNest::updateBuffer, fix the logic of a test
for possible thread conflicts, of the sort Georg resolved at
6a30211f. I have made static variables const where possible,
and marked cases that looked potentially problematic with the
comment:
// FIXME THREAD
Many of these definitely are vulnerable to concurrent access, such
as the static variables declared at the start of output_latex.cpp.
Suppose, e.g., we were outputting latex and also displaying the
source of a different document.
I'd appreciate it if others could grep for "FIXME THREAD" and see
if some of these are harmless, or what.
http://marc.info/?l=lyx-devel&m=138590578911716&w=2
If you look at Buffer.cpp, around line 4351, there was a comment about bug 5699. We are seeing the
same crash. The problem is that, although the master does have a GUI, that GUI is in a different window. So the structureChanged() call we do during updateBuffer() is for the TOC in that window, not the TOC in the window we are actually in. So our TocModel::toc_ has been reset and is invalid, though the widget itself has not been updated and looks fine.
This patch tests whether the master is in the same window as the buffer we are updating.
A problem remains, which is noted in a comment.
In e02df14 the return type of doExport was changed from bool to ExportStatus.
All calls except this one were adjusted. This one did now fail because the
numercial value of ExportSuccess is 0.
The new HTML clipboard export could cause error message boxes on copying
data to the clipboard (bug #8866). These are now suppressed, like all other
errors which might occur for preparing the clipboard data.
LyX, lyx2lyx and tex2lyx produce now all the same version indicator consisting
only of the major and minor version. It is not decided yet whether future
development versions will add a -dev suffix, but for 2.1.0 this change fixes
the inconsistencies.
These should be used if any new style needs to be introduced in the stable
2.1 series: If the ForceLocal flag of the style is set, it will always be
written to the document header, so that even older 2.1 versions can read
and correctly output the document.
Move the handling of branch-(de)activate(master) to Buffer. This code was moved to Bufferview in [3a03e71c/lyxgit] because a cursor was necessary to call Undo::recordUndoFullDocument(). However, it turns out that the undo code is already prepared to handle an empty cursor (and do nothing in this case).
Therefore we do that and move the branch code to Buffer where it belongs.
Note that there was a bug in the previous code that broke undo support: recordUndo should always be called _before_ doing any change.
each failure.
There are several places I was not sure what to do. These are marked
by comments beginning "LASSERT:" so they can be found easily. At the
moment, they are at:
Author.cpp:105: // LASSERT: What should we do here?
Author.cpp:121: // LASSERT: What should we do here?
Buffer.cpp:4525: // LASSERT: Is it safe to continue here, or should we just return?
Cursor.cpp:345: // LASSERT: Is it safe to continue here, or should we return?
Cursor.cpp:403: // LASSERT: Is it safe to continue here, or should we return?
Cursor.cpp:1143: // LASSERT: There have been several bugs around this code, that seem
CursorSlice.cpp:83: // LASSERT: This should only ever be called from an InsetMath.
CursorSlice.cpp:92: // LASSERT: This should only ever be called from an InsetMath.
LayoutFile.cpp:303: // LASSERT: Why would this fail?
Text.cpp:995: // LASSERT: Is it safe to continue here?
This was a simple logic error that crept in during refactoring:
If the format does not match, and the converted file has been read,
the string must not be read.
As discussed on the list. No automatic contents detection is done, the user
needs to use the special paste menu instead. I used the new TempFile class
for safe temporary file handling.
The documentation would go into section 2.2 of UserGuide.lyx, but I am not
allowed to edit that document.
The code does a reload on the buffer to avoid loose pointers if the
file changes directory. This commit adds a bool parameter to
Buffer::reload to allow for keeping the undo stack intact. This is of
couse only wanted in this case, not when reloading an earlier version
of the file.
This commit does a bit more than fix selection, since it saves the full cursor state
in the undo stack. This means that undo now restores:
* the selection
* the current font
* transient mark (shall we keep this one?), logical position...
In order to do that, it introduces an intermediate class between Cursor and DotIterator: CursorData.
The new inheritance diagram is thus
DocIteraator -> CursorData -> Cursor
CursorData contains all the members of Cursor that define the current position, but not the stuff
related to current view of dispatch mechanism. It may make sense in the future to move members
between CursorData and Cursor and to move some member functions to CursorData.
Now UndoElement uses CursorData for cur_before and cur_after, but not for the cell. The undo API uses
also CursorData instead of DocIterator.
The idea is to record undo at the place where the document is modified:
1/ in Buffer::updateBuffer, add a recordUndo, with the caveat that a
const_cast has to be used (because updateBuffer is const but
modifies the document, go figure).
2/ in GuiApplication::dispatch, add an extra undo group that
encompasses the updateBuffer call. Some other undo groups may be
redundant now, but it is not a problem since they do not cost
anything.
In this version, the idea is to record undo at the place where the document is modified, which is definitely cleaner.
1/ in Buffer::updateBuffer, add a recordUndo, with the caveat that a
const_cast has to be used
2/ in GuiApplication::dispatch, add an extra undo group that
encompasses the updateBuffer call. Some other undo groups may be
redundant now, but it is not a problem since they do not cost
anything.
While cppcheck did not turn out any suspicious error messages, using
the "performance" flag highlighted several nitpicks in three categories
* do not use it++ for iterators, ++it is better
* do not use size() to test for emptyness, empty() is here
* do not use "const T" as a function parameter, "const & T" is better
I doubt that any of these is a real performance problem, but the code is cleaner anyway.
In this case, the working dir has already a slash at the end.
Appending another one would result in a path ending with a double slash,
which has a special meaning when used in TEXINPUTS (all subdirs would
be recursively scanned). So, avoid doing that.
If a converter specifies the needaux flag, latex (or xelatex) is
always run to produce the needed auxiliary files. This is wrong
because there are documents that can only be compiled with a specific
backend and thus the conversion may fail. On the other hand, even if
the document specifies the backend to be used, LyX ignores this info.
This commit rectifies this behavior by letting LyX run the same flavor
of the latex backend that shall be used for previewing the document
also for producing the auxiliary files.
Math commands need it as well as text commands. At the same time, this
further unifies the checking for termination and fixes cases of wrong
output (e.g. for 0x2005).
We only copied the error list to the cloned buffer when makeLatexfile
failed. This means that a second try will never clear the error list and
the user will be presented the same list again.
Therefore, we unconditionally copy the error list such that we also clear
the list on success.
then trying to compile.
There are really two problems here. One is that the renamed
buffer needs to be reloaded. All kinds of files, etc, may not
exist any more, if we've been saved to a new directory; our
children e.g. may not be in the right place. And, in this case,
we may no longer be a child of our old parent. Reloading will
fix all of that.
On reload, though, we need to clear our parent, since we may
not have one any more. It will get reset if need be.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@40609 a592a061-630c-0410-9148-cb99ea01b6c8
for this yet, however.
Includes elements of a patch by Rob Oakes.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@40409 a592a061-630c-0410-9148-cb99ea01b6c8
We split Buffer::clone() into various routines that know whether
to clone the children.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@40357 a592a061-630c-0410-9148-cb99ea01b6c8
The global list of cloned buffers was a bad idea. We don't have multiple
export threads, but we can have multiple autosave threads. So now we keep
more than one of these lists at the same time, and each cloned buffer has
a pointer to the relevant list. Note that this would make multiple export
possible, if we wanted to do that at some time.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@40227 a592a061-630c-0410-9148-cb99ea01b6c8
the destructor since we could, in some cases, end up deleting them
multiple times. So we need to keep a list of the Buffers we need to
delete, kind of like the BufferList.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@40205 a592a061-630c-0410-9148-cb99ea01b6c8
- Let all doExport calls honor maintain_unincluded_children
- Also don't let the behaviour depend on supplying the result_file parameter
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@40085 a592a061-630c-0410-9148-cb99ea01b6c8
TODO:
- Also let the public function return an error value,
- Move all user interaction (Alerts etc.) out of Buffer.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@40044 a592a061-630c-0410-9148-cb99ea01b6c8
TODO:
- Also let the public function return an error value,
- Move all user interaction (Alerts etc.) out of Buffer.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@40043 a592a061-630c-0410-9148-cb99ea01b6c8
All calls to doExport from outside of Buffer have the same algorithm to
determine whether the included children parameter should be true. Moreover,
this decision is only based on information from the Buffer itself.
Now, Buffer only has 1 public function doExport and preview.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@40041 a592a061-630c-0410-9148-cb99ea01b6c8
The LyX buffer is cloned before autosaving, but the unnamed_ member was not
copied. This causes the autosave files to end up in the wrong location and
consequently they were never removed afterwards.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@40008 a592a061-630c-0410-9148-cb99ea01b6c8
This restores \input@path handling, which turns out to be necessary, as
the TEXINPUTS mechanism is not used with relative paths. It turns out
that both methods must be used, because \input@path does not work in all
cases (most notably with tikz).
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@39918 a592a061-630c-0410-9148-cb99ea01b6c8
Keeping some debugging output about these filename mangling, in case additional debugging is needed.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@39812 a592a061-630c-0410-9148-cb99ea01b6c8