Commit Graph

568 Commits

Author SHA1 Message Date
Juergen Spitzmueller
8239e66c94 Add BufferParams::bibtexCommand()
This function returns the real command (either per lyxrc or bufferparam)
2017-01-01 10:49:22 +01:00
Tommaso Cucinotta
244de5d2c1 Add 'needauth' option to converters that need explicit user authorization.
Addressing #10481.

This patch adds the new 'needauth' option for converters launching
external programs that are capable of running arbitrary code on behalf
of the user. These converters won't be run unless the user gives explicit
authorization, which is asked on-demand when the converter is about to
be run (question is not asked if the file is cached and calling the
converter is not needed).

The user prompt has a 3rd button so that he/she's not prompted again
for (any converter over) the same document (identified through
buffer->absFileName()).

Two preference options are added:

lyxrc.use_converter_needauth_forbidden disables any converter with
the 'needauth' option, which is meant to force user to an explicit
action via the preferences pane, before being able to use advanced
converters that can potentially bring security threats;

lyxrc.use_converter_needauth enables prompting the user for 'needauth'
converters, or bypasses the check if not enabled, falling back to the
previous behavior.

So, the first option is for maximum security, the second is for
maximum usability.
2016-11-22 23:54:58 +01:00
Tommaso Cucinotta
8b5dc3c662 Fix bug in replacement of "$$s/" in converter commands, introduced in 8b66f9ce. 2016-10-24 15:08:06 +02:00
Guillaume Munch
193cda6e48 Remove unused variable warning and remove preprocessor switch. 2016-08-22 00:04:30 +01:00
Enrico Forestieri
f323a64fc3 Adapt code to comment 2016-08-15 03:22:01 +02:00
Enrico Forestieri
7113fb669d Correct comment
According to C++11 rules, static locals are thread safe for
the first-time initialization.

See also:
http://stackoverflow.com/questions/12302057/c11-safe-double-checked-locking-for-lazy-initialization-possible
2016-08-13 17:43:03 +02:00
Enrico Forestieri
41e409f8f7 Use std::call_once only if it is actually available 2016-08-07 04:58:41 +02:00
Guillaume Munch
22d7ba6424 Use call_once to ensure something is only called once
This is thread-safe.
2016-07-31 18:34:33 +01:00
Guillaume Munch
46d8dfc6c2 Make static counters atomic
This ensures thread-safety

(requires: gcc >= 4.6, MSVC >= 2015)
2016-07-31 18:34:33 +01:00
Guillaume Munch
2fd2e65745 C++11 supports thread-safe initialization of statics
A static local variable is guaranteed to be initialized only once, and in time.

Lambda expressions can be used to perform complex initialization of those static
variables on the spot.

(starting from: gcc >= 4.8, msvc >= 2015)
2016-07-31 18:34:33 +01:00
Guillaume Munch
670efa8f64 Rationalise includes
Modifying TexRow.h or texstream.h no longer triggers the recompilation of the
complete source tree.
2016-07-04 02:42:17 +02:00
Guillaume Munch
489dca71cd Simplifications, mainly removal of boost::function and useless std::bind 2016-07-03 01:39:32 +02:00
Georg Baum
2047ea5eb4 Replace Boost.Signals with Boost.Signals2
Boost.Signals is deprecated. This fixes bug #9943.
The only thing left to do is to rewrite (or get rid of) the boost -mt test
in config/lyxinclude.m4 not to use signals anymore.
2016-06-09 22:25:34 +02:00
Guillaume Munch
b032e2dfaf Replace support/shared_ptr.h and boost::shared_ptr with std::shared_ptr
shared_ptrs now only require the <memory> header.
2016-06-09 15:21:39 +01:00
Guillaume Munch
ca8709aaf5 Replace boost::scoped_ptr with unique_ptr 2016-06-09 15:21:39 +01:00
Georg Baum
d2424c6998 Improve debug output
Now we have only one line per format, not two. The output looks the same now
as in GuiApplication.cpp for the qt formats.
2016-06-02 22:17:19 +02:00
Stephan Witt
21e4e939be Revert part of c053a9394d
This change introduced a regression and is not needed anymore.

