Re: [LyX/master] Fixup c49cd699: QString::toStdString is not always available

2016-12-28 Thread Jürgen Spitzmüller
Am Mittwoch, den 28.12.2016, 22:46 +0100 schrieb Jean-Marc Lasgouttes:
> commit eeb6e8333c5d4207a22a23f09e71b8334bdf7532
> Author: Jean-Marc Lasgouttes 
> Date:   Wed Dec 28 22:44:40 2016 +0100
> 
> Fixup c49cd699: QString::toStdString is not always available
> 
> This method requires STL support in Qt. Fortunately, it is not
> needed
> here.

Ah, thanks. I missed these.

Jürgen

signature.asc
Description: This is a digitally signed message part


Re: [LyX/master] TocWidget: fix an erroneous collapse and optimise updates based on profiling

2016-12-28 Thread Guillaume Munch

Le 27/12/2016 à 23:11, Scott Kostyshak a écrit :

On Tue, May 31, 2016 at 01:15:38AM +0200, Guillaume Munch wrote:

commit 1cc14a31ca8320d881b674f93c34a09cf1666cca
Author: Guillaume Munch 
Date:   Mon May 30 21:42:08 2016 +0100

TocWidget: fix an erroneous collapse and optimise updates based on profiling

TocModels::reset() in GuiView::structureChanged() collapses the TocWidget, 
and
therefore requires an update right after, which was missing.

In fact, profiling TocWidget::updateView() shows that delaying the update is
good only for fast keypresses (essentially movement). It costs 5% of a
char-forward operation in a document with approx. 100 table of contents
items. The update optimisation has been rewritten to take this data into
account.


A git bisect suggests this causes a SIGSEGV. To reproduce:

1. open the attached file
2. open the outline pane
3. put the cursor just to the left of "Hello" (but inside the caption inset)
4. "Save As" to a new filename.

Can you reproduce?

Backtrace is attached.



Hi,

The root of the issue is in Buffer::reload() called during "Save As".
After loadLyXFile() there, all the insets have been deleted, and
therefore the Inset pointer
GuiView::documentBufferView()->cursor().inset() is dangling. Immediately
after loadLyXFile(), reload() calls updateBuffer() from your backtrace
which then crashes.

While debugging I got other segfaults caused by the same dangling Inset
pointer in Cursor, notably: 1) a trace identical to the second one from
, and 2) a repeated segfault in
the critical path (a call to inMathed()) which closes LyX instantly
after the first segfault is caught (luckily after the emergency save is
complete).

I am trying to find a proper fix for this issue, but the strategy for
managing these Inset pointers in CursorSlice escapes me. Does anyone
know which assumptions are made on when these pointers must be valid?
If there are such assumptions, how are they supposed to be enforced?

The attached patch fixes this crash, but I find very unsatisfactory to
have to update the cursors by hand like this.

Guillaume
diff --git a/src/Buffer.cpp b/src/Buffer.cpp
index 3652e7a..e45efd1 100644
--- a/src/Buffer.cpp
+++ b/src/Buffer.cpp
@@ -1044,6 +1044,9 @@ bool Buffer::readDocument(Lexer & lex)
 	bool const res = text().read(lex, errorList, d->inset);
 	d->old_position.clear();
 
+	// Insets have been deleted; update the inset_ cache of Cursors.
+	updateCursors();
+
 	// inform parent buffer about local macros
 	if (parent()) {
 		Buffer const * pbuf = parent();
@@ -3816,6 +3819,13 @@ ErrorList & Buffer::errorList(string const & type) const
 }
 
 
+void Buffer::updateCursors() const
+{
+	if (d->gui_)
+		d->gui_->updateCursors();
+}
+
+
 void Buffer::updateTocItem(std::string const & type,
 	DocIterator const & dit) const
 {
diff --git a/src/Buffer.h b/src/Buffer.h
index 0cb7026..ba68a45 100644
--- a/src/Buffer.h
+++ b/src/Buffer.h
@@ -682,6 +682,8 @@ public:
 	bool lastPreviewError() const;
 
 private:
+	/// This function is called when inset pointers have changed.
+	void updateCursors() const;
 	///
 	ExportStatus doExport(std::string const & target, bool put_in_tempdir,
 		std::string & result_file) const;
diff --git a/src/BufferView.cpp b/src/BufferView.cpp
index d017db0..81b6d46 100644
--- a/src/BufferView.cpp
+++ b/src/BufferView.cpp
@@ -2447,6 +2447,12 @@ int BufferView::workHeight() const
 }
 
 
