http://bugzilla.lyx.org/show_bug.cgi?id=4055

The attached patch (4055.diff) fixes one part of this crash. However, LyX 
still asserts when "rtl support" is checked in Preferences->Languages (i.e. 
in the default settings). I suspect the bidi tables are not correctly 
updated, but I don't understand the bidi thing, so someone else will need to 
have a look.

If we don't find an easy fix for the bidi issue, 4055-alt.diff has an 
alternative fix that cures the crash, but isn't really the behaviour the user 
would expect (the selection is reset, not replaced by the math symbol). 
Better than a crash, though.

Testcase (with 4055.diff applied):

- C-N
- type "test"
- select this word
- M-x math-insert \alpha

Assertion triggered in const lyx::Font lyx::Paragraph::getFontSettings(const 
lyx::BufferParams&, lyx::pos_type) const by failing check "pos <= size()" in 
file Paragraph.cpp:1317
LyX: Attempting to save document newfile1.lyx
 /home/juergen/newfile1.lyx.emergency
  Save seems successful. Phew.

Program received signal SIGABRT, Aborted.
[Switching to Thread 47163412974192 (LWP 11121)]
0x00002ae51648c535 in raise () from /lib64/libc.so.6
(gdb) bt
#0  0x00002ae51648c535 in raise () from /lib64/libc.so.6
#1  0x00002ae51648d990 in abort () from /lib64/libc.so.6
#2  0x0000000000970945 in lyx::support::abort () at abort.cpp:25
#3  0x00000000004316b7 in boost::assertion_failed (expr=0xa1030a "pos <= 
size()",
    function=0xa10d20 "const lyx::Font lyx::Paragraph::getFontSettings(const 
lyx::BufferParams&, lyx::pos_type) const", file=0xa8224c "Paragraph.cpp", 
line=1317) at boost.cpp:56
#4  0x00000000005a9a09 in lyx::Paragraph::getFontSettings (this=0x1477490, 
[EMAIL PROTECTED], pos=2)
    at Paragraph.cpp:1317
#5  0x0000000000430f65 in lyx::Bidi::computeTables (this=0x7fff9910e7c0, 
[EMAIL PROTECTED], buf=<value optimized out>,
    [EMAIL PROTECTED]) at Bidi.cpp:111
#6  0x00000000005ce1e7 in lyx::Text::cursorX (this=0x1476c78, [EMAIL 
PROTECTED], 
[EMAIL PROTECTED],
    boundary=<value optimized out>) at Text.cpp:1711
#7  0x000000000048d2f8 in lyx::bv_funcs::coordOffset ([EMAIL PROTECTED], 
[EMAIL PROTECTED], boundary=false)
    at bufferview_funcs.cpp:214
#8  0x000000000048d47c in lyx::bv_funcs::getPos ([EMAIL PROTECTED], 
[EMAIL PROTECTED], boundary=6)
    at bufferview_funcs.cpp:242
#9  0x00000000004b51e4 in lyx::Cursor::getPos (this=0x10d4990, [EMAIL 
PROTECTED], 
[EMAIL PROTECTED]) at Cursor.cpp:421
#10 0x00000000004bacb3 in lyx::Cursor::dispatch (this=0x10d4990, 
[EMAIL PROTECTED]) at Cursor.cpp:304
#11 0x00000000005e8906 in lyx::Text::dispatch (this=0x1476c78, 
cur=dwarf2_read_address: Corrupted DWARF expression.
) at Text3.cpp:1347
#12 0x000000000076bf3f in lyx::InsetText::doDispatch (this=0x1476c48, 
[EMAIL PROTECTED], [EMAIL PROTECTED])
    at InsetText.cpp:270
#13 0x00000000006a12a6 in lyx::Inset::dispatch (this=0x1476c48, 
[EMAIL PROTECTED], [EMAIL PROTECTED]) at Inset.cpp:145
#14 0x00000000004badec in lyx::Cursor::dispatch (this=0x10d4990, 
[EMAIL PROTECTED]) at Cursor.cpp:318
---Type <return> to continue, or q <return> to quit---
#15 0x000000000056daef in lyx::LyXFunc::dispatch (this=0xe4cbd0, 
[EMAIL PROTECTED]) at LyXFunc.cpp:1808
#16 0x000000000053e194 in lyx::dispatch ([EMAIL PROTECTED]) at 
LyX.cpp:1478
#17 0x0000000000794002 in lyx::LyXView::dispatch (this=0xf6c968, 
[EMAIL PROTECTED]) at LyXView.cpp:513
#18 0x0000000000913aa1 in lyx::frontend::ControlCommandBuffer::dispatch 
(this=0xf26600, [EMAIL PROTECTED])
    at ControlCommandBuffer.cpp:142
#19 0x000000000080de4e in lyx::frontend::QCommandBuffer::dispatch 
(this=0xf7eec0) at QCommandBuffer.cpp:134
#20 0x000000000081003f in lyx::frontend::QCommandBuffer::qt_metacall 
(this=0xf7eec0,
    _c=QMetaObject::InvokeMetaMethod, _id=0, _a=0x7fff991117e0) at 
QCommandBuffer_moc.cpp:74
#21 0x00002ae513d1dbcb in QMetaObject::activate (sender=0xfac1f0, 
from_signal_index=30, to_signal_index=30,
    argv=0xffffffffffffffff) at kernel/qobject.cpp:2940
#22 0x00002ae511fc6146 in QLineEdit::keyPressEvent (this=0xfac1f0, 
event=0x7fff99111ee0)
    at widgets/qlineedit.cpp:1741
