Fix reloading of SVG images
ClosedPublic

Authored by muhlenpfordt on Apr 14 2018, 7:35 AM.

Details

Summary

If an SVG image is reloaded (F5 or FileReload) the
QSvgRenderer is not updated after loading and Gwenview crashes
when trying to zoom. If the SVG file is changed outside Gwenview
while it is viewed and then reloaded it's not updated.
This is caused by a missing connection to the loaded() signal
and calling SvgImageView::finishLoadFromDocument() to setup the
new renderer.

BUG: 359736
FIXED-IN: 18.04.1

Test Plan
  1. Open SVG image in View Mode
  2. Press F5 to reload
  3. Zoom by mouse scroll or moving the slider
  4. Gwenview should not crash
  1. Open SVG image in View Mode
  2. Overwrite viewed file with another SVG outside Gwenview
  3. Press F5 to reload
  4. New image should display

Diff Detail

Repository
R260 Gwenview
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
muhlenpfordt requested review of this revision.Apr 14 2018, 7:35 AM
muhlenpfordt created this revision.
muhlenpfordt added inline comments.
lib/documentview/svgviewadapter.cpp
55–56

The loaded() signal has already been emitted so we need to call finishLoadFromDocument() here. The check is not needed at the moment since SvgDocumentLoadedImpl::loadingState() always returns Document::Loaded but this may change in future.

huoni added a subscriber: huoni.EditedApr 14 2018, 11:15 PM

Tested and working in both cases, and code makes sense.

This says FIXED-IN: 18.04.1, but is branched from master... in case you weren't aware.

rkflx accepted this revision.Apr 14 2018, 11:17 PM
rkflx added a subscriber: rkflx.

Haha, reading the title I thought this was a fix for https://bugs.kde.org/show_bug.cgi?id=131068, but eliminating a crash is even better, of course ;)

Apart from the comment LGTM (but make sure to land to stable).

lib/documentview/svgviewadapter.cpp
58

First I had trouble understanding the comment. After reading f827f8a95, how about:

// Ensure finishLoadFromDocument is also called when
// - loadFromDocument was called before the document was fully loaded
// - reloading is triggered (e.g. via F5)

As you mentioned, currently the first case can never happen, but at least this would correspond to the if.

This revision is now accepted and ready to land.Apr 14 2018, 11:17 PM
muhlenpfordt marked an inline comment as done.

Rebase to Applications/18.04
Changed comment

This says FIXED-IN: 18.04.1, but is branched from master... in case you weren't aware.

Oh, thanks - I really didn't notice that.

lib/documentview/svgviewadapter.cpp
58

That's a much better description. :)

This revision was automatically updated to reflect the committed changes.