Bug 170399 - Crash when trying to edit template
Summary: Crash when trying to edit template
Status: VERIFIED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: UI (show other bugs)
Version:
(earliest affected)
26.2.0.0 alpha0+ master
Hardware: x86-64 (AMD64) All
: highest critical
Assignee: Michael Weghorn
URL:
Whiteboard: target:26.8.0 target:26.2.0
Keywords: bibisected, bisected, haveBacktrace, regression
Depends on:
Blocks:
 
Reported: 2026-01-20 08:23 UTC by Buovjaga
Modified: 2026-01-22 10:54 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Buovjaga 2026-01-20 08:23:33 UTC
1. Launch into Start Center
2. File - Templates - Manage Templates (Ctrl+Shift+N)
3. Right-click on any template, even your own custom one and click Edit

Bibisected with linux-64-26.2 to 8ce2cf3973ecd428eb8d0290930791ee1c771626
tdf#41777 Add window size and position for each document

Noticed in bug 138246. Reproduced by multiple people on Linux and Windows.

Backtrace: attachment 205084 [details]
Comment 1 Noel Grandin 2026-01-20 08:43:51 UTC
The new code added in the bisected commit is being triggered and closing the frame that is currently trying to open, stacktrace looks like:

#0  framework::pattern::frame::closeIt (xResource=uno::Reference to ((anonymous namespace)::XFrameImpl *) 0x555556745920)
    at framework/source/inc/pattern/frame.hxx:51
#1  0x00007ffff4a53c5d in framework::LoadEnv::impl_reactForLoadingState (this=0x7fffffff15e8)
    at /home/noel/libo/framework/source/loadenv/loadenv.cxx:1655
#2  0x00007ffff4a53656 in framework::LoadEnv::impl_setResult (this=0x7fffffff15e8, bResult=true)
    at /home/noel/libo/framework/source/loadenv/loadenv.cxx:537
#3  0x00007ffff4a53491 in framework::LoadEnv::impl_loadContent (this=0x7fffffff15e8) at /home/noel/libo/framework/source/loadenv/loadenv.cxx:1184
#4  0x00007ffff4a505e5 in framework::LoadEnv::start (this=0x7fffffff15e8) at /home/noel/libo/framework/source/loadenv/loadenv.cxx:417
#5  0x00007ffff4a4e2d2 in framework::LoadEnv::startLoading
    (this=0x7fffffff15e8, sURL="file:///home/noel/libo/instdir/share/extensions/wiki-publisher/templates/MediaWiki/mediawiki.ott", lMediaDescriptor=uno::Sequence of length 3 = {...}, xBaseFrame=uno::Reference to (framework::Desktop *) 0x5555567a25f8, sTarget="_default", nSearchFlags=0, eFeature=LoadEnvFeatures::WorkWithUI) at /home/noel/libo/framework/source/loadenv/loadenv.cxx:313
#6  0x00007ffff4a4cbd2 in framework::LoadEnv::loadComponentFromURL
    (xLoader=uno::Reference to (framework::Desktop *) 0x5555567a2608, xContext=uno::Reference to (cppu::(anonymous namespace)::ComponentContext *) 0x55555559b608, sURL="file:///home/noel/libo/instdir/share/extensions/wiki-publisher/templates/MediaWiki/mediawiki.ott", sTarget="_default", nSearchFlags=0, lArgs=uno::Sequence of length 3 = {...}) at /home/noel/libo/framework/source/loadenv/loadenv.cxx:169
