Bookmark Marker Weirdness

Jean-Marc Lasgouttes lasgouttes at lyx.org
Sun Apr 4 17:54:56 UTC 2021


Le 03/04/2021 à 15:31, Jean-Marc Lasgouttes a écrit :
> Note that a consequence of the visualization is that bookmarks bugs 
> become more obvious. Simple example :
> 
> 1. set a bookmark in a paragraph,
> 2. modify the paragraph,
> 3. undo
> -> the bookmark disappears.
> 
> This is because the paragraph id dies in the operation. A fix is coming 
> soon for this.

At least we have a ticket here https://www.lyx.org/trac/ticket/12235
but I am not sure anymore about the quick fix.

The issue is that, when copying paragraph for the need to undo, the ids 
should be preserved (both when doing recordUndo and when undoing), but 
the Paragraph constructors used by the containers assign new paragraph ids.

The only solution I see is to use a static member of Paragraph that 
tells whether we are in a mode where ids should be preserved or not. 
Then of course there are the thread safety issues which may or may not 
bite us eventually.

The solution I see is to add to the Paragraph::Private declaration 
something like
static thread_local bool preserve_ids = false;
and change it locally in the relevant Undo operations. Does this make 
sense? Does anyone have a better idea?

JMarc



Postface:

But then there is this in Paragraph.cpp:

// OSX clang, gcc < 4.8.0, and msvc < 2015 do not support C++11 thread_local
#if defined(__APPLE__) || (defined(__GNUC__) && __GNUC__ == 4 && 
__GNUC_MINOR__ < 8)
#define THREAD_LOCAL_STATIC static __thread
#elif defined(_MSC_VER) && (_MSC_VER < 1900)
#define THREAD_LOCAL_STATIC static __declspec(thread)
#else
#define THREAD_LOCAL_STATIC thread_local static
#endif


We do not support gcc < 4.9, but what about the other compilers? Can we 
consider now that thread_local exists? For the mac, it seems that it has 
been added to XCode 8. For windows, INSTALL.Win32 says that MSVC 2017 is 
recommended, and then instructs to use version 2019. What is the minimal 
version that we support ?

JMarc



More information about the lyx-devel mailing list