Simplify Panel lastSpacer + fix crash
ClosedPublic

Authored by davidedmundson on Sep 11 2016, 8:02 PM.

Details

Summary

The panel contains an invisible Item lastSpacer, who will fill the width
of the layout if no other applet has Layout.fillWidth/Height set,
keeping all applets left aligned.

Previous this worked by reparenting the invisible item in/out of the
layout to the root item. This seems overkill when we can just toggle
visibility. I think the code existed from before the panel was managed
by a Layout.

Worse, the current code leads to a potential crash on teardown.
The root gets deleted, starting a foreach(child, children)
{child->delete}
This kills the task bar, which means we reparent the spacer to the
layout. The layout then finishes killing the children and kills the
spacer. We then get back to the root objects dtor which is now deleting
a previously deleted object. See bug report.

This patch also fixes the fact that addApplet/removeApplet had a
slightly different check to see if the spacer is needed or not, fixing a
hypothetical bug if you had a Hidden applet with fillWidth: true.

BUG: 357317

Test Plan

In both horizontal and vertical:

  • have a panel without a task manager
  • add a task manager
  • remove a task manager

Diff Detail

Repository
R119 Plasma Desktop
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
davidedmundson retitled this revision from to Simplify Panel lastSpacer + fix crash.
davidedmundson updated this object.
davidedmundson edited the test plan for this revision. (Show Details)
davidedmundson added a reviewer: Plasma.
Restricted Application added a project: Plasma. · View Herald TranscriptSep 11 2016, 8:02 PM
Restricted Application added a subscriber: plasma-devel. · View Herald Transcript
mart accepted this revision.Sep 13 2016, 11:23 AM
mart added a reviewer: mart.
This revision is now accepted and ready to land.Sep 13 2016, 11:23 AM
This revision was automatically updated to reflect the committed changes.