+void BufferView::updateCursorInsets()
+{
+	cursor().updateInsets(().inset());
+}
+
+
 void BufferView::setCursor(DocIterator const & dit)
 {
 	d->cursor_.reset();
diff --git a/src/BufferView.h b/src/BufferView.h
index ee2de82..f17b57e 100644
--- a/src/BufferView.h
+++ b/src/BufferView.h
@@ -247,6 +247,8 @@ public:
 	Cursor & cursor();
 	/// access to full cursor.
 	Cursor const & cursor() const;
+	/// update the cursor inset cache
+	void updateCursorInsets();
 	/// sets cursor.
 	/// This will also open all relevant collapsable insets.
 	void setCursor(DocIterator const &);
diff --git a/src/frontends/Delegates.h b/src/frontends/Delegates.h
index d13af7e..0f969e6 100644
--- a/src/frontends/Delegates.h
+++ b/src/frontends/Delegates.h
@@ -72,6 +72,8 @@ public:
 	virtual void setBusy(bool) = 0;
 	/// Reset autosave timers for all users.
 	virtual void resetAutosaveTimers() = 0;
+	/// This function is called when inset pointers have changed.
+	virtual void updateCursors() = 0;
 };
 
 } // namespace frontend
diff --git a/src/frontends/qt4/GuiView.cpp b/src/frontends/qt4/GuiView.cpp
index 90b43eb..8bb699a 100644
--- a/src/frontends/qt4/GuiView.cpp
+++ b/src/frontends/qt4/GuiView.cpp
@@ -1661,6 +1661,15 @@ void GuiView::structureChanged()
 }
 
 
+void GuiView::updateCursors()
+{
+	if (documentBufferView())
+		documentBufferView()->updateCursorInsets();
+	if (currentBufferView() && documentBufferView() != currentBufferView())
+		currentBufferView()->updateCursorInsets();
+}
+
+
 void 

Re: License to Publish Work

2016-12-28 Thread Jürgen Spitzmüller
Am Dienstag, den 25.10.2016, 23:52 +0200 schrieb Uwe Stöhr:
> Am 25.10.2016 um 02:10 schrieb Joel Kulesza:
> 
> > I hereby grant the right to publish my work for LyX under the
> > license GPL
> > version 2 or later.
> 
> Many thanks Joel.
> 
> As soon as your first patch goes in for LyX we will add you to the
> LyX 
> credits as an author of LyX.

Which happened just now.

Jürgen

> 
> regards Uwe

signature.asc
Description: This is a digitally signed message part


Re: doc/UserGuide systemF tests failing

2016-12-28 Thread Jürgen Spitzmüller
Am Mittwoch, den 28.12.2016, 11:41 + schrieb Guenter Milde:
> I see. But as the tests should correspond to "normal" LyX behaviour,
> we
> should rather
> 
> a) fix the document: we can set a custom non-tex font that contains
> the
>    missing characters. This way a user just clicking "use non-TeX
> fonts" and
>    compiling will get the correct result.
>    There are no side-effects with the default (TeX-fonts) setting.
>    
>    If there is a free suitable font, this is my preference.

I doubt you will find a free suitable font that is expected to be
installed on every user's box so that "a user just clicking "'use non-
TeX fonts' and compiling will get the correct result."

But, after all, this is not something the UG is designed for (and
neither the CJK quotation marks).

> b) invert the test: as the document is not required to work with non-
> TeX
>    fonts but only reused for tests of all export formats, the failing
> test
>    does not mean there is a problem in LyX and can be ignored.

However, the UG is a quite good test file. It would be a pity to take
it off the set just because the glyphs are missing. Ignoring the
missing glyphs warning strikes me a better alternative.

>    
>    -1 the document can no longer be used to test export with Unicode
> fonts.
>    
>    If there is no suitable Unicode font, this is the correct way.
>    For test with Unicode fonts, we could add a modified copy to the
>    "dedicated test samples folder" autotests/export/latex/.

Then you would need to maintain that copy and update it every time the
UG is updated. I doubt this will work.

Jürgen

>    
> Günter   
> 

signature.asc
Description: This is a digitally signed message part


Re: doc/UserGuide systemF tests failing

2016-12-28 Thread Guenter Milde
On 2016-12-28, Jürgen Spitzmüller wrote:

