Skip to content

Conversation

Jojo-Schmitz
Copy link
Contributor

@Jojo-Schmitz Jojo-Schmitz commented Sep 18, 2025

as isStyled() has been asked for already and lead to leaving this method, asking it again doesn't make any sense. Reinstating a comment from 3.x reveals that this method is supposed to be working differently, so now it does.

This would render the force parameter unneeded, if instead setPropertyFlags(<pid>, PropertyFlags::UNSTYLED) would be used.
I guess the force parameter got introduced as a workaround for that bug?

}
PropertyFlags f = item->propertyFlags(pid);
PropertyValue d = !force && (f != PropertyFlags::STYLED) ? item->propertyDefault(pid) : PropertyValue();
PropertyValue d = !force && (f != PropertyFlags::NOSTYLE) ? item->propertyDefault(pid) : PropertyValue();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not match "properties without style are written if different from default value".
Instead, properties without style are now written always, because they are compared to an invalid PropertyValue, rather than the default value.

Since isStyled is indeed checked at the top of the method, isn't the solution (as far as there is anything to be solved at all) to remove this check completely?

Suggested change
PropertyValue d = !force && (f != PropertyFlags::NOSTYLE) ? item->propertyDefault(pid) : PropertyValue();
PropertyValue d = force ? PropertyValue() : item->propertyDefault(pid);

Copy link
Contributor Author

@Jojo-Schmitz Jojo-Schmitz Sep 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May well be. But why has there been that check in the first place?

Well, as PropertyFlags::STYLED can't happen, != PropertyFlags::NOSTYLE means `== PropertyFlags::UNSTYLED``, and that is when they do get writte (now)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But isn't it the wrong way around now? With your change, for NOSTYLE we don't check the default, and for UNSTYLED we do check the default.

So, shouldn't it be like this?

Suggested change
PropertyValue d = !force && (f != PropertyFlags::NOSTYLE) ? item->propertyDefault(pid) : PropertyValue();
PropertyValue d = (force || f == PropertyFlags::UNSTYLED) ? PropertyValue() : item->propertyDefault(pid);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, most probably... this inverted logic makes me go dizzy...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit from the history seems relevant: 7523286

Copy link
Contributor Author

@Jojo-Schmitz Jojo-Schmitz Sep 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Certainly. Yet the logic is obviously wrong, that case just can't happen

Indeed 3.x has the same issue, that's how I found out...

Copy link
Contributor Author

@Jojo-Schmitz Jojo-Schmitz Sep 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe @jthistle can enlighten us here about the intention of his change?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wish I could help, but this was almost 7 years ago. I don't even remember writing this commit. How time flies....

Good luck!!!!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So back to @cbjeukendrup's simplification, that at least keeps the current behavior

as `isStyled()` has been asked for already and lead to leaving this method, asking it again doesn't make any sense.
Reinstating a comment from 3.x reveals that this method is supposed to be working differently, so now it does.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants