Use the "nullptr" literal.

This commit is contained in:
Roman Telezhynskyi 2024-02-19 11:24:10 +02:00
parent 409161c302
commit 304ff66b06
5 changed files with 33 additions and 36 deletions

View File

@ -1641,7 +1641,7 @@ auto dxfRW::writeImage(DRW_Image *ent, const std::string &name) -> DRW_ImageDef
{ {
// search if exist imagedef with this mane (image inserted more than 1 time) // search if exist imagedef with this mane (image inserted more than 1 time)
// RLZ: imagedef_reactor seem needed to read in acad // RLZ: imagedef_reactor seem needed to read in acad
DRW_ImageDef *id = NULL; DRW_ImageDef *id = nullptr;
for (unsigned int i = 0; i < imageDef.size(); i++) for (unsigned int i = 0; i < imageDef.size(); i++)
{ {
if (imageDef.at(i)->name == name) if (imageDef.at(i)->name == name)
@ -1682,7 +1682,7 @@ auto dxfRW::writeImage(DRW_Image *ent, const std::string &name) -> DRW_ImageDef
id->reactors[idReactor] = toHexStr(static_cast<int>(ent->handle)); id->reactors[idReactor] = toHexStr(static_cast<int>(ent->handle));
return id; return id;
} }
return NULL; // not exist in acad 12 return nullptr; // not exist in acad 12
} }
auto dxfRW::writeBlockRecord(std::string name) -> bool auto dxfRW::writeBlockRecord(std::string name) -> bool

View File

