Commit Graph

1776 Commits

Author SHA1 Message Date
Georg Baum
0de4bc224a Make DocFileName::mangledFileName() threadsafe 2014-07-05 12:22:08 +02:00
Georg Baum
c9c20dc23b Make IconvProcessor::Impl noncopyable
The compiler-generated copy-constructor and assigment operators would be wrong
for IconvProcessor::Impl, since cd would be copied, and iconv_close() could
thus be called twice on the same descriptor. The old code did work, but now
IconvProcessor::Impl cannot be copied by accident in the future.
2014-07-01 22:23:06 +02:00
Georg Baum
0e8fea0705 Fix memory leak and assignment operator signature
The IconvProcessor assignment operator did not delete pimpl_ and used a
non-standard signature. If you want to know why the standard signature is
important, read "Effective C++" by Scott Meyers.
2014-07-01 22:17:07 +02:00
Peter Kümmel
2f17858115 On Linux show in crash message box the backtrace 2014-06-14 11:25:25 +02:00
Kornel Benko
3b14de740d Cmake build: Symplify use of linking optional libraries found via find_package 2014-06-12 19:02:29 +02:00
Kornel Benko
2b0511510a Cmake build: Added magic library to some link commands.
Needed due to the use of magic_(open|load|error|file|close) after recent changes.
2014-06-12 07:49:17 +02:00
Enrico Forestieri
f439609304 Make binary file detection more robust.
The magic library can detect the charset used by a file. While this
detection is not full proof, actually the library seems to be infallible
as regards the binary nature of a file. So, use libmagic for the detection
and fallback to the previous method if the library is not installed or
its database cannot be loaded.
2014-06-11 23:04:39 +02:00
Enrico Forestieri
82faa66192 Set the default locale at startup.
On startup, the default locale is "C", meaning that all system
functions assume an ascii codeset. The environment's locale
settings should be selected by calling setlocale(LC_ALL,"").
This is done by Qt during the QCoreApplication initialization
but this inizialization is never performed for batch processing
and, as a result, LyX is not able to process files whose names
contain non-ascii characters. This is not an issue on Windows,
where the file names are always stored as UTF-16, so the call is
only performed for unix-like platforms (this also includes cygwin,
due to its own filenames management that allows using characters
which are forbidden to native programs).
2014-06-11 18:23:44 +02:00
Georg Baum
f76d6997b7 Fix thinko in loop detection 2014-06-09 22:06:58 +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
Georg Baum
ae15b59734 Don't double delete by making TempFile noncopyable
The compiler generated copy constructor and assignment operator are wrong.
This could easily be fixed by implementing them manually, but a) they are
not needed, and b) the semantics would be unclear (should the copy point
to a new temp file or not?), so it is better to forbid them.
2014-06-09 13:03:32 +02:00
Georg Baum
bf782ee02a Improve file saving strategy
- 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).
2014-06-09 11:08:24 +02:00
Georg Baum
47721216f0 Fix typo 2014-06-09 10:26:39 +02:00
Enrico Forestieri
7d31194085 Fix bug #9146.
If LyX does not know about a given file format, it may easily
happen that the format is recognized as "latex" and this causes
bug #9146. This patch limits the check for a latex format to
non-binary files. The strategy for deciding that a file has
binary content is the same as that adopted by the "less" program.
2014-06-05 17:33:25 +02:00
Scott Kostyshak
fc19148f6d Fix a GCC warning: comparing signed vs. unsigned
This also changes the type of an int to an ssize_t.

