On 02/05/2017 11:19, Kornel Benko wrote:
Start lyx select new file type anything e.g. 'abcd' Goto home position in minibuffer type word-findadv a<Return> Any (or no at all) parameter to this function leads to crash. This is independent of active search dialog.
(would be great to have an autotest for this :-) ) the attached patch fixes the crash for me, can you please check ? Can we commit to master now ?
For comparision, the function 'word-find' does not crash, but doesn't find anything either.
these LFUNs use a special syntax to be provided, encoding the set of available search options as a string; the regular word-find can be hand-made, but the one needed by the word-findadv() requires a multi-line options string including the name of the search and replace internal buffers within theBuffers(), which are generally things internal to LyX and not exposed to the user... ... if we'd like to have a "word-findadv a" command to find "a" with default options, that can be achieved by tweaking the istringstream & operator>>(istringstream & is, FindAndReplaceOptions & opt) function in lyxfind.cpp. Can't remember why this is done this way (passing the names of these 2 buffers), probably at that time I couldn't find a better/simpler way to find those 2 special buffers from the lyxfind.cpp context :-(! T.
>From f2819a9daf5014434f2b39636268cad8455e0bd9 Mon Sep 17 00:00:00 2001 From: Tommaso Cucinotta <tomm...@lyx.org> Date: Tue, 2 May 2017 17:46:38 +0200 Subject: [PATCH] findadv: fix crash on wrong syntax/usage of word-findadv LFUN from mini-command. --- src/lyxfind.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/lyxfind.cpp b/src/lyxfind.cpp index c743fb81..d789c012 100644 --- a/src/lyxfind.cpp +++ b/src/lyxfind.cpp @@ -1512,6 +1512,11 @@ bool findAdv(BufferView * bv, FindAndReplaceOptions const & opt) DocIterator cur; int match_len = 0; + // e.g., when invoking word-findadv from mini-buffer wither with + // wrong options syntax or before ever opening advanced F&R pane + if (theBufferList().getBuffer(FileName(to_utf8(opt.find_buf_name))) == 0) + return false; + try { MatchStringAdv matchAdv(bv->buffer(), opt); int length = bv->cursor().selectionEnd().pos() - bv->cursor().selectionBegin().pos(); -- 2.9.3