@ -20,19 +20,20 @@
#include "vemptyproperty.h" #include "vemptyproperty.h"
#include <stddef.h>
#include <QBrush> #include <QBrush>
#include <QColor> #include <QColor>
#include <QFlags> #include <QFlags>
#include <QFont> #include <QFont>
#include <stddef.h>
#include "../vproperty.h" #include "../vproperty.h"
namespace VPE { namespace VPE
{
class VPropertyPrivate; class VPropertyPrivate;
} // namespace VPE } // namespace VPE
VPE::VEmptyProperty::VEmptyProperty(const QString& name) VPE::VEmptyProperty::VEmptyProperty(const QString &name)
: VProperty(name, : VProperty(name,
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
QMetaType::UnknownType) QMetaType::UnknownType)
@ -42,13 +43,11 @@ VPE::VEmptyProperty::VEmptyProperty(const QString& name)
{ {
} }
VPE::VEmptyProperty::VEmptyProperty(VPropertyPrivate *d) VPE::VEmptyProperty::VEmptyProperty(VPropertyPrivate *d)
: VProperty(d) : VProperty(d)
{ {
} }
VPE::VEmptyProperty::~VEmptyProperty() VPE::VEmptyProperty::~VEmptyProperty()
{ {
// //
@ -85,10 +84,9 @@ auto VPE::VEmptyProperty::createEditor(QWidget *parent, const QStyleOptionViewIt
Q_UNUSED(parent) Q_UNUSED(parent)
Q_UNUSED(delegate) Q_UNUSED(delegate)
return NULL; return nullptr;
} }
//! Gets the data from the widget //! Gets the data from the widget
auto VPE::VEmptyProperty::getEditorData(const QWidget *editor) const -> QVariant auto VPE::VEmptyProperty::getEditorData(const QWidget *editor) const -> QVariant
{ {

View File

@ -20,36 +20,35 @@
#include "vpropertyfactorymanager.h" #include "vpropertyfactorymanager.h"
#include <stddef.h>
#include <QList> #include <QList>
#include <QMap> #include <QMap>
#include <QStringList> #include <QStringList>
#include <stddef.h>
#include "vabstractpropertyfactory.h" #include "vabstractpropertyfactory.h"
#include "vproperty.h" #include "vproperty.h"
#include "vpropertyfactorymanager_p.h" #include "vpropertyfactorymanager_p.h"
#include "vstandardpropertyfactory.h" #include "vstandardpropertyfactory.h"
VPE::VPropertyFactoryManager* VPE::VPropertyFactoryManager::DefaultManager = NULL; VPE::VPropertyFactoryManager *VPE::VPropertyFactoryManager::DefaultManager = nullptr;
VPE::VPropertyFactoryManager::VPropertyFactoryManager(QObject *parent) VPE::VPropertyFactoryManager::VPropertyFactoryManager(QObject *parent)
: QObject(parent), d_ptr(new VPropertyFactoryManagerPrivate()) : QObject(parent),
d_ptr(new VPropertyFactoryManagerPrivate())
{ {
} }
VPE::VPropertyFactoryManager::~VPropertyFactoryManager() VPE::VPropertyFactoryManager::~VPropertyFactoryManager()
{ {
// Delete all factories // Delete all factories
QList<VAbstractPropertyFactory*> tmpFactories = d_ptr->Factories.values(); QList<VAbstractPropertyFactory *> tmpFactories = d_ptr->Factories.values();
while (!tmpFactories.isEmpty()) while (!tmpFactories.isEmpty())
{ {
VAbstractPropertyFactory* tmpFactory = tmpFactories.takeLast(); VAbstractPropertyFactory *tmpFactory = tmpFactories.takeLast();
tmpFactories.removeAll(tmpFactory); tmpFactories.removeAll(tmpFactory);
delete tmpFactory; delete tmpFactory;
} }
delete d_ptr; delete d_ptr;
if (this == DefaultManager) if (this == DefaultManager)
{ {
@ -57,7 +56,7 @@ VPE::VPropertyFactoryManager::~VPropertyFactoryManager()
} }
} }
void VPE::VPropertyFactoryManager::registerFactory(const QString& type, VAbstractPropertyFactory* factory) void VPE::VPropertyFactoryManager::registerFactory(const QString &type, VAbstractPropertyFactory *factory)
{ {
if (type.isEmpty()) if (type.isEmpty())
{ {
@ -70,7 +69,7 @@ void VPE::VPropertyFactoryManager::registerFactory(const QString& type, VAbstrac
d_ptr->Factories[type] = factory; d_ptr->Factories[type] = factory;
} }
void VPE::VPropertyFactoryManager::unregisterFactory(VAbstractPropertyFactory* factory, const QString& type, void VPE::VPropertyFactoryManager::unregisterFactory(VAbstractPropertyFactory *factory, const QString &type,
bool delete_if_unused) bool delete_if_unused)
{ {
if (!factory) if (!factory)
@ -89,7 +88,7 @@ void VPE::VPropertyFactoryManager::unregisterFactory(VAbstractPropertyFactory* f
{ {
d_ptr->Factories.remove(tmpKey); d_ptr->Factories.remove(tmpKey);
} }
} while(!tmpKey.isEmpty()); } while (!tmpKey.isEmpty());
} }
else else
{ {
@ -119,8 +118,8 @@ auto VPE::VPropertyFactoryManager::getFactory(const QString &type) -> VPE::VAbst
auto VPE::VPropertyFactoryManager::createProperty(const QString &type, const QString &name, const QString &description, auto VPE::VPropertyFactoryManager::createProperty(const QString &type, const QString &name, const QString &description,
const QString &default_value) -> VPE::VProperty * const QString &default_value) -> VPE::VProperty *
{ {
VAbstractPropertyFactory* tmpFactory = getFactory(type); VAbstractPropertyFactory *tmpFactory = getFactory(type);
VProperty* tmpResult = NULL; VProperty *tmpResult = nullptr;
if (tmpFactory) if (tmpFactory)
{ {
tmpResult = tmpFactory->createProperty(type, name); tmpResult = tmpFactory->createProperty(type, name);
@ -140,7 +139,7 @@ auto VPE::VPropertyFactoryManager::createProperty(const QString &type, const QSt
} }
// cppcheck-suppress unusedFunction // cppcheck-suppress unusedFunction
//VPE::VPropertyFactoryManager *VPE::VPropertyFactoryManager::getDefaultManager() // VPE::VPropertyFactoryManager *VPE::VPropertyFactoryManager::getDefaultManager()
//{ //{
// if (!DefaultManager) // if (!DefaultManager)
// { // {

View File

@ -168,7 +168,7 @@ class ColorPickerItem : public QFrame
Q_OBJECT // NOLINT Q_OBJECT // NOLINT
public: public:
ColorPickerItem(const QColor &color = Qt::white, const QString &text = QString(), QWidget *parent = 0); ColorPickerItem(const QColor &color = Qt::white, const QString &text = QString(), QWidget *parent = nullptr);
~ColorPickerItem(); ~ColorPickerItem();
auto color() const -> QColor; auto color() const -> QColor;
@ -573,7 +573,7 @@ ColorPickerPopup::ColorPickerPopup(int width, bool withColorDialog, QWidget *par
} }
else else
{ {
moreButton = 0; moreButton = nullptr;
} }
eventLoop = nullptr; eventLoop = nullptr;
@ -709,7 +709,7 @@ void ColorPickerPopup::updateSelected()
{ {
QLayoutItem *layoutItem; QLayoutItem *layoutItem;
int i = 0; int i = 0;
while ((layoutItem = grid->itemAt(i)) != 0) while ((layoutItem = grid->itemAt(i)) != nullptr)
{ {
QWidget *w = layoutItem->widget(); QWidget *w = layoutItem->widget();
if (w && w->inherits("ColorPickerItem")) if (w && w->inherits("ColorPickerItem"))
@ -832,7 +832,7 @@ void ColorPickerPopup::keyPressEvent(QKeyEvent *e)
QLayoutItem *layoutItem; QLayoutItem *layoutItem;
int i = 0; int i = 0;
while ((layoutItem = grid->itemAt(i)) != 0) while ((layoutItem = grid->itemAt(i)) != nullptr)
{ {
QWidget *wl = layoutItem->widget(); QWidget *wl = layoutItem->widget();
if (wl && wl->inherits("ColorPickerItem")) if (wl && wl->inherits("ColorPickerItem"))
@ -857,7 +857,7 @@ void ColorPickerPopup::keyPressEvent(QKeyEvent *e)
QLayoutItem *layoutItem; QLayoutItem *layoutItem;
int i = 0; int i = 0;
while ((layoutItem = grid->itemAt(i)) != 0) while ((layoutItem = grid->itemAt(i)) != nullptr)
{ {
QWidget *wl = layoutItem->widget(); QWidget *wl = layoutItem->widget();
if (wl && wl->inherits("ColorPickerItem")) if (wl && wl->inherits("ColorPickerItem"))

View File

@ -64,7 +64,7 @@ class QtColorPicker : public QPushButton
Q_PROPERTY(bool colorDialog READ colorDialogEnabled WRITE setColorDialogEnabled) Q_PROPERTY(bool colorDialog READ colorDialogEnabled WRITE setColorDialogEnabled)
public: public:
explicit QtColorPicker(QWidget *parent = 0, int columns = -1, bool enableColorDialog = true); explicit QtColorPicker(QWidget *parent = nullptr, int columns = -1, bool enableColorDialog = true);
~QtColorPicker() override; ~QtColorPicker() override;