(More stack frames follow...)
Comment 2 Michael Weghorn 2026-01-20 09:24:41 UTC
(In reply to Buovjaga from comment #0)
> 1. Launch into Start Center
> 2. File - Templates - Manage Templates (Ctrl+Shift+N)
> 3. Right-click on any template, even your own custom one and click Edit
> 
> Bibisected with linux-64-26.2 to 8ce2cf3973ecd428eb8d0290930791ee1c771626
> tdf#41777 Add window size and position for each document
> 
> Noticed in bug 138246. Reproduced by multiple people on Linux and Windows.
> 
> Backtrace: attachment 205084 [details]

Wasn't involved in the above, but at a quick glance, a partial revert could avoid the problem/crash while mostly keeping the feature of restoring previous window state working. The latter wouldn't work when opening docs from the start center any more, however.

Change demonstrating that:
https://gerrit.libreoffice.org/c/core/+/197637

If somebody else comes up with a better solution, I'm happy to drop that again.
Comment 3 wildgugu2020 2026-01-20 19:21:08 UTC
Hi, although I couldn't find the crash reason atm, part of the reason seems to be 

LoadEnv::impl_searchRecycleTarget() is expecting templates to reuse the 
start center but in manage templates view, the templates that are right click and open as edit are not loaded as templates.

Inside templatedlg.cxx, changing aArgs property, AsTemplate to true fixes the crash for now.

IMPL_LINK(SfxTemplateManagerDlg, EditTemplateHdl, ThumbnailViewItem*, pItem, void)
{
    uno::Sequence< PropertyValue > aArgs{
        comphelper::makePropertyValue(u"AsTemplate"_ustr, true),
...}

Even it is created as a new frame, it shouldn't close together with the start center like other documents that are created as new frames.
Comment 4 Commit Notification 2026-01-21 09:25:27 UTC
Michael Weghorn committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/ab7a187b28ac1f40d47552d2ce05811dfa03fe59

tdf#170399 Revert LoadEnv changes from "tdf#41777 Add window size ...

It will be available in 26.8.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 5 Michael Weghorn 2026-01-21 09:29:54 UTC
(In reply to wildgugu2020 from comment #3)
> Hi, although I couldn't find the crash reason atm, part of the reason seems
> to be 
> 
> LoadEnv::impl_searchRecycleTarget() is expecting templates to reuse the 
> start center but in manage templates view, the templates that are right
> click and open as edit are not loaded as templates.
> 
> Inside templatedlg.cxx, changing aArgs property, AsTemplate to true fixes
> the crash for now.
> 
> IMPL_LINK(SfxTemplateManagerDlg, EditTemplateHdl, ThumbnailViewItem*, pItem,
> void)
> {
>     uno::Sequence< PropertyValue > aArgs{
>         comphelper::makePropertyValue(u"AsTemplate"_ustr, true),
> ...}
> 
> Even it is created as a new frame, it shouldn't close together with the
> start center like other documents that are created as new frames.

That indeed avoids the crash in a quick test. But it would mean that you now get a new document (e.g. "Untitled 1") based on the template, instead of being able to edit the actual template, so that wouldn't be ideal.

I've merged my change for now to have the crash fixed in time for the 26.2 release. (This gives time to take a closer look without needing to rush in any way, if you're interested.)

If you come up with a different idea/solution, then this can of course be changed again.
Thanks a lot for looking into this and your input in Gerrit and by email!
Comment 6 Commit Notification 2026-01-22 08:33:50 UTC
Michael Weghorn committed a patch related to this issue.
It has been pushed to "libreoffice-26-2":

https://git.libreoffice.org/core/commit/15af2537927281a8073fdf919fc0050f3e55db57

tdf#170399 Revert LoadEnv changes from "tdf#41777 Add window size ...

It will be available in 26.2.1.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 7 Commit Notification 2026-01-22 08:34:58 UTC
Michael Weghorn committed a patch related to this issue.
It has been pushed to "libreoffice-26-2-0":

https://git.libreoffice.org/core/commit/f2f7209d5226a34e96d7a308a86b67607d268001

tdf#170399 Revert LoadEnv changes from "tdf#41777 Add window size ...

It will be available in 26.2.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 8 Buovjaga 2026-01-22 10:54:23 UTC
Verified.