Changeset View
Changeset View
Standalone View
Standalone View
src/core/kemoticonstheme.cpp
Show All 23 Lines | |||||
24 | 24 | | |||
25 | #include <QDebug> | 25 | #include <QDebug> | ||
26 | 26 | | |||
27 | class Q_DECL_HIDDEN KEmoticonsTheme::KEmoticonsThemeData : public QSharedData | 27 | class Q_DECL_HIDDEN KEmoticonsTheme::KEmoticonsThemeData : public QSharedData | ||
28 | { | 28 | { | ||
29 | public: | 29 | public: | ||
30 | KEmoticonsThemeData(); | 30 | KEmoticonsThemeData(); | ||
31 | ~KEmoticonsThemeData(); | 31 | ~KEmoticonsThemeData(); | ||
32 | KEmoticonsProvider *provider = nullptr; | 32 | | ||
33 | QSharedPointer<KEmoticonsProvider> provider; | ||||
anthonyfieroni: Make it shared pointer, KEmoticonsTheme::KEmoticonsTheme(const KEmoticonsTheme &ket) initialize… | |||||
33 | }; | 34 | }; | ||
34 | 35 | | |||
35 | KEmoticonsTheme::KEmoticonsThemeData::KEmoticonsThemeData() | 36 | KEmoticonsTheme::KEmoticonsThemeData::KEmoticonsThemeData() | ||
36 | { | 37 | { | ||
37 | } | 38 | } | ||
38 | 39 | | |||
39 | KEmoticonsTheme::KEmoticonsThemeData::~KEmoticonsThemeData() | 40 | KEmoticonsTheme::KEmoticonsThemeData::~KEmoticonsThemeData() | ||
40 | { | 41 | { | ||
41 | // delete provider; | | |||
42 | } | 42 | } | ||
anthonyfieroni: Remove that line. | |||||
43 | 43 | | |||
44 | KEmoticonsTheme::KEmoticonsTheme() | 44 | KEmoticonsTheme::KEmoticonsTheme() | ||
45 | { | 45 | { | ||
46 | d = new KEmoticonsThemeData; | 46 | d = new KEmoticonsThemeData; | ||
47 | } | 47 | } | ||
48 | 48 | | |||
49 | KEmoticonsTheme::KEmoticonsTheme(const KEmoticonsTheme &ket) | 49 | KEmoticonsTheme::KEmoticonsTheme(const KEmoticonsTheme &ket) | ||
50 | { | 50 | { | ||
51 | d = ket.d; | 51 | d = ket.d; | ||
52 | } | 52 | } | ||
53 | 53 | | |||
54 | KEmoticonsTheme::KEmoticonsTheme(KEmoticonsProvider *p) | 54 | KEmoticonsTheme::KEmoticonsTheme(KEmoticonsProvider *p) | ||
55 | { | 55 | { | ||
56 | d = new KEmoticonsThemeData; | 56 | d = new KEmoticonsThemeData; | ||
57 | d->provider = p; | 57 | d->provider.reset(p); | ||
I've rethink it, this line can be a problem if pointer is not owned by us. Did you know consumer of the KEmoticonsTheme? anthonyfieroni: I've rethink it, this line can be a problem if pointer is not owned by us. Did you know… | |||||
58 | } | 58 | } | ||
59 | 59 | | |||
60 | KEmoticonsTheme::~KEmoticonsTheme() | 60 | KEmoticonsTheme::~KEmoticonsTheme() | ||
61 | { | 61 | { | ||
62 | } | 62 | } | ||
63 | 63 | | |||
64 | bool KEmoticonsTheme::loadTheme(const QString &path) | 64 | bool KEmoticonsTheme::loadTheme(const QString &path) | ||
65 | { | 65 | { | ||
▲ Show 20 Lines • Show All 304 Lines • Show Last 20 Lines |
Make it shared pointer, KEmoticonsTheme::KEmoticonsTheme(const KEmoticonsTheme &ket) initialize provider with raw other pointer, deletion will cause a segfault in use after.