> [-- Type: text/plain, Encoding: quoted-printable --]

> Am Mittwoch, den 28.12.2016, 05:20 -0500 schrieb Scott Kostyshak:
>> > Note, though, that the missing glyphs message is a warning, not an
>> > error. We treat it as an error in the GUI, for good reasons (since
>> it
>> > severely can impact the output), but it does not stop LaTeX from
>> > processing.

>> I do remember this. But since the default is to treat it as an error,
>> I'm not sure we should treat it differently from any LaTeX error.

> Since it does not point to a LaTeX error, but to the fact that the
> selected font is not suitable for the content. Which is probably not
> something that is of interest for the tests (as opposed to LaTeX
> errors).

I see. But as the tests should correspond to "normal" LyX behaviour, we
should rather

a) fix the document: we can set a custom non-tex font that contains the
   missing characters. This way a user just clicking "use non-TeX fonts" and
   compiling will get the correct result.
   There are no side-effects with the default (TeX-fonts) setting.
   
   If there is a free suitable font, this is my preference.

b) invert the test: as the document is not required to work with non-TeX
   fonts but only reused for tests of all export formats, the failing test
   does not mean there is a problem in LyX and can be ignored.
   
   -1 the document can no longer be used to test export with Unicode fonts.
   
   If there is no suitable Unicode font, this is the correct way.
   For test with Unicode fonts, we could add a modified copy to the
   "dedicated test samples folder" autotests/export/latex/.
   
Günter   



Re: doc/UserGuide systemF tests failing

2016-12-28 Thread Scott Kostyshak
On Wed, Dec 28, 2016 at 11:25:51AM +0100, Jürgen Spitzmüller wrote:
> Am Mittwoch, den 28.12.2016, 05:20 -0500 schrieb Scott Kostyshak:
> > > Note, though, that the missing glyphs message is a warning, not an
> > > error. We treat it as an error in the GUI, for good reasons (since
> > it
> > > severely can impact the output), but it does not stop LaTeX from
> > > processing.
> > 
> > I do remember this. But since the default is to treat it as an error,
> > I'm not sure we should treat it differently from any LaTeX error.
> 
> Since it does not point to a LaTeX error, but to the fact that the
> selected font is not suitable for the content. Which is probably not
> something that is of interest for the tests (as opposed to LaTeX
> errors).

Ah I see what you mean.

Scott


signature.asc
Description: PGP signature


Re: doc/UserGuide systemF tests failing

2016-12-28 Thread Jürgen Spitzmüller
Am Mittwoch, den 28.12.2016, 05:20 -0500 schrieb Scott Kostyshak:
> > Note, though, that the missing glyphs message is a warning, not an
> > error. We treat it as an error in the GUI, for good reasons (since
> it
> > severely can impact the output), but it does not stop LaTeX from
> > processing.
> 
> I do remember this. But since the default is to treat it as an error,
> I'm not sure we should treat it differently from any LaTeX error.

Since it does not point to a LaTeX error, but to the fact that the
selected font is not suitable for the content. Which is probably not
something that is of interest for the tests (as opposed to LaTeX
errors).

Jürgen

signature.asc
Description: This is a digitally signed message part


Re: doc/UserGuide systemF tests failing

2016-12-28 Thread Scott Kostyshak
On Wed, Dec 28, 2016 at 11:13:59AM +0100, Jürgen Spitzmüller wrote:
> Am Mittwoch, den 28.12.2016, 04:27 -0500 schrieb Scott Kostyshak:
> > I know nothing about this so I'll go along with whatever others
> > decide.
> > Günter might have an opinion.
> > 
> > If we do implement the above we might want a general solution for
> > ignoring other errors. I think there might be an enhancement request
> > about this somewhere.
> 
> Note, though, that the missing glyphs message is a warning, not an
> error. We treat it as an error in the GUI, for good reasons (since it
> severely can impact the output), but it does not stop LaTeX from
> processing.

I do remember this. But since the default is to treat it as an error,
I'm not sure we should treat it differently from any LaTeX error.

> I've actually been interested in the opposite: I would like a way to
> > turn warnings into errors. I suppose that only the warnings on the
> > last
> > compilation should be considered (from what I understand, the
> > intermediate compilations often produce expected warnings).
> 
> What do you mean by "errors"? Just make LyX stop processing (that would
> be a bad idea, IMHO) or report the warnings somewhat more loudly?

Report the warnings more loudly.

Scott


signature.asc
Description: PGP signature


Re: doc/UserGuide systemF tests failing

2016-12-28 Thread Jürgen Spitzmüller
Am Mittwoch, den 28.12.2016, 04:27 -0500 schrieb Scott Kostyshak:
> I know nothing about this so I'll go along with whatever others
> decide.
> Günter might have an opinion.
> 
> If we do implement the above we might want a general solution for
> ignoring other errors. I think there might be an enhancement request
> about this somewhere.

Note, though, that the missing glyphs message is a warning, not an
error. We treat it as an error in the GUI, for good reasons (since it
severely can impact the output), but it does not stop LaTeX from
processing.

I've actually been interested in the opposite: I would like a way to
> turn warnings into errors. I suppose that only the warnings on the
> last
> compilation should be considered (from what I understand, the
> intermediate compilations often produce expected warnings).

What do you mean by "errors"? Just make LyX stop processing (that would
be a bad idea, IMHO) or report the warnings somewhat more loudly?

Jürgen

> 
> Scott

signature.asc
Description: This is a digitally signed message part


Re: doc/UserGuide systemF tests failing

2016-12-28 Thread Scott Kostyshak
On Wed, Dec 28, 2016 at 10:38:02AM +0100, Jürgen Spitzmüller wrote:

> Probably not. But there are free alternatives that might suffice:
> https://en.wikipedia.org/wiki/Open-source_Unicode_typefaces

OK thanks.

Scott


signature.asc
Description: PGP signature


Re: doc/UserGuide systemF tests failing

2016-12-28 Thread Jürgen Spitzmüller
Am Mittwoch, den 28.12.2016, 04:09 -0500 schrieb Scott Kostyshak:
> > Note that the
> > CJK quotation marks used in sec. 3.9.3.2 are not covered in some
> fonts.
> > You will probably need a rather comprehensive font (such as Arial
> > Unicode MS).
> 
> I don't have this font. Is it free?

Probably not. But there are free alternatives that might suffice:
https://en.wikipedia.org/wiki/Open-source_Unicode_typefaces

Jürgen

signature.asc
Description: This is a digitally signed message part


Re: doc/UserGuide systemF tests failing

2016-12-28 Thread Scott Kostyshak
On Wed, Dec 28, 2016 at 10:11:16AM +0100, Jürgen Spitzmüller wrote:

> A more general and probably generally useful solution is to add a
> command line option that makes LyX (again) proceed despite the missing
> glyphs warning (and just report the warning). Then the tests could use
> this option.

I know nothing about this so I'll go along with whatever others decide.
Günter might have an opinion.

If we do implement the above we might want a general solution for
ignoring other errors. I think there might be an enhancement request
about this somewhere.

I've actually been interested in the opposite: I would like a way to
turn warnings into errors. I suppose that only the warnings on the last
compilation should be considered (from what I understand, the
intermediate compilations often produce expected warnings).

Scott


signature.asc
Description: PGP signature


Re: doc/UserGuide systemF tests failing

