Changeset View
Changeset View
Standalone View
Standalone View
src/common/KReportItemBase.cpp
Show All 27 Lines | |||||
28 | { | 28 | { | ||
29 | public: | 29 | public: | ||
30 | Private(); | 30 | Private(); | ||
31 | ~Private(); | 31 | ~Private(); | ||
32 | 32 | | |||
33 | KPropertySet *set; | 33 | KPropertySet *set; | ||
34 | KProperty *nameProperty; | 34 | KProperty *nameProperty; | ||
35 | KProperty *sizeProperty; | 35 | KProperty *sizeProperty; | ||
36 | KProperty *positionProperty; | 36 | KProperty *positionProperty; | ||
staniek: This is not needed. This class of warnings is a false positive. If you mark them as such at… | |||||
37 | QString oldName; | 37 | QString oldName; | ||
38 | qreal z; | 38 | qreal z = 0; | ||
staniek: not needed, it's initialized in the ctor | |||||
is it better to set to 0 the c++11 way, in Private() or in KReportItemBase() ? piggz: is it better to set to 0 the c++11 way, in Private() or in KReportItemBase() ? | |||||
The c++11 way in Private() if it is only possible. Here it is. Most known exceptions are related to creating QWidgets/QObjects where we have to do that in ctor of the regular class. staniek: The c++11 way in Private() if it is only possible. Here it is.
Most known exceptions are… | |||||
39 | }; | 39 | }; | ||
40 | 40 | | |||
41 | KReportItemBase::Private::Private() | 41 | KReportItemBase::Private::Private() | ||
42 | { | 42 | { | ||
43 | set = new KPropertySet(); | 43 | set = new KPropertySet(); | ||
44 | nameProperty = new KProperty("name", QString(), tr("Name"), tr("Object Name")); | 44 | nameProperty = new KProperty("name", QString(), tr("Name"), tr("Object Name")); | ||
45 | nameProperty->setAutoSync(0); | 45 | nameProperty->setAutoSync(0); | ||
46 | 46 | | |||
47 | positionProperty = new KProperty("position", QPointF(), QCoreApplication::translate("ItemPosition", "Position")); | 47 | positionProperty = new KProperty("position", QPointF(), QCoreApplication::translate("ItemPosition", "Position")); | ||
48 | sizeProperty = new KProperty("size", QSizeF(), QCoreApplication::translate("ItemSize", "Size")); | 48 | sizeProperty = new KProperty("size", QSizeF(), QCoreApplication::translate("ItemSize", "Size")); | ||
49 | 49 | | |||
50 | set->addProperty(nameProperty); | 50 | set->addProperty(nameProperty); | ||
51 | set->addProperty(positionProperty); | 51 | set->addProperty(positionProperty); | ||
52 | set->addProperty(sizeProperty); | 52 | set->addProperty(sizeProperty); | ||
53 | } | 53 | } | ||
54 | 54 | | |||
55 | KReportItemBase::Private::~Private() | 55 | KReportItemBase::Private::~Private() | ||
56 | { | 56 | { | ||
57 | delete set; | 57 | delete set; | ||
58 | } | 58 | } | ||
59 | 59 | | |||
60 | 60 | | |||
61 | KReportItemBase::KReportItemBase() : d(new Private()) | 61 | KReportItemBase::KReportItemBase() : d(new Private()) | ||
62 | { | 62 | { | ||
63 | d->z = 0; | | |||
64 | | ||||
65 | connect(propertySet(), &KPropertySet::propertyChanged, | 63 | connect(propertySet(), &KPropertySet::propertyChanged, | ||
66 | this, &KReportItemBase::propertyChanged); | 64 | this, &KReportItemBase::propertyChanged); | ||
67 | } | 65 | } | ||
68 | 66 | | |||
69 | KReportItemBase::~KReportItemBase() | 67 | KReportItemBase::~KReportItemBase() | ||
70 | { | 68 | { | ||
71 | delete d; | 69 | delete d; | ||
72 | } | 70 | } | ||
▲ Show 20 Lines • Show All 167 Lines • Show Last 20 Lines |
This is not needed. This class of warnings is a false positive. If you mark them as such at coverity.com we don't need any changes and next time it won't complain. Please note that setting nullptr here is misleading.
If you want you can change initialization from Private::Private() to an initializer list: