Il 02/05/2011 20:44, Richard Heck ha scritto:
On 05/02/2011 02:11 PM, Richard Heck wrote:

Backtrace:

0    lyx::checkAndLoadLyXFile    buffer_funcs.cpp    109    0x4f9a3d
1    lyx::Buffer::readDocument    Buffer.cpp    792    0x4c1e3b
2    lyx::Buffer::readString    Buffer.cpp    861    0x4c3f83
3    lyx::findAdvReplace    lyxfind.cpp    1299    0x819af5
4    lyx::findAdv    lyxfind.cpp    1359    0x81cfaa
5    lyx::BufferView::dispatch    BufferView.cpp    1544    0x769179

At (3), we are doing:
       LASSERT(repl_buffer.readString(lyx), /**/);
and the problem here is that the lyx string is:

Thanks for the diagnosis.
The problem turns out to be simple. In ApplyParams(), in
FindAndReplace.cpp, we apply the document params to the find and replace
buffers.

the sole reason we do that, is that we need to copy the language settings of the main document, in order to avoid that what we search & replace is detected as with the wrong language, w.r.t. what is typed within (there was a trac entry about that problem, too).

Alternative solutions that were proposed included disabling at all the language highlighting and spellchecker in the F&R workareas (but after all I find them useful, i.e., when I search for something, the spellchecker can highlight that I typed a "typo", so it wouldn't be found, or it would be replaced causing problems etc.), but in the end I had found that "ugly" way of solving the issue in FindAndReplace.cpp:

/// Apply to buf the parameters supplied through bp
static void ApplyParams(Buffer &buf, BufferParams const & bp) {
    ostringstream ss;
    ss << "\\begin_header\n";
    bp.writeFile(ss);
    ss << "\\end_header\n";
    istringstream iss(ss.str());
    Lexer lex;
    lex.setStream(iss);
    int unknown_tokens = buf.readHeader(lex);
    LASSERT(unknown_tokens == 0, /* */);
}

Probably we would need a BufferParams::setLanguage() method to use, here, instead of copying the whole parameters. Looking at BufferParams::readLanguage(), I would implement it as:

bool BufferParams::setLanguage(std::string const &lang)
{
    Language const *new_language = languages.getLanguage(lang);
    if (!new_language) {
        // Language lang was not found
        return false;
    }
    language = new_language;
    return true;
}

Would you like such a solution ?

    T.

Reply via email to