Bug 48999

Summary: crash on replacing KWord forward newline selection with horizontal space
Product: kword Reporter: Stephen Compall <rushing>
Component: generalAssignee: Thomas Zander <zander>
Status: RESOLVED FIXED    
Severity: crash    
Priority: NOR    
Version: 1.5 or before   
Target Milestone: ---   
Platform: Mandrake RPMs   
OS: Linux   
Latest Commit: Version Fixed In:

Description Stephen Compall 2002-10-11 01:38:45 UTC
Version:           1.2 (using KDE KDE 3.0.3)
Installed from:    Mandrake RPMs
Compiler:          GCC 3.2 
OS:          Linux

No backtraces w/ RPMs. It's easy to reproduce, though:

1. Open new KWord doc
2. type a newline, then some text and/or spaces
3. go back to the first line, select the newline forward, and type a space or tab (thus replacing the newline)
4. core dumped

I encountered this error removing some spacing from the FDL notice, FYI :)

This bug *does not* manifest itself if you select the newline backwards (that is, the cursor is on the first line), if you don't use a horizontal spacing character, or if there is no text on the second line (though if there are spaces, it still crashes).
Comment 1 David Faure 2003-04-02 12:15:53 UTC
Subject: koffice/lib/kotext

CVS commit by faure: 

Fix crash due to autoformat using a stale paragraph pointer
CCMAIL: 48999-done@bugs.kde.org


  M +2 -2      kotextview.cc   1.107


--- koffice/lib/kotext/kotextview.cc  #1.106:1.107
@@ -330,6 +330,6 @@ void KoTextView::handleKeyPressEvent( QK
                     {
                         insertText( text );
-
-                        doAutoFormat( m_cursor, p, m_cursor->index() - 1, text[ text.length() - 1 ] );
+                        // Don't use 'p' past this point. If we replaced a selection, p could have been deleted (#48999)
+                        doAutoFormat( m_cursor, m_cursor->parag(), m_cursor->index() - 1, text[ text.length() - 1 ] );
                     }
                 }