nRead is initialized as an ssize_t because it could
be negative. It is cast to a size_t for comparison
to the size of a vector, but only after we check
that nRead is not negative.
2014-05-20 08:01:49 -04:00
Enrico Forestieri
480f8d3115 Fix compilation after afc34c7a 2014-05-20 00:43:46 +02:00
Georg Baum
afc34c7a60 Fix bug 9030 except for windows
The format entries should be sorted according to the culture selected for the
UI. This was not the case previously, resulting in unexpected sorting of small
and capital letters. This is now fixed by using the standard C function
strcoll(). Qt does only offer similar functionality in Qt5, and this is not
mature enough yet to depend on it.
Unfortunately we have a report that strcoll() does not work on MSVC, however
this partial fix is better than nothing. The MSVC issue might also be a
configuration problem, since MS claims that strcoll() is supported. This
still needs to be checked.
2014-05-19 22:37:14 +02:00
Enrico Forestieri
ee9ff6cb0c Extend the otexstream class to also report about paragraph breaks.
The new method afterParbreak() returns true if a blank line was just
output and we are at the beginning of the next line, false otherwise.
2014-05-18 22:46:33 +02:00
Scott Kostyshak
1821c6d8a3 Centralize substitution of python commands
The code for detecting python commands and substituting in the
correct prefix is now merged with what used to be libScriptSearch()
and is now renamed to commandPrep(). This commit does not change
any functionality and just improves organization to reduce the
chance of bugs in the future.
2014-05-14 15:45:20 -04:00
Scott Kostyshak
8b66f9cedf Centralize replacement of "$$s"
Now the replacement is done in startScript(). In addition to making
the code cleaner and more consistent, this commit fixes a bug where
"$$s" was not replaced when "latex=" was specified in the extra flags
of a converter.

Note that the temporary fix at 731b8610 is reverted with this commit.
2014-05-14 15:45:20 -04:00
Jean-Marc Lasgouttes
ac9a2fa9f8 Turn an error message into a Debug::LOCALE warning 2014-05-06 14:29:42 +02:00
Stephan Witt
36e5864a82 improve language flag for Objective-C compiler call 2014-04-30 23:14:41 +02:00
Georg Baum
351363c599 Fix C++11 test
Thanks Vincent for noticing. The old test was slightly off, the C++98 standard
guarantees that __cplusplus is defined as 199711L, not 19971L.
2014-04-29 21:00:02 +02:00
Vincent van Ravesteijn
b6ccf21192 cmake: Objective-C compilation support with clang and C++11
This fixes an issue when compiling with C++11 flags on: the
objective-C clang compiler produces an error. This patch set
the -std option to ansi for the Objective-C sources.
2014-04-22 09:41:25 +02:00
Benjamin Piwowarski
d863088986 Revert "Objective-C compililation support with cmake and C++11"
This reverts commit c2e67a41ce.
2014-04-22 09:36:17 +02:00
Richard Heck
065db68067 Fix a bunch of minor issues discovered by the cppcheck script. 2014-04-21 11:52:00 -04:00
Richard Heck
cd32001de6 Typo. 2014-04-21 11:51:59 -04:00
Benjamin Piwowarski
73405549cb Avoids const_cast in configure_command by using mutable 2014-04-21 11:51:57 -04:00
Richard Heck
fdbe775b9f This is the result of an audit of all static variables, looking
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.
2014-04-21 11:51:57 -04:00
Benjamin Piwowarski
4e38cf1524 Fix problem with python and change of PATH
- waits that lyxrc has been read before finding python
- when the PATH changes, resets the value
2014-04-21 11:51:28 -04:00
Benjamin Piwowarski
2da0d32771 CMake: specific modules for Qt5 2014-04-21 11:51:04 -04:00
Benjamin Piwowarski
c2e67a41ce Objective-C compililation support with cmake and C++11
This fixes an issue whe compiling with C++11 flags on: The
objective-C clang compiler produces an error. This patch waits
avoid including specific C++ flags and uses LYX_CPP_SPECIFIC_FLAGS
to store the confliciting flags (for the moment, just C++11).
2014-04-21 11:51:04 -04:00
Stephan Witt
024e1175dc Apple recommends the use of drain instead of calling release for NSAutoreleasePool objects 2014-04-19 18:27:14 +02:00
Benjamin Piwowarski
ac8b77fc03 Fix problem with python and change of PATH
- waits that lyxrc has been read before finding python
- when the PATH changes, resets the value
2014-03-29 22:19:03 +01:00
Pavel Sanda
0f8a2d2860 Squash gcc warning.
http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg183142.html
2014-03-27 01:12:26 -07:00
Vincent van Ravesteijn
3c67d6f77c Add a comment for the special code on Windows 2014-03-19 21:07:43 +01:00
Vincent van Ravesteijn
d44b465efa Do not use QProcess::startDetached on Windows
QProcess::startDetached cannot provide environment variables. When the
environment variables are set using the latexEnvCmdPrefix, a console
window is shown every time a viewer is started.

