Bug 309109

Summary: CWOP: Opening a document sets it to Modified
Product: [Applications] calligrawords Reporter: Friedrich W. H. Kossebau <kossebau>
Component: generalAssignee: Calligra Words Bugs <calligra-words-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: inge
Priority: NOR    
Version: Git   
Target Milestone: ---   
Platform: unspecified   
OS: Linux   
Latest Commit: Version Fixed In:
Attachments: Backtrace to point where setModified results in document set as modified after loading

Description Friedrich W. H. Kossebau 2012-10-27 17:20:28 UTC
Calligra Words for some reason sets any document it loads to the state "Modified" right from the start.
This results in the the "Save or Discard?" dialog on closing the document, even if the user did not change anything herself.

This is especially annoying when running Jos' odfautotests, btw, because though they are run with "--roundtrip-filename" the dialog box pops up and "Discard" has to be selected :/
Comment 1 Friedrich W. H. Kossebau 2012-10-30 20:29:34 UTC
Created attachment 74888 [details]
Backtrace to point where setModified results in document set as modified after loading
Comment 2 Friedrich W. H. Kossebau 2012-10-30 20:33:08 UTC
Seems like StyleDocker/StrokeFillWidget is the culprit:
it creates a command for some reason on a KoShapeManager::selectionChanged() coming in on the end of loading and setup. While StyleDocker::updateWidget() only gets 0 for firstSelectedShape(); and then updates the StrokeFillWidget to reset to default values, the change on the opacity slider results in the slot StyleDocker::updateOpacity(...) being called, which for some reason then creates a command.
See backtrace.
Comment 3 Friedrich W. H. Kossebau 2012-10-30 21:15:38 UTC
(In reply to comment #2)
> Seems like StyleDocker/StrokeFillWidget is the culprit:
> it creates a command for some reason on a KoShapeManager::selectionChanged()
> coming in on the end of loading and setup. While StyleDocker::updateWidget()
> only gets 0 for firstSelectedShape(); 

Wrong, gets a shape, which also has no stroke (0 pointer), no background (0 pointer) and no transparency (100 opacity), but that is not the problem.
The problem seems to be that updating the widget always results in commands, as at least KoSliderCombo* m_opacity always emits the signal valueChanged(), like when called with m_opacity->setValue(opacity); in StrokeFillWidget::updateWidget(...)

So it seems the fix needed is to not listen to signals if the UI is just updated to reflect the state of the selected shape(s).

I hope Inge may have some ideas here and can drop a proper patch right out of his sleeves faster than e.g. I could :)
Comment 4 Inge Wallin 2012-11-13 14:32:05 UTC
Git commit e07ccbb4d52e609a14aacbddb62f4c74edb59028 by Inge Wallin.
Committed on 13/11/2012 at 15:28.
Pushed by ingwa into branch 'master'.

Fix bug 309109: CWOP: Opening a document sets it to Modified

M  +5    -0    plugins/dockers/styledocker/StrokeFillWidget.cpp

http://commits.kde.org/calligra/e07ccbb4d52e609a14aacbddb62f4c74edb59028
Comment 5 Friedrich W. H. Kossebau 2012-11-30 17:23:11 UTC
Git commit da4e2fe352488775985f7f9c81141bbb92d6df58 by Friedrich W. H. Kossebau, on behalf of Inge Wallin.
Committed on 13/11/2012 at 15:28.
Pushed by kossebau into branch 'calligra/2.6'.

Fix bug 309109: CWOP: Opening a document sets it to Modified

M  +5    -0    plugins/dockers/styledocker/StrokeFillWidget.cpp

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