(cherry picked from commit 1cbabdf8d51b26dd80677ddfeb64d13df91fefc0)
2016-04-25 20:59:25 +02:00
Enrico Forestieri
1c94995aef Fix bug ##9627: Make the document name available to preview insets
The \jobname macro is redefined for the preview snippets such that
it contains the name of the document without extension. This is
harmless because the moment it is redefined, TeX has already chosen
the name of the output and log files. On the other hand, any use
of \jobname in preview snippets is now consistent with what one
obtains after exporting and compiling by hand.
2015-11-04 00:36:41 +01:00
Georg Baum
211ac35314 Work around crash on command line export
This was a regression of 0c093a6264. The crash was found by the tex2lyx
test case test-insets.tex: Running lyx -f main -e pdflatex test-insets.lyx.lyx
did crash. This is not a real fix, but will do for now since previews are not
needed in command line mode (I wonder why they are generated at all?) In the
long term, we need theApp() to return a console application in commandline
mode to eliminate the existing sifferences between export from GUI and
commandline.
2015-09-04 21:24:01 +02:00
Richard Heck
2b8ebe9f0d Comment. 2015-07-22 12:08:20 -04:00
Richard Heck
17a033c15a Fix bug noticed by Pavel. Apparently, some changes Abdel made to preview loading for 2.1.x broke LyXHTML preview of math as images.
We have been here before. The png files are generated, but then by the time we preview the document, they are gone. This is because (a) when the PreviewLoader for a Buffer is deleted, it removes all its previews and (b) we export in a clone, so that Buffer gets deleted before the preview is actually shown. So we need to check whether we are a preview for a clone before we delete anything.
2015-07-22 11:04:35 -04:00
Enrico Forestieri
0c093a6264 Fix bug #9684: Update previews after background color change 2015-07-22 00:56:34 +02:00
Georg Baum
81e592603d Support units in external inset bbox
This brings the external inset on par with the graphics insets as far as the
clipping option is concerned. The graphicxs package supports both: A bounding
box without units (which means that bp ia assumed), and a bounding box with
units, so we can simply output the values including the units.
2015-07-16 22:06:35 +02:00
Enrico Forestieri
cd046f0e0c Avoid an exception when the lyxpreview2bitmap.py script fails completely
If latex fails to generate any output, the forked process was not removed.
Now, if a snippet was changed a new one was started but, if also the zoom was
changed, things went awry because the 2 concurrent processes were asked to
process again the same snippet. Previously this would have simply caused a
waste of resources because the changed snippet would have not been regenerated.
Also reset the guard due to the early exit.
2015-06-23 02:39:48 +02:00
Enrico Forestieri
592219c1f1 Properly reschedule refresh of previews
If the zoom factor is changed right while the previews are being
regenerated, the refreshPreviews() method is a no-op. So, reschedule
the refresh until everything is ready.
2015-06-21 17:21:19 +02:00
Enrico Forestieri
2973108a62 Make really sure to wait for previews after zoom changes
Relying on the fact that the timer is not active anymore does not
guarantee that the previews at the correct zoom are ready because
the regeneration process may take several seconds and during this
time the zoom factor may be changed again. So, we need an additional
guard for assuring that everything has settled down.
2015-06-21 11:21:59 +02:00
Enrico Forestieri
bdec44d614 Revert bc47054b and the related commit ad0d0f6d
As discussed on the devel list. See the subthread starting at
http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg187916.html
Soon to be replaced with the same strategy adopted in the stable branch.
2015-06-14 18:05:39 +02:00
Enrico Forestieri
dd62e0594c Fix building with cmake and Qt4 2015-06-11 00:09:31 +02:00
Kornel Benko
19c7902b53 Cmake build: Adapt to compile after 0213e7b5c6 2015-06-10 21:53:10 +02:00
Enrico Forestieri
0213e7b5c6 Was forgetting to clean up 2015-06-10 20:12:31 +02:00
Enrico Forestieri
21e908b8c4 Delay regeneration of previews on zoom changes
Until now the regeneration process was starting as soon as the zoom scale
factor was changed. This was causing some glitches, especially if the zoom
was changed by the mouse wheel, as on each change the process was started
again and again making zoom changes painful and causing races such that
one could end up with the text at some zoom factor and the previews at
another one. After this commit, the regeneration is started only after
the zoom factor has been stable for about 1 second. In this way, one can
use the mouse wheel for changing back and forth the zoom factor at own's
heart desire without any slow down due to the regeneration process running
in the background. For those using previews with numbered math equations,
a nice possibility for getting the equations correctly numbered in sequence
(after removing or adding an equation) is using the shortcuts Alt+ and Alt-
in rapid sequence (less than a second between the keystrokes). Previously,
this would have triggered twice the regeneration, but now only once.
2015-06-10 19:21:27 +02:00
Stephan Witt
c053a9394d #9130 Text in main work area isn't rendered with high resolution
Improved icon and pixmap handling with SVG images and high physical resolution displays.
This results in much better looking icons and splash banner.
2015-05-19 22:46:26 +02:00
Enrico Forestieri
306b136cc0 Fix bug #4812 (Layout in local directory lost on Save As, Copying)
The "save-as" part of the bug is fixed by extending the \textclass tag
such that, if a local layout file is used, its path relative to the
document directory is now stored together with the name. If a relative
path cannot be used, an absolute one is used but, in this case, the
document is not usable on a different platform.

