delete copy constructor and assignment operator of some public classes
ClosedPublic

Authored by aacid on Jan 9 2019, 9:05 PM.

Details

Summary

If someone was using them, it'd crash since it was raw-copying the d pointer
so you would end up with a double delete.

This is BIC, but IMHO it's fine, whoever gets a compiler failure has a bug to fix

Diff Detail

Repository
R244 KCoreAddons
Branch
master
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 6877
Build 6895: arc lint + arc unit
aacid created this revision.Jan 9 2019, 9:05 PM
Restricted Application added a project: Frameworks. · View Herald TranscriptJan 9 2019, 9:05 PM
Restricted Application added a subscriber: kde-frameworks-devel. · View Herald Transcript
aacid requested review of this revision.Jan 9 2019, 9:05 PM
mpyne accepted this revision.Jan 10 2019, 3:43 AM
mpyne added a subscriber: mpyne.

The KSharedDataCache change is definitely correct. I've not done much with the kdelibs migrator but I agree with the logic and the implementation. Have you tried building some of the other frameworks or Plasma after implementing this patch? That's the only real risk I can think of.

This revision is now accepted and ready to land.Jan 10 2019, 3:43 AM
aacid added a comment.Jan 10 2019, 7:24 PM

I did some grepping and didn't find anything obvious (which make sense since it would be crashy)

This revision was automatically updated to reflect the committed changes.
cgiboudeaux added a subscriber: cgiboudeaux.EditedJan 17 2019, 2:13 PM

This is causing an error when building the python bindings:

In file included from /data/kde/build/kcoreaddons/src/lib/pybuild/PyKF5/KCoreAddons/unifiedKCoreAddons.cpp:15:
/data/kde/build/kcoreaddons/src/lib/pybuild/PyKF5/KCoreAddons/sipKCoreAddonsKdelibs4Migration.cpp:134:65: error: overload resolution selected deleted operator '='

reinterpret_cast< ::Kdelibs4Migration *>(sipDst)[sipDstIdx] = *reinterpret_cast< ::Kdelibs4Migration *>(sipSrc);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

/data/kde/src/kcoreaddons/src/lib/util/kdelibs4migration.h:85:24: note: candidate function has been explicitly deleted

Kdelibs4Migration &operator=(const Kdelibs4Migration &) = delete;
                   ^

In file included from /data/kde/build/kcoreaddons/src/lib/pybuild/PyKF5/KCoreAddons/unifiedKCoreAddons.cpp:15:
/data/kde/build/kcoreaddons/src/lib/pybuild/PyKF5/KCoreAddons/sipKCoreAddonsKdelibs4Migration.cpp:148:17: error: call to deleted constructor of '::Kdelibs4Migration'

return new  ::Kdelibs4Migration(reinterpret_cast<const  ::Kdelibs4Migration *>(sipSrc)[sipSrcIdx]);
            ^                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

[cut]

In file included from /data/kde/build/kcoreaddons/src/lib/pybuild/PyKF5/KCoreAddons/unifiedKCoreAddons.cpp:15:
/data/kde/build/kcoreaddons/src/lib/pybuild/PyKF5/KCoreAddons/sipKCoreAddonsKdelibs4Migration.cpp:181:27: error: call to deleted constructor of '::Kdelibs4Migration'

sipCpp = new  ::Kdelibs4Migration(*a0);
              ^                   ~~~

[cut]

In file included from /data/kde/build/kcoreaddons/src/lib/pybuild/PyKF5/KCoreAddons/unifiedKCoreAddons.cpp:53:
/data/kde/build/kcoreaddons/src/lib/pybuild/PyKF5/KCoreAddons/sipKCoreAddonsKSharedDataCache.cpp:348:27: error: call to deleted constructor of '::KSharedDataCache'

sipCpp = new  ::KSharedDataCache(*a0);
              ^                  ~~~

The magic to generate sip files was not magic enough

https://phabricator.kde.org/D18345