Bug 139890 - automatic formatting of URLs crash KWord
Summary: automatic formatting of URLs crash KWord
Status: RESOLVED FIXED
Alias: None
Product: kword
Classification: Miscellaneous
Component: general (show other bugs)
Version: 1.6.1
Platform: Ubuntu Linux
: NOR crash
Target Milestone: ---
Assignee: Thomas Zander
URL:
Keywords:
: 141605 (view as bug list)
Depends on:
Blocks:
 
Reported: 2007-01-11 06:21 UTC by Lasse Liehu
Modified: 2007-03-04 22:43 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Lasse Liehu 2007-01-11 06:21:33 UTC
Version:           1.6.1 (using KDE KDE 3.5.5)
Installed from:    Ubuntu Packages
Compiler:          gcc (GCC) 4.1.2 20060928 (prerelease) (Ubuntu 4.1.1-13ubuntu5) 
OS:                Linux

Steps to reproduce:

1. open KWord and create new document.
2. Make sure "Automatic formatting of URLs" is checked on in "Autocorrecting settings"
3. type "http://www.koffice.org/"
4. press spacebar
5. enjoy crash! :D

URL can be any address KWord will automatically format to a hyperlink.
If you add hyperlink from the menu uinf Insert->(Hyper?)link, no crash will happen.

Backtrace:

Using host libthread_db library "/lib/tls/i686/cmov/libthread_db.so.1".
[Thread debugging using libthread_db enabled]
[New Thread -1232504512 (LWP 17040)]
[KCrash handler]
#6  0xb7521feb in QGList::append () from /usr/lib/libqt-mt.so.3
#7  0xb6c55887 in KMacroCommand::addCommand (this=0x0, command=0x84148a8)
    at /usr/share/qt3/include/qptrlist.h:82
#8  0xb5e22c39 in KoTextObject::UndoRedoInfo::clear (this=0x8383a3c)
    at /root/koffice/koffice-1.6.1/./lib/kotext/KoTextObject.cpp:290
#9  0xb5e23610 in KoTextObject::clearUndoRedoInfo (this=0x8383a00)
    at /root/koffice/koffice-1.6.1/./lib/kotext/KoTextObject.cpp:204
#10 0xb5e56ff0 in KoTextObject::insert (this=0x8383a00, cursor=0x847ca88, 
    currentFormat=0x837c9b0, txt=@0xbfc769f4, commandName=@0xb76ff9b8, 
    selectionId=HighlightSelection, insertFlags=4, customItemsMap=@0xbfc76894)
    at /root/koffice/koffice-1.6.1/./lib/kotext/KoTextObject.cpp:726
#11 0xb5e5a0ed in KoTextObject::replaceSelectionCommand (this=0x8383a00, 
    cursor=0x847ca88, replacement=@0xbfc769f4, cmdName=@0xbfc769f0, 
    selectionId=HighlightSelection, insertFlags=4, customItemsMap=@0xbfc76924)
    at /root/koffice/koffice-1.6.1/./lib/kotext/KoTextObject.cpp:1618
#12 0xb5e56eea in KoTextObject::insert (this=0x8383a00, cursor=0x847ca88, 
    currentFormat=0x837c9b0, txt=@0xbfc769f4, commandName=@0xbfc769f0, 
    selectionId=HighlightSelection, insertFlags=0, customItemsMap=@0xbfc769ec)
    at /root/koffice/koffice-1.6.1/./lib/kotext/KoTextObject.cpp:610
#13 0xb5e57b1e in KoAutoFormat::doAutoDetectUrl (this=0x81f8c20, 
    textEditCursor=0x847ca88, parag=0x83986d8, index=@0xbfc76aec, 
    word=@0xbfc76aa0, txtObj=0x8383a00)
    at /root/koffice/koffice-1.6.1/./lib/kotext/KoAutoFormat.cpp:1779
#14 0xb5e5df3c in KoAutoFormat::doAutoFormat (this=0x81f8c20, 
    textEditCursor=0x847ca88, parag=0x83986d8, index=23, ch=@0xbfc76b12, 
    txtObj=0x8383a00)
    at /root/koffice/koffice-1.6.1/./lib/kotext/KoAutoFormat.cpp:1295
#15 0xb6069c43 in KWTextFrameSetEdit::doAutoFormat (this=0x847c4a8, 
    cursor=0x847ca88, parag=0x83986d8, index=23, ch=@0xbfc76c34)
    at /root/koffice/koffice-1.6.1/./kword/KWTextFrameSet.cpp:3237
#16 0xb5e59c38 in KoTextView::handleKeyPressEvent (this=0x847c4a8, 
    e=0xbfc77314, widget=0x84776c8, pos=@0xbfc76ca0)
    at /root/koffice/koffice-1.6.1/./lib/kotext/KoTextView.cpp:350
#17 0xb6140c11 in KWTextFrameSetEdit::keyPressEvent (this=0x847c4a8, 
    e=0xbfc77314)
    at /root/koffice/koffice-1.6.1/./kword/KWTextFrameSet.cpp:3456
#18 0xb6138227 in KWCanvas::eventFilter (this=0x84776c8, o=0x84776c8, 
    e=0xbfc77314) at /root/koffice/koffice-1.6.1/./kword/KWCanvas.cpp:1862
#19 0xb7224f04 in QObject::activate_filters () from /usr/lib/libqt-mt.so.3
#20 0xb7224f82 in QObject::event () from /usr/lib/libqt-mt.so.3
#21 0xb725c65b in QWidget::event () from /usr/lib/libqt-mt.so.3
#22 0xb71bcb88 in QApplication::internalNotify () from /usr/lib/libqt-mt.so.3
#23 0xb71beb58 in QApplication::notify () from /usr/lib/libqt-mt.so.3
#24 0xb78b2db2 in KApplication::notify (this=0xbfc77908, receiver=0x84776c8, 
    event=0xbfc77314)
    at /build/buildd/kdelibs-3.5.5/./kdecore/kapplication.cpp:550
#25 0xb714f3fd in QApplication::sendSpontaneousEvent ()
   from /usr/lib/libqt-mt.so.3
#26 0xb713fde9 in QETWidget::translateKeyEvent () from /usr/lib/libqt-mt.so.3
#27 0xb714c1cf in QApplication::x11ProcessEvent () from /usr/lib/libqt-mt.so.3
#28 0xb7163320 in QEventLoop::processEvents () from /usr/lib/libqt-mt.so.3
#29 0xb71d725e in QEventLoop::enterLoop () from /usr/lib/libqt-mt.so.3
#30 0xb71d706e in QEventLoop::exec () from /usr/lib/libqt-mt.so.3
#31 0xb71be731 in QApplication::exec () from /usr/lib/libqt-mt.so.3
Comment 1 David Faure 2007-01-11 13:17:25 UTC
SVN commit 622286 by dfaure:

Fix crash when autocorrect-urls replaces a url with a link
 (replaceSelectionCommand wants no placeholder command but insert assumed there was one at some point)
BUG: 139890

I see now that this is the same crash as the one in 126428 and 127771, which got fixed in 1.5, but I guess that bugfix didn't get forwardported out of the 1.5 branch :{
CCBUG: 126428, 127771


 M  +20 -16    KoTextObject.cpp  


--- branches/koffice/1.6/koffice/lib/kotext/KoTextObject.cpp #622285:622286
@@ -262,7 +262,7 @@
 
 bool KoTextObject::UndoRedoInfo::valid() const
 {
-    return text.length() > 0 && id >= 0 && index >= 0;
+    return text.length() > 0 && id >= 0 && index >= 0 && type != Invalid;
 }
 
 void KoTextObject::UndoRedoInfo::clear()
@@ -276,23 +276,26 @@
                 KoTextDocCommand * cmd = new KoTextInsertCommand( textdoc, id, index, text.rawData(), customItemsMap, oldParagLayouts );
                 textdoc->addCommand( cmd );
                 Q_ASSERT( placeHolderCmd );
-                // Inserting any custom items -> macro command, to let custom items add their command
-                if ( !customItemsMap.isEmpty() )
+                if ( placeHolderCmd ) // crash prevention
                 {
-                    CustomItemsMap::Iterator it = customItemsMap.begin();
-                    for ( ; it != customItemsMap.end(); ++it )
+                    // Inserting any custom items -> macro command, to let custom items add their command
+                    if ( !customItemsMap.isEmpty() )
                     {
-                        KoTextCustomItem * item = it.data();
-                        KCommand * itemCmd = item->createCommand();
-                        if ( itemCmd )
-                            placeHolderCmd->addCommand( itemCmd );
+                        CustomItemsMap::Iterator it = customItemsMap.begin();
+                        for ( ; it != customItemsMap.end(); ++it )
+                        {
+                            KoTextCustomItem * item = it.data();
+                            KCommand * itemCmd = item->createCommand();
+                            if ( itemCmd )
+                                placeHolderCmd->addCommand( itemCmd );
+                        }
+                        placeHolderCmd->addCommand( new KoTextCommand( textobj, /*cmd, */QString::null ) );
                     }
-                    placeHolderCmd->addCommand( new KoTextCommand( textobj, /*cmd, */QString::null ) );
+                    else
+                    {
+                        placeHolderCmd->addCommand( new KoTextCommand( textobj, /*cmd, */QString::null ) );
+                    }
                 }
-                else
-                {
-                    placeHolderCmd->addCommand( new KoTextCommand( textobj, /*cmd, */QString::null ) );
-                }
             } break;
             case Delete:
             case RemoveSelected:
@@ -319,7 +322,7 @@
     index = -1;
     oldParagLayouts.clear();
     customItemsMap.clear();
-    placeHolderCmd = 0L;
+    placeHolderCmd = 0;
 }
 
 void KoTextObject::copyCharFormatting( KoTextParag *parag, int position, int index /*in text*/, bool moveCustomItems )
@@ -722,7 +725,8 @@
         if ( textdoc->removeSelection( selectionId ) && repaint )
             selectionChangedNotify(); // does the repaint
     }
-    if ( !customItemsMap.isEmpty() ) {
+    if ( !customItemsMap.isEmpty()
+         && !commandName.isNull() /* see replace-selection; #139890 */ ) {
         clearUndoRedoInfo();
     }
 
Comment 2 Thomas Zander 2007-03-04 22:43:05 UTC
*** Bug 141605 has been marked as a duplicate of this bug. ***