Bug 52661 - KWord crashes often
Summary: KWord crashes often
Status: CLOSED FIXED
Alias: None
Product: kword
Classification: Miscellaneous
Component: general (show other bugs)
Version: 1.5 or before
Platform: Compiled Sources Linux
: NOR crash
Target Milestone: ---
Assignee: Thomas Zander
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-01-06 12:56 UTC by Nicolas Goutte
Modified: 2003-01-12 20:09 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
Crash output (3.28 KB, text/plain)
2003-01-06 12:58 UTC, Nicolas Goutte
Details
Crash with KOffice 2003-01-06 16:47 UTC (3.29 KB, text/plain)
2003-01-06 20:22 UTC, Nicolas Goutte
Details
kotextformatter.diff (2.77 KB, text/x-diff)
2003-01-09 21:11 UTC, Nicolas Goutte
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Nicolas Goutte 2003-01-06 12:56:40 UTC
Version:           KOffice CVS HEAD 2003-01-06 09:48 UTC (using KDE KDE 3.0.99)
Installed from:    Compiled From Sources
Compiler:          gcc 3.2 -march=pentium2
OS:          Linux

Just after loading the MSWrite test file (kofficetests/documents/import/mswrite/filtertest.wri), KWord crashes.

As it worked before the cvs update of KWord, I do not think that it is a filter problem.

Have a nice day/evening/night!
Comment 1 Nicolas Goutte 2003-01-06 12:58:41 UTC
Created attachment 705 [details]
Crash output
Comment 2 Nicolas Goutte 2003-01-06 15:03:45 UTC
It is not only this file. 
 
I have the same problem when inserting a variable in KWord on a new document. 
 
Have a nice day/evening/night! 
Comment 3 Nicolas Goutte 2003-01-06 20:22:54 UTC
Created attachment 708 [details]
Crash with KOffice 2003-01-06 16:47 UTC

The crash has now changed a little.
Comment 4 Nicolas Goutte 2003-01-08 18:11:09 UTC
Just a feeling: could it be when there is a <FORMAT> where the id attribute is not 1? 
 
Have a nice day/evening/night! 
 
Comment 5 Nicolas Goutte 2003-01-09 21:11:07 UTC
Subject: [PATCH] Fix KoText crash (#52661)

Attached is a (rough) patch for koffice/lib/kotext/kotextformatter.cc

It fixes KDE Bug#52661 (crash of KWord when loading the MSWrite test file 
kofficetests/documents/import/mswrite/filtertest.wri and similar crashes.)

The problem is that the code assumed that KoTextStringChar::d.format is always 
valid, which it is not in the case of custom data (pictures, variables and 
anything similar, which in a KWord file have a <FORMAT> where id != 1)

Having seen the code, I am also asking myself if instead of using the height 
of the characters to decide where to draw the underline, it would not be 
better to use only the descent. Otherwise, it might get ugly for fonts having 
an untypical ascent/descent ratio. (Similar for strikeout, where using the 
ascent would be better in my opinion.)

Have a nice day/evening/night!

Created an attachment (id=717)
kotextformatter.diff
Comment 6 Nicolas Goutte 2003-01-10 21:06:41 UTC
Subject: koffice/lib/kotext

CVS commit by goutte: 

Fix the crash of KWord in KoText
(If the change is not right, it can be still changed, but I have supposed that
people would prefer a working KWord for the weekend.)
CCMAIL: 52661-close@bugs.kde.org


  M +3 -3      kotextformatter.cc   1.50


--- koffice/lib/kotext/kotextformatter.cc  #1.49:1.50
@@ -605,8 +605,8 @@ KoTextParagLineStart *KoTextFormatter::k
     }
     double current=0;
-    double nc=0;
+    int nc=0; // Not double, as we check it against 0 and to avoid gcc warnings
     for(int i=start;i<=last;i++)
     {
-        KoTextFormat* format=string->at(i).d.format;
+        KoTextFormat* format=string->at(i).format();
         if((((!format->underline())&&
            (!format->doubleUnderline())&&
@@ -621,5 +621,4 @@ KoTextParagLineStart *KoTextFormatter::k
             nc=0;
             current=0;
-            avg=0;
         }
         else if(format->underline()||
@@ -628,4 +627,5 @@ KoTextParagLineStart *KoTextFormatter::k
         {
             nc++;
+            // ### TODO: check if a formula with descent() instead of height() would not be better (for strikeout, use ascent())
             current+=format->height();
         }