2016-12-28 Thread Jürgen Spitzmüller
Am Mittwoch, den 28.12.2016, 09:58 +0100 schrieb Jürgen Spitzmüller:
> For the sake of the tests, we could just add something like the
> following to the preamble that intentionally ignores these missing
> chars:
> 
> \AtBeginDocument{%
> \usepackage{newunicodechar}
> \newcommand\lyxbypasschar[2]{%
> \newunicodechar{#1}{\iffontchar\font`#1 #1\else{\textbf{ char:
> #2>}}\fi}}
> \lyxbypasschar{「}{0x300c}
> \lyxbypasschar{」}{0x300d}
> \lyxbypasschar{『}{0x300e}
> \lyxbypasschar{』}{0x300f}
> \lyxbypasschar{《}{0x300a}
> \lyxbypasschar{》}{0x300b}
> \lyxbypasschar{〈}{0x3008}
> \lyxbypasschar{〉}{0x3009}
> }
> 
> However, I am reluctant to include it in the UG's preamble just for
> the
> sake of making the tests happy.

A more general and probably generally useful solution is to add a
command line option that makes LyX (again) proceed despite the missing
glyphs warning (and just report the warning). Then the tests could use
this option.

Jürgen

signature.asc
Description: This is a digitally signed message part


Re: doc/UserGuide systemF tests failing

2016-12-28 Thread Scott Kostyshak
On Wed, Dec 28, 2016 at 09:58:08AM +0100, Jürgen Spitzmüller wrote:

> However, I am reluctant to include it in the UG's preamble just for the
> sake of making the tests happy.

I agree.

Scott


signature.asc
Description: PGP signature


Re: doc/UserGuide systemF tests failing

2016-12-28 Thread Scott Kostyshak
On Wed, Dec 28, 2016 at 09:07:45AM +0100, Jürgen Spitzmüller wrote:
> Am Dienstag, den 27.12.2016, 16:02 -0500 schrieb Scott Kostyshak:
> > The following tests on current master are failing:
> > 
> >   export/doc/UserGuide_dvi3_systemF (Failed)
> >   export/doc/UserGuide_pdf4_systemF (Failed)
> >   export/doc/UserGuide_pdf5_systemF (Failed)
> 
> Does "systemF" mean non-TeX fonts?

Yes. See the Development manual for more information.

> If so, is it due to "missing glyphs"
> errors?

Yes.

> And if this is the case, what font are you using?

The tests for English documents use DejaVu.

> Note that the
> CJK quotation marks used in sec. 3.9.3.2 are not covered in some fonts.
> You will probably need a rather comprehensive font (such as Arial
> Unicode MS).

I don't have this font. Is it free?

> Alternatively, we can define a cjk font for fontspec, but
> I don't know which font is supposed to be available everywhere.

No idea.

Scott


signature.asc
Description: PGP signature


Re: doc/UserGuide systemF tests failing

2016-12-28 Thread Jürgen Spitzmüller
Am Mittwoch, den 28.12.2016, 09:07 +0100 schrieb Jürgen Spitzmüller:
> Am Dienstag, den 27.12.2016, 16:02 -0500 schrieb Scott Kostyshak:
> > The following tests on current master are failing:
> > 
> >   export/doc/UserGuide_dvi3_systemF (Failed)
> >   export/doc/UserGuide_pdf4_systemF (Failed)
> >   export/doc/UserGuide_pdf5_systemF (Failed)
> 
> Does "systemF" mean non-TeX fonts? If so, is it due to "missing
> glyphs"
> errors? And if this is the case, what font are you using? Note that
> the
> CJK quotation marks used in sec. 3.9.3.2 are not covered in some
> fonts.
> You will probably need a rather comprehensive font (such as Arial
> Unicode MS). Alternatively, we can define a cjk font for fontspec,
> but
> I don't know which font is supposed to be available everywhere.

For the sake of the tests, we could just add something like the
following to the preamble that intentionally ignores these missing
chars:

\AtBeginDocument{%
\usepackage{newunicodechar}
\newcommand\lyxbypasschar[2]{%
\newunicodechar{#1}{\iffontchar\font`#1 #1\else{\textbf{}}\fi}}
\lyxbypasschar{「}{0x300c}
\lyxbypasschar{」}{0x300d}
\lyxbypasschar{『}{0x300e}
\lyxbypasschar{』}{0x300f}
\lyxbypasschar{《}{0x300a}
\lyxbypasschar{》}{0x300b}
\lyxbypasschar{〈}{0x3008}
\lyxbypasschar{〉}{0x3009}
}

However, I am reluctant to include it in the UG's preamble just for the
sake of making the tests happy.

Jürgen

> 
> Jürgen
> 
> > 
> > Scott

signature.asc
Description: This is a digitally signed message part


Re: doc/UserGuide systemF tests failing

2016-12-28 Thread Jürgen Spitzmüller
Am Dienstag, den 27.12.2016, 16:02 -0500 schrieb Scott Kostyshak:
> The following tests on current master are failing:
> 
>   export/doc/UserGuide_dvi3_systemF (Failed)
>   export/doc/UserGuide_pdf4_systemF (Failed)
>   export/doc/UserGuide_pdf5_systemF (Failed)

Does "systemF" mean non-TeX fonts? If so, is it due to "missing glyphs"
errors? And if this is the case, what font are you using? Note that the
CJK quotation marks used in sec. 3.9.3.2 are not covered in some fonts.
You will probably need a rather comprehensive font (such as Arial
Unicode MS). Alternatively, we can define a cjk font for fontspec, but
I don't know which font is supposed to be available everywhere.

Jürgen

> 
> Scott

signature.asc
Description: This is a digitally signed message part