power@cinnamon.org: avoid re-adding contentSection in _updateProfile - #13999
Open
RainbowXie wants to merge 1 commit into
Open
RainbowXie wants to merge 1 commit into
RainbowXie wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #13998
Related to #12916
In
files/usr/share/cinnamon/applets/power@cinnamon.org/applet.js,_updateProfile()was repeatedly callingthis.menu.addMenuItem(this.contentSection)on every property change fromorg.freedesktop.UPower.PowerProfiles.Because
this.contentSectionwas already added tothis.menu.box, repeatedly adding it:~/.xsession-errors:Attempting to add actor of type 'StBoxLayout' to a container of type 'StBoxLayout', but the actor has already a parent of type 'StBoxLayout'.this.lengthinPopupMenuBaseto drift on every property change.Solution
this.contentSectiontothis.menuonce during constructor initialization (consistent withuser@cinnamon.organdremovable-drives@cinnamon.org)._updateProfile(), guardaddMenuItem(this.contentSection)withif (!this.contentSection.actor.get_parent())to prevent redundant parenting attempts while preserving the ability to refresh the items within the section viaremoveAll()andaddMenuItem(item).Verification
Reproduction & Fix verification via DBus:
Before fix, calling
_updateProfile()logged aClutter-WARNINGeach time:~/.xsession-errors.~/.local/share/cinnamon/applets/power@cinnamon.org/for 3+ days in a desktop session with dynamic power profile switches.~/.xsession-errorslogged 0 warnings (compared to over 3,000 instances prior to the fix), and compositor GPU usage dropped back to normal idle levels.