Le 06/08/2015 22:44, Jean-Marc Lasgouttes a écrit :
Le 5 août 2015 03:18:37 UTC+02:00, Guillaume Munch <ga...@free.fr> a écrit :
Hello,


Here is a patch that I would like to discuss. It brings some
improvements to the source view panel and it fixes
<http://www.lyx.org/trac/ticket/6501> (Cursor in "LaTeX Source" pane
does not follow cursor in Editor window).

I use a unique_ptr because it was the best way to do. Because of this,
the patch has to be compiled with CXXFLAGS="-std=c++11". Fortunately it

was easy to fix the LyX source to have a compilation with c++11.

Is there a reason for not using c++11? I don't mind rewriting the patch

in such a way that it works in the current environment. Just tell me
what you prefer instead. (auto_ptr is too limited here and I don't want

to put a raw pointer in the interface. shared_ptr would certainly work
but on the other hand I don't see why we would forbid ourselves from
using c++11 features.) Anyway it would be good to fix the source code
for c++11 compilation even if we don't make c++11 mandatory.


As for the improvements themselves, please have a look at the
description of the patch below if you would like to test the new
features. Note that the patch is independant of my earlier patch adding

QTimers.

Also is there an expert of TexRow? I am thinking of a further
improvement along the lines of
<http://www.lyx.org/trac/ticket/4725#comment:1> (ability to view source

of only the current selection) which seems quite simple to do at least
partially.


Guillaume

Hello Guillaume,

I am in vacation currently and cannot really look at the patch.

However the c++11 problem is separate and should be treated as such.

The current situation is

* c++11 is supported in 2.1 and 2.2, and it will be required in 2.3. Requiring 
it is not completely neutral since for example Mac OS 10.7 does not support it 
natively (this is what I have on the desk at home).

* for 2.2, we should enable c++11 by default for all compiler that supports it. 
I can do the autoconf part of this plan. This should fix your problems with 
next() (is that with clang?).

* for 2.2 again, we should provide an alternative implementation of unique_ptr 
to replace all our uses of auto_ptr. I do not know what is the best solution, 
maybe from boost or à typedef from auto_ptr.

If you feel like providing unique_ptr (or something good enough) for c++98, 
that would be welcome.

I see the situation. You seem to have a clear idea of what you want to do.

For backporting my code to 2.1, I can avoid the use of unique_ptr but for master it is better to only commit good code.

For 2.2: there is a unique_ptr in Boost <http://www.boost.org/doc/libs/1_58_0/doc/html/move.html>, see the remarks about using it for forward-compatibility purposes. The main caveat seems to be the following:

"Important: To be able to use containers of movable-only values you will need to use containers supporting move semantics, like Boost.Container containers"

For instance, in my code I return the unique_ptr in a pair and thus we would need to also define a forward-compatible implementation of pairs...

I doubt that you will have anything better --- unique_ptr is really made possible by the features of c++11.

If Mac OS 10.6 is the blocker... what about <http://stackoverflow.com/a/14494515>, or other workarounds? (No pressure, just to know.)


Concerning your compilation problems, aren't they fixed by --enable-cxx11 (or 
the equivalent invocation) ?


I see that --enable-cxx11 passes std=gnu++11 while I was passing std=c++11. (I overlooked the option, because it was not mentioned in the INSTALL file...) Yes, this fixes the issue with next(). However, I still had to move Q_DECL_OVERRIDE to the header file in GuiApplication.cpp. The relevant commit was related to qt5. So, I appear to be the first who compiles with both qt5 and c++11... Patch attached.

I hereby grant permission to license my contributions to LyX under the Gnu General Public Licence (version two or later), etc.

>From 6fec9b191f286bf7df62ccc993f302fd7a61cb18 Mon Sep 17 00:00:00 2001
From: gadmm <ga...@free.fr>
Date: Fri, 7 Aug 2015 00:06:09 +0100
Subject: [PATCH] Fix compilation with qt5 and c++11 combined.

---
 src/frontends/qt4/GuiApplication.cpp | 2 +-
 src/frontends/qt4/GuiApplication.h   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/frontends/qt4/GuiApplication.cpp b/src/frontends/qt4/GuiApplication.cpp
index fe34509..7671d59 100644
--- a/src/frontends/qt4/GuiApplication.cpp
+++ b/src/frontends/qt4/GuiApplication.cpp
@@ -3085,7 +3085,7 @@ bool GuiApplication::x11EventFilter(XEvent * xev)
 }
 #elif defined(QPA_XCB)
 bool GuiApplication::nativeEventFilter(const QByteArray & eventType,
-				       void * message, long *) Q_DECL_OVERRIDE
+				       void * message, long *)
 {
 	if (!current_view_ || eventType != "xcb_generic_event_t")
 		return false;
diff --git a/src/frontends/qt4/GuiApplication.h b/src/frontends/qt4/GuiApplication.h
index 344a862..82f5898 100644
--- a/src/frontends/qt4/GuiApplication.h
+++ b/src/frontends/qt4/GuiApplication.h
@@ -108,7 +108,7 @@ public:
 #ifdef Q_WS_X11
 	bool x11EventFilter(XEvent * ev);
 #elif defined(QPA_XCB)
-	virtual bool nativeEventFilter(const QByteArray & eventType, void * message, long * result);
+	virtual bool nativeEventFilter(const QByteArray & eventType, void * message, long * result) Q_DECL_OVERRIDE;
 #endif
 	//@}
 
-- 
2.1.4

Reply via email to