PreviewDrawing is crashing on exit

Summary:

Crash on exit with Export dialog open. Use-after-free.

Steps to reproduce:

  • open Inkscape
  • draw a shape
  • play with Export dialog (open export extension prefs popup)
  • quit

What happened?

Crash with use after free under ASAN:

heap-use-after-free export-preview.cpp:39 in Inkscape::UI::Dialog::PreviewDrawing::~PreviewDrawing()

Previously allocated:

SPDocument::createDoc(Inkscape::XML::Document*, char const*, char const*, char const*, bool, SPDocument*) document.cpp:348

Freed by:

InkscapeApplication::document_close(SPDocument*) inkscape-application.cpp:343

What should have happened?

No crash.

Sample attachments:

Version info

Inkscape 1.5-dev (46d0f04d09, 2025-04-13, custom) on macOS