Bug 293337 - Words freezes on opening file
Summary: Words freezes on opening file
Status: RESOLVED FIXED
Alias: None
Product: calligrawords
Classification: Applications
Component: general (show other bugs)
Version: Git
Platform: Unlisted Binaries Linux
: NOR normal
Target Milestone: ---
Assignee: Calligra Words Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-02-05 02:16 UTC by Sven Langkamp
Modified: 2014-10-03 17:34 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Much simpler test case by removing most of the document (10.59 KB, application/vnd.oasis.opendocument.text)
2014-09-20 07:28 UTC, Pierre Ducroquet
Details
Workaround this crash - just to help discuss further (1010 bytes, patch)
2014-09-29 22:38 UTC, Pierre Ducroquet
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Sven Langkamp 2012-02-05 02:16:59 UTC
Version:           svn (using KDE 4.6.5) 
OS:                Linux

Words freezes on opening the following file:
www.openoffice.org/dba/specifications/kde_address_book_access.odt

Reproducible: Always

Steps to Reproduce:
Open the file above.

Actual Results:  
Freezes

Expected Results:  
Doesn't freeze

OS: Linux (x86_64) release 2.6.38-13-generic
Compiler: cc
Comment 1 Pierre Ducroquet 2014-09-20 07:28:24 UTC
Created attachment 88758 [details]
Much simpler test case by removing most of the document

I cleaned up the test case to get to the root of the crash and it seems to be related to the table layout.
The opendocument parsing code seems perfectly fine with it, but the layout end up in an infinite loop…
words(6075)/kword KWDocument::insertPage: pageNumber= 1023
With this simpler test case, the debugging should be simpler
Comment 2 Camilla Boemann 2014-09-20 07:47:53 UTC
It seems to have a row that is not high enough to hold any text. I wonder if that is where the layout goes wrong

I mean if it cant fit the text it might try to move the row to the next page hoping it will have a higher row there - but if the reason is the row height rather than remaining space on paper then it will never fit and thus give us an infinite loop

I just don't get it that I haven't taken that into consideration - I know I have - so there must be some special condition here that I haven't considered
Comment 3 Pierre Ducroquet 2014-09-20 08:04:26 UTC
I confirm, drop the «empty» row (lines 516-523 of the new content.xml file) and it will work.
But the row is not exactly empty, it contains an empty paragraph. That may change a lot of things.
Comment 4 Camilla Boemann 2014-09-20 09:15:52 UTC
I think it might be this:

    if (noCellsFitted && row <= d->headerRows) {
        d->totalMisFit = true;
    }

That needs to be a bit more complex and check if additionally we are limitedByPage 

for that we need a change further up to now look like:

            qreal maxBottom = maximumAllowedBottom();
            bool limitedByPage = true;
            if (rowHasExactHeight && d->rowPositions[row] + rowHeight <= maxBottom) {
                  limitedByPage =  false;
                  maxBottom = d->rowPositions[row] + rowHeight;
            }

However I am not sure if this will not crash during paint and/or edit as the paragraph inside is not layouted
Comment 5 Pierre Ducroquet 2014-09-29 22:38:40 UTC
Created attachment 88890 [details]
Workaround this crash - just to help discuss further

This fix (well, this hack so far) hints the area of layouting code where, as far as I understand, the problem is. I submit it here to help finding a real fix.
Comment 6 Camilla Boemann 2014-09-30 09:33:53 UTC
Comment on attachment 88890 [details]
Workaround this crash - just to help discuss further

yes, it's something like this, however:

- we can't set maxBottom this late as the border thickness was subtracted above
- the  "&& !rowHasExactHeight" test is too aggressive as there might be cases where we would want to nuke and layout the row on the next page. What we only want is to prevent the case of no line fitting at all due to exact height to cause a nuke because then we end in an endless loop
Comment 7 Pierre Ducroquet 2014-10-03 17:34:46 UTC
Git commit bed9cf6b7eaf8e05cb1c78e5a5de036bd6c61569 by Pierre Ducroquet.
Committed on 02/10/2014 at 19:49.
Pushed by ducroquet into branch 'master'.

Check cell size constraints against rerow height

If the requested row height for the cell is not enough to old borders
and padding, we force the layouting to happen nevertheless in order
to prevent infinite looking for space.

Testing done on the test case for bug 293337 containing both 'real'
cells and small cells : no more infinite loop.

REVIEW: 120468

M  +13   -2    libs/textlayout/KoTextLayoutTableArea.cpp

http://commits.kde.org/calligra/bed9cf6b7eaf8e05cb1c78e5a5de036bd6c61569