Fix dangling pointer in KPackageJob

Review Request #129187 - Created Oct. 14, 2016 and submitted

Information
David Edmundson
kpackage
master
fcc931d...
Reviewers
kdeframeworks, plasma

A KPackage::Package object uses qexplicitlyshareddata, and it designed
to be kept on the stack and copied. However, PackageJob takes a pointer
to a package, which it later updates, which is expected to exist for the
lifecycle of the job.

This means

Package p = PackageLoader::self()->loadPackage(..);
p.install();

will crash.

Given that, I don't think this is an application error, and but a
library bug.

Both plasmashell installation and uninstallation have this problem:

BUG: 370718
BUG: 369935

As Package is not a QObject we can't just use a QWeakPointer, and
we can't just copy the Package in the packagejob as we need to detatch
and update the *original* KPackage instance. Also to match behaviour we need to do this without changing any other
KPackage instances sharing the same shareddata.

Not a neat fix at all, but there aren't many options that work
without breaking API or behaviour.

Crashing unit test
No longer crashes.

Issues

  • 1
  • 0
  • 0
  • 1
Description From Last Updated
emit? Anthony Fieroni Anthony Fieroni
David Edmundson
Anthony Fieroni
Marco Martin
David Edmundson
Review request changed

Status: Closed (submitted)

Change Summary:

Submitted with commit cfb69e21fb0aad92f403487b4c8a75b2b0bc8041 by David Edmundson to branch master.
Loading...