Bug 200858 - Folding crash when cursor moved in collapsed block [KateLineLayout::viewLineCount, KateLineLayout::viewLine, KateLayoutCache::textLayout]
Summary: Folding crash when cursor moved in collapsed block [KateLineLayout::viewLineC...
Alias: None
Product: kate
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Fedora RPMs Linux
: NOR crash
Target Milestone: ---
Assignee: KWrite Developers
: 164772 211384 213328 233432 235799 (view as bug list)
Depends on:
Reported: 2009-07-20 13:28 UTC by Michal Hlavinka
Modified: 2013-04-16 13:29 UTC (History)
6 users (show)

See Also:
Latest Commit:
Version Fixed In:

reproducer file (246 bytes, text/plain)
2009-07-20 13:29 UTC, Michal Hlavinka
backtrace and backtrace full (30.66 KB, text/plain)
2009-07-20 13:29 UTC, Michal Hlavinka

Note You need to log in before you can comment on or make changes to this bug.
Description Michal Hlavinka 2009-07-20 13:28:18 UTC
Version:           4.2.96 (using KDE 4.2.96)
OS:                Linux
Installed from:    Fedora RPMs

steps to reproduce:
1)open attached file crashme.js
2)put cursor on marked line
3)press ctrl+shift+minus
4)press up key

actual result:

expected result:
cursor moved up
Comment 1 Michal Hlavinka 2009-07-20 13:29:06 UTC
Created attachment 35479 [details]
reproducer file
Comment 2 Michal Hlavinka 2009-07-20 13:29:50 UTC
Created attachment 35480 [details]
backtrace and backtrace full
Comment 3 Dominik Haumann 2009-07-20 16:55:18 UTC
paste backtrace

#0  KateLineLayout::viewLineCount (this=<value optimized out>, this=<value optimized out>) at /usr/src/debug/kdelibs-4.2.96/kate/render/katelinelayout.cpp:173
#1  KateLineLayout::viewLine (this=<value optimized out>, this=<value optimized out>) at /usr/src/debug/kdelibs-4.2.96/kate/render/katelinelayout.cpp:179
#2  0x00007fc89fe1f1ce in KateLayoutCache::textLayout (this=<value optimized out>, realLine=24, _viewLine=-1) at /usr/src/debug/kdelibs-4.2.96/kate/render/katelayoutcache.cpp:346
#3  0x00007fc89fe6c360 in KateViewInternal::previousLayout (this=0x2869220) at /usr/src/debug/kdelibs-4.2.96/kate/view/kateviewinternal.cpp:1282
#4  0x00007fc89fe742cf in KateViewInternal::cursorUp (this=0x2869220, sel=false) at /usr/src/debug/kdelibs-4.2.96/kate/view/kateviewinternal.cpp:1462
#5  0x00007fc89fe5e9fd in KateView::qt_metacall (this=0x285e050, _c=QMetaObject::InvokeMetaMethod, _id=<value optimized out>, _a=0x7fffc40e1c10)
    at /usr/src/debug/kdelibs-4.2.96/x86_64-redhat-linux-gnu/kate/kateview.moc:371