On Windows, this reverts commit 5225821242.

Fixes: #9035.
2014-03-19 08:29:38 +01:00
Georg Baum
f7e06dbf16 Fix wrong comment (thanks Enrico) 2014-03-13 21:02:41 +01:00
Georg Baum
362630fba1 Add comments about putenv() usage
Again thanks to Enrico.
2014-03-10 20:59:03 +01:00
Benjamin Piwowarski
908c92e831 Updates to AppleScript support, and documentaoin for it. 2014-03-05 15:46:27 -05:00
Georg Baum
07afd76b7c Fix compilation with libc++
libc++ (http://libcxx.llvm.org/) is used on OS X with newer XCode.
The patch is from Benjamin Piwowarski <benjamin.piwowarski@lip6.fr>, I only
added more comments.
The changes regarding implicit conversion to bool of std::iostream work
because both the C++98 and C++11 standards guarantee that boolean evaluation
of streams returns !fail(). See e.g.
http://stackoverflow.com/questions/1334858/why-dont-iostream-objects-overload-operator-bool
for details.
2014-03-04 23:27:57 +01:00
Richard Heck
7b46aa8fbb Forgot in previous commit to deal with case. As I'm doing it now,
it's easy to use the existing docstring routine, so I've commented
out the string version of lowercase I had introduced. I've left the
code in case someone else needs it later.
2014-02-23 12:04:56 -05:00
Richard Heck
e5ea535952 If the selection is some sort of URL, then make it the target, not
the name, in the hyperlink. Fixes bug #8792.

This also fixes a bug discovered while working on this code: The
params passed to GuiHyperlink were never used.
2014-02-23 11:36:54 -05:00
Stephan Witt
cfe9724a4c add -fobjc-exceptions for compiling linkback sources with g++ and cmake on Mac
Original patch is from Ramanathan Vishnampet
2014-02-19 16:11:03 +01:00
Kornel Benko
5efd59733a Remove warning 2014-01-05 10:04:23 +01:00
Kornel Benko
805e51eff8 Implement file locking and apply to configure
Functions for file locking are added. They are used for ensuring that
for specified userdir only one LyX process runs configure.
2013-11-20 19:40:32 +01:00
Enrico Forestieri
45a6a9362c Ditch the quote_python flag.
This was discussed on the list some months ago:
http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg179563.html
2013-10-13 23:57:33 +02:00
Jean-Marc Lasgouttes
50af06c29b Implement reading of mo files with bad byte endianness 2013-10-11 17:21:16 +02:00
Georg Baum
6a30211fef Make encoding conversions thread safe
This is the result of the discussion on the list "2.1.0 Blocker". Thanks to
all contributors!
The main idea is to use thread-local storage for all static variables.
This solution does not need any mutex. For more details, see the comment in
unicode.h.
2013-10-10 21:20:44 +02:00
Georg Baum
3e83380350 Remove questionable Mutex copy code
It is no longer needed, and it had a comment that it needed review...
Now anybody who tries to make a copy again is forced to think about it,
instead of trying and using possibly wrong semantics by accident.
2013-10-08 22:06:55 +02:00