Bug 165313 - EDITING: Character Style Inherit from and Delete does not revert to the parent style
Summary: EDITING: Character Style Inherit from and Delete does not revert to the paren...
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
24.8.4.2 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: bibisected, bisected, dataLoss, needsDevAdvice, regression
: 164370 (view as bug list)
Depends on:
Blocks:
 
Reported: 2025-02-18 10:44 UTC by Michael Otto
Modified: 2025-07-10 03:02 UTC (History)
5 users (show)

See Also:
Crash report or crash signature:


Attachments
Character Styles inherit from Strong Emphasis resp. MyEmphasis (14.38 KB, application/vnd.oasis.opendocument.text)
2025-02-18 10:44 UTC, Michael Otto
Details
styles myStrong and MyEmphasis2 deleted but still used in content (14.51 KB, application/vnd.oasis.opendocument.text)
2025-02-18 10:47 UTC, Michael Otto
Details
Sample of LibreOffice master build at crash (210.58 KB, text/plain)
2025-03-28 20:02 UTC, Patrick (volunteer)
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Otto 2025-02-18 10:44:48 UTC
Created attachment 199272 [details]
Character Styles inherit from Strong Emphasis resp. MyEmphasis

PRECONDITION:
(see attached MyCharacterStyle.odt)

example inherits from standard style:
New Style myStrong Inherit from Strong Emphasis
used by 1st text line in document

another example which inherits from Custom Style:
New Style MyEmphasis Inherit from Emphasis
used by 2nd text line in document
New Style MyEmphasis2 Inherit from MyEmphasis
used by 3rd text line in document


PROBLEM DESCRIPTION:
(see attached MyCharacterStyleDel.odt after deleting both)

Delete custom style myStrong
==> text does not revert to inherit-from-style Strong Emphasis

Delete custom style MyEmphasis2
==> text does not revert to inherit-from-style MyEmphasis

see style.xml
the deleted styles are removed
see content.xml:
the removed styles are still used
<text:span text:style-name="myStrong">
<text:span text:style-name="MyEmphasis2">


EXPECTED BEHAVIOR:
styles will revert to the parent style
<text:span text:style-name="Strong_20_Emphasis"> (1st line)
resp. <text:span text:style-name="MyEmphasis"> (3rd line)

(works fine with Paragraph Styles)


Version: 24.8.4.2 (X86_64) / LibreOffice Community
Build ID: bb3cfa12c7b1bf994ecc5649a80400d06cd71002
CPU threads: 2; OS: Linux 6.8; UI render: default; VCL: gtk3
Locale: de-DE (de_DE.UTF-8); UI: en-US
Calc: threaded
Comment 1 Michael Otto 2025-02-18 10:47:04 UTC
Created attachment 199273 [details]
styles myStrong and MyEmphasis2 deleted but still used in content
Comment 2 Regina Henschel 2025-02-18 17:26:48 UTC
The warning text when deleting the character style is, "One or more of the selected styles is in use in this document. If you will delete it, text or objects using these styles will revert to the parent style. Do you still wish to delete these styles?"

When you have deleted the style the text portion still shows the color from the now deleted style. It does not show the color of the parent. Reverting to the parent styles does not happen. If you use the Style Inspector with this portion of text, LibreOffice crashes. (Click on different portions of the text and then back to the affected one.)

An immediate save after deleting the character style has the no longer existing style referenced in the markup of the text portion, as described by the reporter.

Tested with Version: 25.8.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: 85c8901dc2710e91bccb64cd7d8068441f42f65b
CPU threads: 32; OS: Windows 11 X86_64 (build 26100); UI render: Skia/Vulkan; VCL: win
Locale: de-DE (de_DE); UI: en-US
Calc: threaded

It was OK in Version: 7.6.4.1 (X86_64) / LibreOffice Community
Build ID: e19e193f88cd6c0525a17fb7a176ed8e6a3e2aa1
CPU threads: 32; OS: Windows 10.0 Build 26100; UI render: Skia/Vulkan; VCL: win
Locale: de-DE (de_DE); UI: en-US
Calc: threaded
Comment 3 Saburo 2025-02-20 08:52:49 UTC
Bibisected with linux-64-24.8
commit 23829f6e1cebf808f4e6ff6ed4856123ad8e8e38
author	Patrick Luby <guibmacdev@gmail.com>

tdf#140061 keep SwCharFormat instances alive while SwDoc is alive

Change-Id: I22a7fc1e109e641932f348e9ac3b85f11ce46c9d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171608
Comment 4 David 2025-03-28 13:21:47 UTC
Causes data loss that may not be realized until too late.
Comment 5 Patrick (volunteer) 2025-03-28 19:55:53 UTC
(In reply to Saburo from comment #3)
> Bibisected with linux-64-24.8
> commit 23829f6e1cebf808f4e6ff6ed4856123ad8e8e38
> author	Patrick Luby <guibmacdev@gmail.com>
> 
> tdf#140061 keep SwCharFormat instances alive while SwDoc is alive
> 
> Change-Id: I22a7fc1e109e641932f348e9ac3b85f11ce46c9d
> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171608

So I created the following patch that reverts the above commit:

https://gerrit.libreoffice.org/c/core/+/183468

The good news is that reverting the commit does *not* cause tdf#140061 to reappear.

The bad news is that now I see a crash when deleting a custom style in attachment #199272 [details].

While I wish I could help, I am not familiar with the Writer code so when I tried to fix tdf#140061, I just delayed deletion of the custom style's memory and it appears that this bug also needs the same delayed deletion as well.

Maybe the Writer developers know some way to "unlink" whatever code is holding on to the custom style's memory.
Comment 6 Patrick (volunteer) 2025-03-28 20:02:18 UTC
Created attachment 200071 [details]
Sample of LibreOffice master build at crash

This crash log was captured while using the following patch in my local master macOS build. Don't know if this is useful data, but the crash occurs in lcl_MergeAttr_ExpandChrFormat():

https://gerrit.libreoffice.org/c/core/+/183468
Comment 7 Buovjaga 2025-06-11 15:25:49 UTC
*** Bug 164370 has been marked as a duplicate of this bug. ***