Gradient weirdness on revert

Summary:

Gradients in objectBoundingBox units are rendered badly when reverted.

Steps to reproduce:

Route 1
  • Open Inkscape
  • Open an existing file with a linear gradient using default (objectBoundingBox) units
  • Look at the image in Inkscape without modifying it
  • Revert the image
Route 2
  • Open Inkscape
  • Create a file with an object using a linear gradient
  • Save the file in Inkscape
  • Open the file in a text editor
  • Notice that the file contains two gradient definitions: One with stops and no set gradientUnits, and a second one with a hyperreference to the first one
  • Copy the ID of the first gradient
  • Switch the fill of the object from the second gradient to the first gradient
  • Save the file in your text editor
  • Revert the image in Inkscape
  • Close Inkscape
  • Restart Inkscape
  • Reopen the file

What happened?

The image viewed after reverting is different from the image when freshly opened in Inkscape. Specifically, when freshly opened, the gradient spans the object, whereas when reverted, the object's color is highly dominated by the stop at 100%.

What should have happened?

The gradient should smoothly span the object. Additionally, reverting an image without modifying it should never change its appearance.

Sample attachments:

Minimal SVG test case for the bug:

gradient-revert-test-simple-1.svg

How this renders in Inkscape on first open and in other programs:

gradient-revert-test-simple-1

How this renders in Inkscape after reverting:

gradient-revert-test-simple-1-actual

Version info

Inkscape 1.4 (e7c3feb, 2024-10-09)

                      Compile  (Run)
    GLib version:     2.64.6
    GTK version:      3.24.20 (3.24.20)
    glibmm version:   2.64.2
    gtkmm version:    3.24.2
    libxml2 version:  2.9.10
    libxslt version:  1.1.34
    Cairo version:    1.16.0 (1.16.0)
    Pango version:    1.44.7 (1.44.7)
    HarfBuzz version: 2.6.4 (2.6.4)

    OS version:       Debian GNU/Linux 12 (bookworm)