#6  0x00000031b4754fdc in QMetaObject::activate (sender=0x29245a0, from_signal_index=<value optimized out>, to_signal_index=<value optimized out>, argv=0x1) at kernel/qobject.cpp:3113
#7  0x0000003f2c188fe7 in QAction::triggered (this=0x7fffc40e1a20, _t1=false) at .moc/release-shared/moc_qaction.cpp:236
#8  0x0000003f2c18a42f in QAction::activate (this=0x29245a0, event=<value optimized out>) at kernel/qaction.cpp:1160
#9  0x0000003f2c18ceef in QAction::event (this=0x7fffc40e1a20, e=<value optimized out>) at kernel/qaction.cpp:1079
#10 0x00007fc8c19bb5cd in KAction::event (this=0x7fffc40e1a20, event=0x7fffc40e2120) at /usr/src/debug/kdelibs-4.2.96/kdeui/actions/kaction.cpp:88
#11 0x0000003f2c18ee2c in QApplicationPrivate::notify_helper (this=0x1f10890, receiver=0x29245a0, e=0x7fffc40e2120) at kernel/qapplication.cpp:4056
#12 0x0000003f2c195e5e in QApplication::notify (this=0x7fffc40e4a20, receiver=0x29245a0, e=0x7fffc40e2120) at kernel/qapplication.cpp:4021
#13 0x00007fc8c1a8c456 in KApplication::notify (this=0x7fffc40e4a20, receiver=0x29245a0, event=0x7fffc40e2120) at /usr/src/debug/kdelibs-4.2.96/kdeui/kernel/kapplication.cpp:302
#14 0x00000031b473fcbc in QCoreApplication::notifyInternal (this=0x7fffc40e4a20, receiver=0x29245a0, event=0x7fffc40e2120) at kernel/qcoreapplication.cpp:610
#15 0x0000003f2c1c35e6 in QCoreApplication::sendEvent (event=<value optimized out>, receiver=<value optimized out>) at ../../src/corelib/kernel/qcoreapplication.h:213
#16 QShortcutMap::dispatchEvent (event=<value optimized out>, receiver=<value optimized out>) at kernel/qshortcutmap.cpp:884
#17 0x0000003f2c1c5457 in QShortcutMap::tryShortcutEvent (this=0x1f109a8, o=<value optimized out>, e=0x7fffc40e25b0) at kernel/qshortcutmap.cpp:369
#18 0x0000003f2c196d8e in QApplication::notify (this=0x7fffc40e4a20, receiver=0x2869220, e=0x7fffc40e25b0) at kernel/qapplication.cpp:3645
#19 0x00007fc8c1a8c456 in KApplication::notify (this=0x7fffc40e4a20, receiver=0x2869220, event=0x7fffc40e25b0) at /usr/src/debug/kdelibs-4.2.96/kdeui/kernel/kapplication.cpp:302
#20 0x00000031b473fcbc in QCoreApplication::notifyInternal (this=0x7fffc40e4a20, receiver=0x2869220, event=0x7fffc40e25b0) at kernel/qcoreapplication.cpp:610
#21 0x0000003f2c21e4ba in QKeyMapper::sendKeyEvent (keyWidget=0x2869220, grab=<value optimized out>, type=QEvent::KeyPress, code=16777235, modifiers=<value optimized out>,
    text=@0x7fffc40e27d0, autorepeat=false, count=1, nativeScanCode=111, nativeVirtualKey=65362, nativeModifiers=16) at kernel/qkeymapper_x11.cpp:1675