#23 0x00000000008104ae in lyx::frontend::QCommandEdit::keyPressEvent 
(this=0xfac1f0, e=0x7fff99111ee0)
    at QCommandEdit.cpp:55
#24 0x00002ae511d62878 in QWidget::event (this=0xfac1f0, event=0x7fff99111ee0) 
at kernel/qwidget.cpp:5753
#25 0x00002ae511fc509e in QLineEdit::event (this=0xfac1f0, e=0x7fff99111ee0) 
at widgets/qlineedit.cpp:1516
#26 0x00000000008104e5 in lyx::frontend::QCommandEdit::event (this=0x2b71, 
e=0x2b71) at QCommandEdit.cpp:69
#27 0x00002ae511d1dbbc in QApplicationPrivate::notify_helper (this=0xe50cb0, 
receiver=0xfac1f0, e=0x7fff99111ee0)
    at kernel/qapplication.cpp:3439
#28 0x00002ae511d206db in QApplication::notify (this=<value optimized out>, 
receiver=0xfac1f0, e=0x7fff99111ee0)
    at kernel/qapplication.cpp:3067
#29 0x00000000007df6c8 in lyx::frontend::GuiApplication::notify (this=0x2b71, 
receiver=0x2b71, event=0x6)
    at GuiApplication.cpp:237
---Type <return> to continue, or q <return> to quit---
#30 0x00002ae511d674fd in qt_sendSpontaneousEvent 
(receiver=0xffffffffffffffff, event=0x6)
    at ../../include/QtCore/../../src/corelib/kernel/qcoreapplication.h:186
#31 0x00002ae511d8f94d in QKeyMapper::sendKeyEvent (keyWidget=0xfac1f0, 
grab=<value optimized out>,
    type=QEvent::KeyPress, code=16777220, [EMAIL PROTECTED], 
[EMAIL PROTECTED],
    autorepeat=<value optimized out>, count=1, nativeScanCode=36, 
nativeVirtualKey=65293, nativeModifiers=16)
    at kernel/qkeymapper_x11.cpp:1580
#32 0x00002ae511d91889 in QKeyMapperPrivate::translateKeyEvent (this=0xe8c740, 
keyWidget=0xfac1f0,
    event=0x7fff99112750, grab=113) at kernel/qkeymapper_x11.cpp:1560
#33 0x00002ae511d711e7 in QApplication::x11ProcessEvent (this=0xe524a0, 
event=0x7fff99112750)
    at kernel/qapplication_x11.cpp:2782
#34 0x00002ae511d92ca5 in x11EventSourceDispatch (s=0xe5a460, callback=0, 
user_data=0x0)
    at kernel/qguieventdispatcher_glib.cpp:122
#35 0x00002ae5141e4f94 in g_main_context_dispatch () 
from /opt/gnome/lib64/libglib-2.0.so.0
#36 0x00002ae5141e7dc5 in g_main_context_prepare () 
from /opt/gnome/lib64/libglib-2.0.so.0
#37 0x00002ae5141e82ee in g_main_context_iteration () 
from /opt/gnome/lib64/libglib-2.0.so.0
#38 0x00002ae513d2e430 in QEventDispatcherGlib::processEvents (this=0xe56980, 
flags=<value optimized out>)
    at kernel/qeventdispatcher_glib.cpp:366
#39 0x00002ae511d92abf in QGuiEventDispatcherGlib::processEvents (this=0x2b71, 
flags=<value optimized out>)
    at kernel/qguieventdispatcher_glib.cpp:178
#40 0x00002ae513d0cda8 in QEventLoop::processEvents (this=<value optimized 
out>, flags=<value optimized out>)
    at kernel/qeventloop.cpp:126
#41 0x00002ae513d0ceb9 in QEventLoop::exec (this=0x7fff99112ad0, 
[EMAIL PROTECTED]) at kernel/qeventloop.cpp:172
#42 0x00002ae513d0f080 in QCoreApplication::exec () at 
kernel/qcoreapplication.cpp:730
---Type <return> to continue, or q <return> to quit---
#43 0x00000000007df639 in lyx::frontend::GuiApplication::exec (this=<value 
optimized out>) at GuiApplication.cpp:158
#44 0x000000000054eb40 in lyx::LyX::exec (this=0x7fff99112c00, argc=<value 
optimized out>,
    argv=<value optimized out>) at LyX.cpp:478
#45 0x0000000000428caf in main (argc=1, argv=0x7fff99112d18) at main.cpp:48


Jürgen
Index: src/Text3.cpp
===================================================================
--- src/Text3.cpp	(Revision 19175)
+++ src/Text3.cpp	(Arbeitskopie)
@@ -1340,6 +1340,7 @@
 	case LFUN_MATH_MATRIX:
 	case LFUN_MATH_DELIM:
 	case LFUN_MATH_BIGDELIM: {
+		cap::replaceSelection(cur);
 		cur.insert(new InsetMathHull(hullSimple));
 		checkAndActivateInset(cur, true);
 		BOOST_ASSERT(cur.inMathed());
Index: src/Text3.cpp
===================================================================
--- src/Text3.cpp	(Revision 19175)
+++ src/Text3.cpp	(Arbeitskopie)
@@ -1340,6 +1340,8 @@
 	case LFUN_MATH_MATRIX:
 	case LFUN_MATH_DELIM:
 	case LFUN_MATH_BIGDELIM: {
+		if (cur.selection())
+			cur.clearSelection();
 		cur.insert(new InsetMathHull(hullSimple));
 		checkAndActivateInset(cur, true);
 		BOOST_ASSERT(cur.inMathed());

Reply via email to