The "copy" part is fixed by introducing a new \origin tag, which is
written when the file is saved. This tag stores the absolute path of
the document directory. If the document is manually copied to a
different location, the local layout file is retrivied by using
\origin (which is only updated on save).
This new tag may prove useful also for locating other files when the
document is manually moved to a different directory.

As in the original implementation the files needed for the layout
(for example, a latex class) had to be in the same directory as the
layout file, this directory has also to be added to TEXINPUTS.
2015-05-13 22:02:13 +02:00
Juergen Spitzmueller
bc47054be8 Properly fix #6369
Avoid that \newcommand[x] definitions of math macros are pushed multiple
times to the preview loader.

Redefinitions (via \renewcommand[x]) are properly handled.
2015-04-30 16:48:55 +02:00
Enrico Forestieri
eed452077b Preserve numbering of previewed math formulas on zoom
The preview snippets are cached in a seemingly random order, such
that, when regenerating them on zoom, the math previews would be
numbered accordingly. Hence, we have to go through the insets to
get the correct order. This is a bit slower but unavoidable.
2015-04-28 22:06:58 +02:00
Enrico Forestieri
b82e0d6d7f Fix instant preview for documents not specifying a specific output format.
Fixes the regression introduced at 0bb378ba.
2015-04-27 12:30:03 +02:00
Enrico Forestieri
890b9a53cb Fix bug #7850 (Preview of inline math misaligned) 2015-04-26 19:08:16 +02:00
Enrico Forestieri
b8f04ae29a Fix bug #8258 (Zoom of editor doesn't zoom instant preview) 2015-04-21 23:59:09 +02:00
Kornel Benko
0bb378ba6a Adapt creation of preview images to the defaul document output.
Sometimes, even compilable documents could not display preview
snippets. Previously the preview was computed only with help
of latex or xelatex.
This also fixes #9371
2015-04-09 16:29:59 +02:00
Georg Baum
88c274eee7 Let imagemagick detect file format (bug #2332)
Imagemagick detects the inut file format based on contents. Therefore it does
not make sense that we prefix the to be converted file name with the extension
(assuming that the file extension matches the imagemagick format name). This
breaks formats where the extension used by LyX does not match the imagemagick
format name.
2015-03-22 10:22:31 +01:00
Enrico Forestieri
ee6583ff94 Make sure that a generated temporary filename doesn't end with a dot.
This may happen if the extension is empty, and a filename ending with
a dot may give troubles on Windows.
2015-03-13 18:12:08 +01:00
Enrico Forestieri
c057d4e7ee Make sure an unzipped file has correct extension.
If a mask is missing, the TempFile class appends it to the filename.
This may be a problem with applications relying on the extension,
so explicitly add a mask.
2015-03-13 17:28:18 +01:00
Georg Baum
c86f299a50 Encapsulate Converter class
Now members are not directly accessible anymore.
2014-12-07 18:35:28 +01:00
Stephan Witt
f9bff2d9b1 #9130 Text in main work area isn't rendered with high resolution
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.
2014-10-18 15:39:58 +02:00
Stephan Witt
82904d4603 #9130 Text in main work area isn't rendered with high resolution
Add pixel_ratio to graphics params to use it for displays with high resolution.
It holds the ratio between physical pixels and device-independent pixels of the graphics.
2014-10-18 15:26:49 +02:00
Jean-Marc
93a43742a5 Fix a bunch of small performance issues spotted by cppcheck
Most of these are about passing const strings parameters as references.
2014-07-05 19:13:10 +02:00
Georg Baum
b88f6ea3aa Mark some singletons with FIXME THREAD 2014-07-05 15:20:54 +02:00
Georg Baum
5a01424bf0 Make GraphicsConverter threadsafe
build_script() was already threadsafe, since it used a TempFile, and the
counter was basically not needed, but the new solution makes this obvious
and has the additional advantage that TempFile constructs the real output
file, not a dummy without extension which is not needed.
2014-07-05 15:11:24 +02:00
Georg Baum
79e79ed548 Make preview filename generation threadsafe
Threadsafety is ensured by the atomic file name generation in TempFile.
2014-07-05 11:19:34 +02:00
Georg Baum
f09a9fe2e6 Remove unsafe method FileName::tempName()
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().
2014-06-09 13:05:50 +02:00