#22 0x0000003f2c220a20 in QKeyMapperPrivate::translateKeyEvent (this=0x1f4dac0, keyWidget=0x2869220, event=<value optimized out>, grab=false) at kernel/qkeymapper_x11.cpp:1645
#23 0x0000003f2c1fa0a3 in QApplication::x11ProcessEvent (this=<value optimized out>, event=0x7fffc40e4390) at kernel/qapplication_x11.cpp:3443
#24 0x0000003f2c2223bc in x11EventSourceDispatch (s=<value optimized out>, callback=<value optimized out>, user_data=<value optimized out>) at kernel/qguieventdispatcher_glib.cpp:146
#25 0x0000003030c37afe in g_main_context_dispatch () from /lib64/libglib-2.0.so.0
#26 0x0000003030c3b1d8 in ?? () from /lib64/libglib-2.0.so.0
#27 0x0000003030c3b300 in g_main_context_iteration () from /lib64/libglib-2.0.so.0
#28 0x00000031b47683b6 in QEventDispatcherGlib::processEvents (this=0x1ee7d90, flags=<value optimized out>) at kernel/qeventdispatcher_glib.cpp:327
#29 0x0000003f2c221b6e in QGuiEventDispatcherGlib::processEvents (this=0x7fffc40e1a20, flags=<value optimized out>) at kernel/qguieventdispatcher_glib.cpp:202
#30 0x00000031b473e5f2 in QEventLoop::processEvents (this=<value optimized out>, flags={i = 36}) at kernel/qeventloop.cpp:149
#31 0x00000031b473e9c4 in QEventLoop::exec (this=0x7fffc40e46c0, flags={i = 0}) at kernel/qeventloop.cpp:201
#32 0x00000031b4740b79 in QCoreApplication::exec () at kernel/qcoreapplication.cpp:888
#33 0x0000000000457de8 in main (argc=<value optimized out>, argv=<value optimized out>) at /usr/src/debug/krusader-6310/krusader/main.cpp:268
Comment 4 Dario Andres 2009-07-21 01:04:29 UTC
This could have some relation with bug 200796. Thanks
Comment 5 Dario Andres 2009-10-22 15:16:15 UTC
*** Bug 211384 has been marked as a duplicate of this bug. ***
Comment 6 Dominik Haumann 2009-11-05 23:20:39 UTC
*** Bug 213328 has been marked as a duplicate of this bug. ***
Comment 7 Milian Wolff 2009-11-06 16:20:29 UTC
Problem is because KateViewInternal::m_displayCursor does not get repositioned (i.e. it's hidden). Hence it's invalid (it points to some hidden line) and cannot be found in KateCodeFoldingTree::getRealLine.

Dominik, I see you once did something like this when folding a local block. I think we need something like that also here. Should I try to make collapseToplevel also return the last visible line and use that in a KateView slot, similar to slotCollapseLocal ?

Can I just add stuff to KateView or should I only add stuff to KateViewInternal?
Comment 8 Dominik Haumann 2009-11-06 19:19:18 UTC
Yes, the display cursor is not updated and thus the crash. It needs to be updated correctly in all views (active + inactive/splitted views).

Everything that's only needed in the View should be in KateViewInternal.

KateView implements all the KTE::View+View-extension interfaces and should stay rather clean. It's supposed to be the interface for all other katepart code, i.e. no access to KateViewInternal anywhere else but KateView.
Comment 9 Pascal Létourneau 2009-12-20 01:55:29 UTC
SVN commit 1064050 by pletourn:

Prevent crash when folding


 M  +17 -14    syntax/katecodefolding.cpp  
 M  +8 -1      view/kateviewinternal.cpp  

WebSVN link: http://websvn.kde.org/?view=rev&revision=1064050
Comment 10 Dominik Haumann 2009-12-25 22:46:55 UTC
Pascal, does that maybe also fix bug #180082 ?
Comment 11 Pascal Létourneau 2009-12-30 02:28:26 UTC
I doubt it
Comment 12 Milian Wolff 2010-01-20 17:17:34 UTC
*** Bug 164772 has been marked as a duplicate of this bug. ***
Comment 13 Milian Wolff 2010-01-20 20:41:37 UTC
SVN commit 1077737 by mwolff:

backport r1064050 by pletourn:

Prevent crash when folding

CCBUG: 200858

 M  +17 -14    syntax/katecodefolding.cpp  
 M  +8 -1      view/kateviewinternal.cpp  

WebSVN link: http://websvn.kde.org/?view=rev&revision=1077737
Comment 14 Milian Wolff 2010-02-11 15:46:15 UTC
See bug 226322:

Pletourn - has there been another commit other than r1064050 that was needed to fix this crash? I only backported that one to 4.3.5.
Comment 15 Dominik Haumann 2010-04-08 00:56:11 UTC
*** Bug 233432 has been marked as a duplicate of this bug. ***
Comment 16 Jonathan Thomas 2010-04-30 14:58:57 UTC
*** Bug 235799 has been marked as a duplicate of this bug. ***
Comment 17 Dominik Haumann 2013-04-16 13:29:18 UTC
Git commit 5888f4b7020115f9bf9b55ff12d33e212d4258f4 by Dominik Haumann.
Committed on 16/04/2013 at 15:29.
Pushed by dhaumann into branch 'master'.

make sure cursor stays visible/valid when text is folded

FIXED-IN: 4.11
Related: bug 311866

M  +9    -0    part/buffer/katetextfolding.cpp
M  +11   -1    part/buffer/katetextfolding.h
M  +9    -7    part/view/kateviewinternal.cpp