Always use nullptr instead of NULL because it is type-safe.

This commit is contained in:
Teo Mrnjavac 2015-07-22 15:48:03 +02:00
parent c4bb654916
commit de27f840bf
43 changed files with 209 additions and 209 deletions

View File

@ -101,7 +101,7 @@ public:
/**
* Open a device for reading.
* @param device_node The path of the device that is to be opened (e.g. /dev/sda)
* @return a pointer to a CoreBackendDevice or NULL if the open failed. If a pointer to
* @return a pointer to a CoreBackendDevice or nullptr if the open failed. If a pointer to
* an instance is returned, it's the caller's responsibility to delete the
* object.
*/
@ -110,7 +110,7 @@ public:
/**
* Open a device in exclusive mode for writing.
* @param device_node The path of the device that is to be opened (e.g. /dev/sda)
* @return a pointer to a CoreBackendDevice or NULL if the open failed. If a pointer to
* @return a pointer to a CoreBackendDevice or nullptr if the open failed. If a pointer to
* an instance is returned, it's the caller's responsibility to delete the
* object.
*/
@ -118,7 +118,7 @@ public:
/**
* Close a CoreBackendDevice that has previously been opened.
* @param core_device Pointer to the CoreBackendDevice to be closed. Must not be NULL.
* @param core_device Pointer to the CoreBackendDevice to be closed. Must not be nullptr.
* @return true if closing the CoreBackendDevice succeeded, otherwise false.
*
* This method does not delete the object.

View File

@ -76,7 +76,7 @@ public:
/**
* Open this backend device's partition table
* @return a pointer to the CoreBackendPartitionTable for this device or NULL in case
* @return a pointer to the CoreBackendPartitionTable for this device or nullptr in case
* of errors
*/
virtual CoreBackendPartitionTable* openPartitionTable() = 0;

View File

@ -28,15 +28,15 @@
#include <KServiceTypeTrader>
CoreBackendManager::CoreBackendManager() :
m_Backend(NULL)
m_Backend(nullptr)
{
}
CoreBackendManager* CoreBackendManager::self()
{
static CoreBackendManager* instance = NULL;
static CoreBackendManager* instance = nullptr;
if (instance == NULL)
if (instance == nullptr)
instance = new CoreBackendManager;
return instance;
@ -57,8 +57,8 @@ bool CoreBackendManager::load(const QString& name)
KPluginFactory* factory = loader.factory();
if (factory != NULL) {
m_Backend = factory->create<CoreBackend>(NULL);
if (factory != nullptr) {
m_Backend = factory->create<CoreBackend>(nullptr);
QString id = loader.metaData().toVariantMap().value(QStringLiteral("MetaData"))
.toMap().value(QStringLiteral("KPlugin")).toMap().value(QStringLiteral("Id")).toString();
@ -80,5 +80,5 @@ bool CoreBackendManager::load(const QString& name)
void CoreBackendManager::unload()
{
delete m_Backend;
m_Backend = NULL;
m_Backend = nullptr;
}

View File

@ -53,13 +53,13 @@ public:
virtual bool commit(quint32 timeout = 10) = 0;
/**
* @return pointer to the extended partition as a CoreBackendPartition or NULL if there is none
* @return pointer to the extended partition as a CoreBackendPartition or nullptr if there is none
*/
virtual CoreBackendPartition* getExtendedPartition() = 0;
/**
* @param sector sector the partition occupies
* @return the CoreBackendPartition to occupy the given sector or NULL if not found
* @return the CoreBackendPartition to occupy the given sector or nullptr if not found
*/
virtual CoreBackendPartition* getPartitionBySector(qint64 sector) = 0;

View File

@ -35,7 +35,7 @@ CopySourceDevice::CopySourceDevice(Device& d, qint64 firstsector, qint64 lastsec
m_Device(d),
m_FirstSector(firstsector),
m_LastSector(lastsector),
m_BackendDevice(NULL)
m_BackendDevice(nullptr)
{
}
@ -51,7 +51,7 @@ CopySourceDevice::~CopySourceDevice()
bool CopySourceDevice::open()
{
m_BackendDevice = CoreBackendManager::self()->backend()->openDeviceExclusive(device().deviceNode());
return m_BackendDevice != NULL;
return m_BackendDevice != nullptr;
}
/** Returns the Device's sector size

View File

@ -32,7 +32,7 @@
CopyTargetDevice::CopyTargetDevice(Device& d, qint64 firstsector, qint64 lastsector) :
CopyTarget(),
m_Device(d),
m_BackendDevice(NULL),
m_BackendDevice(nullptr),
m_FirstSector(firstsector),
m_LastSector(lastsector)
{
@ -50,7 +50,7 @@ CopyTargetDevice::~CopyTargetDevice()
bool CopyTargetDevice::open()
{
m_BackendDevice = CoreBackendManager::self()->backend()->openDeviceExclusive(device().deviceNode());
return m_BackendDevice != NULL;
return m_BackendDevice != nullptr;
}
/** @return the Device's sector size */

View File

@ -83,7 +83,7 @@ Device::Device(const QString& name, const QString& devicenode, qint32 heads, qin
QObject(),
m_Name(name.length() > 0 ? name : i18n("Unknown Device")),
m_DeviceNode(devicenode),
m_PartitionTable(NULL),
m_PartitionTable(nullptr),
m_Heads(heads),
m_SectorsPerTrack(numSectors),
m_Cylinders(cylinders),

View File

@ -31,7 +31,7 @@
OperationRunner::OperationRunner(QObject* parent, OperationStack& ostack) :
QThread(parent),
m_OperationStack(ostack),
m_Report(NULL),
m_Report(nullptr),
m_SuspendMutex(),
m_Cancelling(false)
{

View File

@ -93,7 +93,7 @@ bool OperationStack::mergeNewOperation(Operation*& currentOp, Operation*& pushed
{
NewOperation* newOp = dynamic_cast<NewOperation*>(currentOp);
if (newOp == NULL)
if (newOp == nullptr)
return false;
DeleteOperation* pushedDeleteOp = dynamic_cast<DeleteOperation*>(pushedOp);
@ -108,7 +108,7 @@ bool OperationStack::mergeNewOperation(Operation*& currentOp, Operation*& pushed
Log() << i18nc("@info/plain", "Deleting a partition just created: Undoing the operation to create the partition.");
delete pushedOp;
pushedOp = NULL;
pushedOp = nullptr;
newOp->undo();
delete operations().takeAt(operations().indexOf(newOp));
@ -166,7 +166,7 @@ bool OperationStack::mergeNewOperation(Operation*& currentOp, Operation*& pushed
newOp->newPartition().fileSystem().setLabel(pushedLabelOp->newLabel());
delete pushedOp;
pushedOp = NULL;
pushedOp = nullptr;
return true;
}
@ -180,10 +180,10 @@ bool OperationStack::mergeNewOperation(Operation*& currentOp, Operation*& pushed
newOp->newPartition().setFileSystem(FileSystemFactory::cloneWithNewType(pushedCreateFileSystemOp->newFileSystem()->type(), *oldFs));
delete oldFs;
oldFs = NULL;
oldFs = nullptr;
delete pushedOp;
pushedOp = NULL;
pushedOp = nullptr;
return true;
}
@ -193,7 +193,7 @@ bool OperationStack::mergeNewOperation(Operation*& currentOp, Operation*& pushed
Log() << i18nc("@info/plain", "Checking file systems is automatically done when creating them: No new operation required.");
delete pushedOp;
pushedOp = NULL;
pushedOp = nullptr;
return true;
}
@ -226,7 +226,7 @@ bool OperationStack::mergeCopyOperation(Operation*& currentOp, Operation*& pushe
{
CopyOperation* copyOp = dynamic_cast<CopyOperation*>(currentOp);
if (copyOp == NULL)
if (copyOp == nullptr)
return false;
DeleteOperation* pushedDeleteOp = dynamic_cast<DeleteOperation*>(pushedOp);
@ -236,11 +236,11 @@ bool OperationStack::mergeCopyOperation(Operation*& currentOp, Operation*& pushe
if (pushedDeleteOp && &copyOp->copiedPartition() == &pushedDeleteOp->deletedPartition()) {
// If the copy operation didn't overwrite, but create a new partition, just remove the
// copy operation, forget the delete and be done.
if (copyOp->overwrittenPartition() == NULL) {
if (copyOp->overwrittenPartition() == nullptr) {
Log() << i18nc("@info/plain", "Deleting a partition just copied: Removing the copy.");
delete pushedOp;
pushedOp = NULL;
pushedOp = nullptr;
} else {
Log() << i18nc("@info/plain", "Deleting a partition just copied over an existing partition: Removing the copy and deleting the existing partition.");
@ -277,17 +277,17 @@ bool OperationStack::mergeRestoreOperation(Operation*& currentOp, Operation*& pu
{
RestoreOperation* restoreOp = dynamic_cast<RestoreOperation*>(currentOp);
if (restoreOp == NULL)
if (restoreOp == nullptr)
return false;
DeleteOperation* pushedDeleteOp = dynamic_cast<DeleteOperation*>(pushedOp);
if (pushedDeleteOp && &restoreOp->restorePartition() == &pushedDeleteOp->deletedPartition()) {
if (restoreOp->overwrittenPartition() == NULL) {
if (restoreOp->overwrittenPartition() == nullptr) {
Log() << i18nc("@info/plain", "Deleting a partition just restored: Removing the restore operation.");
delete pushedOp;
pushedOp = NULL;
pushedOp = nullptr;
} else {
Log() << i18nc("@info/plain", "Deleting a partition just restored to an existing partition: Removing the restore operation and deleting the existing partition.");
@ -316,7 +316,7 @@ bool OperationStack::mergePartFlagsOperation(Operation*& currentOp, Operation*&
{
SetPartFlagsOperation* partFlagsOp = dynamic_cast<SetPartFlagsOperation*>(currentOp);
if (partFlagsOp == NULL)
if (partFlagsOp == nullptr)
return false;
SetPartFlagsOperation* pushedFlagsOp = dynamic_cast<SetPartFlagsOperation*>(pushedOp);
@ -347,7 +347,7 @@ bool OperationStack::mergePartLabelOperation(Operation*& currentOp, Operation*&
{
SetFileSystemLabelOperation* partLabelOp = dynamic_cast<SetFileSystemLabelOperation*>(currentOp);
if (partLabelOp == NULL)
if (partLabelOp == nullptr)
return false;
SetFileSystemLabelOperation* pushedLabelOp = dynamic_cast<SetFileSystemLabelOperation*>(pushedOp);
@ -382,7 +382,7 @@ bool OperationStack::mergeCreatePartitionTableOperation(Operation*& currentOp, O
Log() << i18nc("@info/plain", "Creating new partition table, discarding previous operation on device.");
CreatePartitionTableOperation* createPartitionTableOp = dynamic_cast<CreatePartitionTableOperation*>(currentOp);
if (createPartitionTableOp != NULL)
if (createPartitionTableOp != nullptr)
pushedCreatePartitionTableOp->setOldPartitionTable(createPartitionTableOp->oldPartitionTable());
currentOp->undo();
@ -401,7 +401,7 @@ bool OperationStack::mergeCreatePartitionTableOperation(Operation*& currentOp, O
Operation. Callers <b>must not rely</b> on the pushed Operation to exist after
calling OperationStack::push().
@param o Pointer to the Operation. Must not be NULL.
@param o Pointer to the Operation. Must not be nullptr.
*/
void OperationStack::push(Operation* o)
{
@ -427,14 +427,14 @@ void OperationStack::push(Operation* o)
break;
}
if (o != NULL) {
if (o != nullptr) {
Log() << i18nc("@info/plain", "Add operation: %1", o->description());
operations().append(o);
o->preview();
o->setStatus(Operation::StatusPending);
}
// emit operationsChanged even if o is NULL because it has been merged: merging might
// emit operationsChanged even if o is nullptr because it has been merged: merging might
// have led to an existing operation changing.
emit operationsChanged();
}
@ -473,14 +473,14 @@ void OperationStack::clearDevices()
/** Finds a Device a Partition is on.
@param p pointer to the Partition to find a Device for
@return the Device or NULL if none could be found
@return the Device or nullptr if none could be found
*/
Device* OperationStack::findDeviceForPartition(const Partition* p)
{
QReadLocker lockDevices(&lock());
foreach(Device * d, previewDevices()) {
if (d->partitionTable() == NULL)
if (d->partitionTable() == nullptr)
continue;
foreach(const Partition * part, d->partitionTable()->children()) {
@ -493,11 +493,11 @@ Device* OperationStack::findDeviceForPartition(const Partition* p)
}
}
return NULL;
return nullptr;
}
/** Adds a Device to the OperationStack
@param d pointer to the Device to add. Must not be NULL.
@param d pointer to the Device to add. Must not be nullptr.
*/
void OperationStack::addDevice(Device* d)
{

View File

@ -51,7 +51,7 @@ public:
typedef QList<Operation*> Operations;
public:
OperationStack(QObject* parent = NULL);
OperationStack(QObject* parent = nullptr);
~OperationStack();
Q_SIGNALS:

View File

@ -33,7 +33,7 @@
#include <KIOCore/KMountPoint>
/** Creates a new Partition object.
@param parent the Partition's parent. May be another Partition (for logicals) or a PartitionTable. Must not be NULL.
@param parent the Partition's parent. May be another Partition (for logicals) or a PartitionTable. Must not be nullptr.
@param device the Device this Partition is on.
@param role the Partition's role(s)
@param fs pointer to the Partition's FileSystem object. The Partition object will take ownership of this.
@ -340,7 +340,7 @@ bool Partition::unmount(Report& report)
void Partition::deleteFileSystem()
{
delete m_FileSystem;
m_FileSystem = NULL;
m_FileSystem = nullptr;
}
void Partition::setPartitionPath(const QString& s)

View File

@ -24,7 +24,7 @@
/** Tries to find the predecessor for a Partition.
@param p the Partition to find a predecessor for
@return pointer to the predecessor or NULL if none was found
@return pointer to the predecessor or nullptr if none was found
*/
Partition* PartitionNode::predecessor(Partition& p)
{
@ -36,7 +36,7 @@ Partition* PartitionNode::predecessor(Partition& p)
if (plist[idx] == &p)
return plist[idx - 1];
return NULL;
return nullptr;
}
/**
@ -52,12 +52,12 @@ const Partition* PartitionNode::predecessor(const Partition& p) const
if (plist[idx] == &p)
return plist[idx - 1];
return NULL;
return nullptr;
}
/** Tries to find the successor for a Partition.
@param p the Partition to find a successor for
@return pointer to the successor or NULL if none was found
@return pointer to the successor or nullptr if none was found
*/
Partition* PartitionNode::successor(Partition& p)
{
@ -69,7 +69,7 @@ Partition* PartitionNode::successor(Partition& p)
if (plist[idx] == &p)
return plist[idx + 1];
return NULL;
return nullptr;
}
/**
@ -85,16 +85,16 @@ const Partition* PartitionNode::successor(const Partition& p) const
if (plist[idx] == &p)
return plist[idx + 1];
return NULL;
return nullptr;
}
/** Inserts a Partition into a PartitionNode's children
@param p pointer to the Partition to insert. May be NULL.
@param p pointer to the Partition to insert. May be nullptr.
@return true on success
*/
bool PartitionNode::insert(Partition* p)
{
if (p == NULL)
if (p == nullptr)
return false;
for (int idx = 0; idx < children().size(); idx++) {
@ -110,12 +110,12 @@ bool PartitionNode::insert(Partition* p)
}
/** Removes a Partition from the PartitionNode's children.
@param p pointer to the Partition to remove. May be NULL.
@param p pointer to the Partition to remove. May be nullptr.
@return true on success.
*/
bool PartitionNode::remove(Partition* p)
{
if (p == NULL)
if (p == nullptr)
return false;
if (children().removeOne(p))
@ -134,7 +134,7 @@ void PartitionNode::clearChildren()
/** Finds a Partition by sector.
@param s the sector the Partition is at
@param role the PartitionRole the Partition is supposed to have
@return pointer to the Partition found or NULL if none was found
@return pointer to the Partition found or nullptr if none was found
*/
Partition* PartitionNode::findPartitionBySector(qint64 s, const PartitionRole& role)
{
@ -148,7 +148,7 @@ Partition* PartitionNode::findPartitionBySector(qint64 s, const PartitionRole& r
return p;
}
return NULL;
return nullptr;
}
/**
@ -165,7 +165,7 @@ const Partition* PartitionNode::findPartitionBySector(qint64 s, const PartitionR
return p;
}
return NULL;
return nullptr;
}
/** Reparents a Partition to this PartitionNode

View File

@ -97,14 +97,14 @@ bool PartitionTable::hasExtended() const
return false;
}
/** @return pointer to the PartitionTable's extended Partition or NULL if none exists */
/** @return pointer to the PartitionTable's extended Partition or nullptr if none exists */
Partition* PartitionTable::extended() const
{
for (int i = 0; i < children().size(); i++)
if (children()[i]->roles().has(PartitionRole::Extended))
return children()[i];
return NULL;
return nullptr;
}
/** Gets valid PartitionRoles for a Partition
@ -136,7 +136,7 @@ int PartitionTable::numPrimaries() const
}
/** Appends a Partition to this PartitionTable
@param partition pointer of the partition to append. Must not be NULL.
@param partition pointer of the partition to append. Must not be nullptr.
*/
void PartitionTable::append(Partition* partition)
{
@ -213,7 +213,7 @@ bool PartitionTable::getUnallocatedRange(const Device& device, PartitionNode& pa
if (!parent.isRoot()) {
Partition* extended = dynamic_cast<Partition*>(&parent);
if (extended == NULL) {
if (extended == nullptr) {
qWarning() << "extended is null. start: " << start << ", end: " << end << ", device: " << device.deviceNode();
return false;
}
@ -236,7 +236,7 @@ bool PartitionTable::getUnallocatedRange(const Device& device, PartitionNode& pa
@param parent the parent PartitionNode for the new Partition
@param start the new Partition's start sector
@param end the new Partition's end sector
@return pointer to the newly created Partition object or NULL if the Partition could not be created
@return pointer to the newly created Partition object or nullptr if the Partition could not be created
*/
Partition* createUnallocated(const Device& device, PartitionNode& parent, qint64 start, qint64 end)
{
@ -246,7 +246,7 @@ Partition* createUnallocated(const Device& device, PartitionNode& parent, qint64
r |= PartitionRole::Logical;
if (!PartitionTable::getUnallocatedRange(device, parent, start, end))
return NULL;
return nullptr;
return new Partition(&parent, device, PartitionRole(r), FileSystemFactory::create(FileSystem::Unknown, start, end), start, end, QString());
}
@ -256,7 +256,7 @@ Partition* createUnallocated(const Device& device, PartitionNode& parent, qint64
*/
void PartitionTable::removeUnallocated(PartitionNode* p)
{
Q_ASSERT(p != NULL);
Q_ASSERT(p != nullptr);
qint32 i = 0;
@ -298,7 +298,7 @@ void PartitionTable::removeUnallocated()
*/
void PartitionTable::insertUnallocated(const Device& d, PartitionNode* p, qint64 start) const
{
Q_ASSERT(p != NULL);
Q_ASSERT(p != nullptr);
qint64 lastEnd = start;
@ -317,8 +317,8 @@ void PartitionTable::insertUnallocated(const Device& d, PartitionNode* p, qint64
if (!p->isRoot()) {
Partition* extended = dynamic_cast<Partition*>(p);
Q_ASSERT(extended != NULL);
parentEnd = (extended != NULL) ? extended->lastSector() : -1;
Q_ASSERT(extended != nullptr);
parentEnd = (extended != nullptr) ? extended->lastSector() : -1;
}
if (parentEnd >= firstUsable())

View File

@ -90,10 +90,10 @@ public:
public:
PartitionNode* parent() {
return NULL; /**< @return always NULL for PartitionTable */
return nullptr; /**< @return always nullptr for PartitionTable */
}
const PartitionNode* parent() const {
return NULL; /**< @return always NULL for PartitionTable */
return nullptr; /**< @return always nullptr for PartitionTable */
}
bool isRoot() const {

View File

@ -46,7 +46,7 @@ SmartStatus::SmartStatus(const QString& device_path) :
void SmartStatus::update()
{
SkDisk* skDisk = NULL;
SkDisk* skDisk = nullptr;
SkBool skSmartStatus = false;
uint64_t mkelvin = 0;
uint64_t skBadSectors = 0;

View File

@ -148,7 +148,7 @@ bool fat16::create(Report& report, const QString& deviceNode) const
bool fat16::updateUUID(Report& report, const QString& deviceNode) const
{
qint32 t = time(NULL);
qint32 t = time(nullptr);
char uuid[4];
for (quint32 i = 0; i < sizeof(uuid); i++, t >>= 8)

View File

@ -48,7 +48,7 @@ bool fat32::create(Report& report, const QString& deviceNode) const
bool fat32::updateUUID(Report& report, const QString& deviceNode) const
{
qint32 t = time(NULL);
qint32 t = time(nullptr);
char uuid[4];
for (quint32 i = 0; i < sizeof(uuid); i++, t >>= 8)

View File

@ -87,11 +87,11 @@ static QString readBlkIdValue(const QString& deviceNode, const QString& tag)
blkid_cache cache;
QString rval;
if (blkid_get_cache(&cache, NULL) == 0) {
if (blkid_get_cache(&cache, nullptr) == 0) {
blkid_dev dev;
char* label = NULL;
if ((dev = blkid_get_dev(cache, deviceNode.toLocal8Bit().constData(), BLKID_DEV_NORMAL)) != NULL &&
char* label = nullptr;
if ((dev = blkid_get_dev(cache, deviceNode.toLocal8Bit().constData(), BLKID_DEV_NORMAL)) != nullptr &&
(label = blkid_get_tag_value(cache, tag.toLocal8Bit().constData(), deviceNode.toLocal8Bit().constData()))) {
rval = QString::fromUtf8(label);
free(label);

View File

@ -116,11 +116,11 @@ void FileSystemFactory::init()
@param lastsector the FileSystem's last sector relative to the Device
@param sectorsused the number of used sectors in the FileSystem
@param label the FileSystem's label
@return pointer to the newly created FileSystem object or NULL if FileSystem could not be created
@return pointer to the newly created FileSystem object or nullptr if FileSystem could not be created
*/
FileSystem* FileSystemFactory::create(FileSystem::Type t, qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QString& uuid)
{
FileSystem* fs = NULL;
FileSystem* fs = nullptr;
switch (t) {
case FileSystem::Btrfs: fs = new FS::btrfs(firstsector, lastsector, sectorsused, label); break;
@ -151,7 +151,7 @@ FileSystem* FileSystemFactory::create(FileSystem::Type t, qint64 firstsector, qi
default: break;
}
if (fs != NULL)
if (fs != nullptr)
fs->setUUID(uuid);
return fs;
@ -174,7 +174,7 @@ const FileSystemFactory::FileSystems& FileSystemFactory::map()
/** Clones a FileSystem from another one, but with a new type.
@param newType the new FileSystem's type
@param other the old FileSystem to clone
@return pointer to the newly created FileSystem or NULL in case of errors
@return pointer to the newly created FileSystem or nullptr in case of errors
*/
FileSystem* FileSystemFactory::cloneWithNewType(FileSystem::Type newType, const FileSystem& other)
{

View File

@ -44,9 +44,9 @@ const qint32 PartResizerWidget::m_HandleHeight = 59;
*/
PartResizerWidget::PartResizerWidget(QWidget* parent) :
QWidget(parent),
m_Device(NULL),
m_Partition(NULL),
m_PartWidget(NULL),
m_Device(nullptr),
m_Partition(nullptr),
m_PartWidget(nullptr),
m_MinimumFirstSector(0),
m_MaximumFirstSector(-1),
m_MinimumLastSector(-1),
@ -55,7 +55,7 @@ PartResizerWidget::PartResizerWidget(QWidget* parent) :
m_MaximumLength(-1),
m_LeftHandle(this),
m_RightHandle(this),
m_DraggedWidget(NULL),
m_DraggedWidget(nullptr),
m_Hotspot(0),
m_MoveAllowed(true),
m_ReadOnly(false),
@ -187,7 +187,7 @@ void PartResizerWidget::mousePressEvent(QMouseEvent* event)
if (event->button() == Qt::LeftButton) {
m_DraggedWidget = static_cast<QWidget*>(childAt(event->pos()));
if (m_DraggedWidget != NULL) {
if (m_DraggedWidget != nullptr) {
if (partWidget().isAncestorOf(m_DraggedWidget))
m_DraggedWidget = &partWidget();
@ -298,7 +298,7 @@ void PartResizerWidget::mouseMoveEvent(QMouseEvent* event)
void PartResizerWidget::mouseReleaseEvent(QMouseEvent* event)
{
if (event->button() == Qt::LeftButton)
m_DraggedWidget = NULL;
m_DraggedWidget = nullptr;
}
bool PartResizerWidget::updateFirstSector(qint64 newFirstSector)
@ -444,7 +444,7 @@ void PartResizerWidget::setMoveAllowed(bool b)
{
m_MoveAllowed = b;
if (m_PartWidget != NULL)
if (m_PartWidget != nullptr)
partWidget().setCursor(b ? Qt::SizeAllCursor : Qt::ArrowCursor);
}

View File

@ -28,11 +28,11 @@
/** Creates a new PartWidget
@param parent pointer to the parent widget
@param p pointer to the Partition this widget will show. must not be NULL.
@param p pointer to the Partition this widget will show. must not be nullptr.
*/
PartWidget::PartWidget(QWidget* parent, const Partition* p) :
PartWidgetBase(parent),
m_Partition(NULL),
m_Partition(nullptr),
m_Active(false)
{
setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont));
@ -59,7 +59,7 @@ void PartWidget::updateChildren()
foreach(QWidget * w, childWidgets()) {
w->setVisible(false);
w->deleteLater();
w->setParent(NULL);
w->setParent(nullptr);
}
foreach(const Partition * child, partition()->children()) {
@ -90,7 +90,7 @@ QColor PartWidget::activeColor(const QColor& col) const
void PartWidget::paintEvent(QPaintEvent*)
{
if (partition() == NULL)
if (partition() == nullptr)
return;
const int usedPercentage = partition()->used() * 100 / partition()->capacity();

View File

@ -44,7 +44,7 @@ class LIBKPMCORE_EXPORT PartWidget : public PartWidgetBase
Q_OBJECT
public:
explicit PartWidget(QWidget* parent, const Partition* p = NULL);
explicit PartWidget(QWidget* parent, const Partition* p = nullptr);
public:
void init(const Partition* p);

View File

@ -45,7 +45,7 @@ bool CreatePartitionTableJob::run(Report& parent)
CoreBackendDevice* backendDevice = CoreBackendManager::self()->backend()->openDevice(device().deviceNode());
if (backendDevice != NULL) {
if (backendDevice != nullptr) {
Q_ASSERT(device().partitionTable());
rval = backendDevice->createPartitionTable(*report, *device().partitionTable());

View File

@ -49,12 +49,12 @@ QString BackupOperation::description() const
}
/** Can the given Partition be backed up?
@param p The Partition in question, may be NULL.
@param p The Partition in question, may be nullptr.
@return true if @p p can be backed up.
*/
bool BackupOperation::canBackup(const Partition* p)
{
if (p == NULL)
if (p == nullptr)
return false;
if (p->isMounted())

View File

@ -60,12 +60,12 @@ QString CheckOperation::description() const
}
/** Can a Partition be checked?
@param p the Partition in question, may be NULL.
@param p the Partition in question, may be nullptr.
@return true if @p p can be checked.
*/
bool CheckOperation::canCheck(const Partition* p)
{
if (p == NULL)
if (p == nullptr)
return false;
if (p->isMounted())

View File

@ -38,9 +38,9 @@
/** Creates a new CopyOperation.
@param targetdevice the Device to copy the Partition to
@param copiedpartition pointer to the new Partition object on the target Device. May not be NULL.
@param copiedpartition pointer to the new Partition object on the target Device. May not be nullptr.
@param sourcedevice the Device where to copy from
@param sourcepartition pointer to the Partition to copy from. May not be NULL.
@param sourcepartition pointer to the Partition to copy from. May not be nullptr.
*/
CopyOperation::CopyOperation(Device& targetdevice, Partition* copiedpartition, Device& sourcedevice, Partition* sourcepartition) :
Operation(),
@ -48,13 +48,13 @@ CopyOperation::CopyOperation(Device& targetdevice, Partition* copiedpartition, D
m_CopiedPartition(copiedpartition),
m_SourceDevice(sourcedevice),
m_SourcePartition(sourcepartition),
m_OverwrittenPartition(NULL),
m_OverwrittenPartition(nullptr),
m_MustDeleteOverwritten(false),
m_CheckSourceJob(NULL),
m_CreatePartitionJob(NULL),
m_CopyFSJob(NULL),
m_CheckTargetJob(NULL),
m_MaximizeJob(NULL),
m_CheckSourceJob(nullptr),
m_CreatePartitionJob(nullptr),
m_CopyFSJob(nullptr),
m_CheckTargetJob(nullptr),
m_MaximizeJob(nullptr),
m_Description(updateDescription())
{
Q_ASSERT(targetDevice().partitionTable());
@ -63,7 +63,7 @@ CopyOperation::CopyOperation(Device& targetdevice, Partition* copiedpartition, D
Q_ASSERT(dest);
if (dest == NULL)
if (dest == nullptr)
qWarning() << "destination partition not found at sector " << copiedPartition().firstSector();
if (dest && !dest->roles().has(PartitionRole::Unallocated)) {
@ -73,7 +73,7 @@ CopyOperation::CopyOperation(Device& targetdevice, Partition* copiedpartition, D
addJob(m_CheckSourceJob = new CheckFileSystemJob(sourcePartition()));
if (overwrittenPartition() == NULL)
if (overwrittenPartition() == nullptr)
addJob(m_CreatePartitionJob = new CreatePartitionJob(targetDevice(), copiedPartition()));
addJob(m_CopyFSJob = new CopyFileSystemJob(targetDevice(), copiedPartition(), sourceDevice(), sourcePartition()));
@ -243,7 +243,7 @@ void CopyOperation::cleanupOverwrittenPartition()
{
if (mustDeleteOverwritten()) {
delete overwrittenPartition();
m_OverwrittenPartition = NULL;
m_OverwrittenPartition = nullptr;
}
}
@ -272,12 +272,12 @@ Partition* CopyOperation::createCopy(const Partition& target, const Partition& s
}
/** Can a Partition be copied?
@param p the Partition in question, may be NULL.
@param p the Partition in question, may be nullptr.
@return true if @p p can be copied.
*/
bool CopyOperation::canCopy(const Partition* p)
{
if (p == NULL)
if (p == nullptr)
return false;
if (p->isMounted())
@ -291,13 +291,13 @@ bool CopyOperation::canCopy(const Partition* p)
}
/** Can a Partition be pasted on another one?
@param p the Partition to be pasted to, may be NULL
@param source the Partition to be pasted, may be NULL
@param p the Partition to be pasted to, may be nullptr
@param source the Partition to be pasted, may be nullptr
@return true if @p source can be pasted on @p p
*/
bool CopyOperation::canPaste(const Partition* p, const Partition* source)
{
if (p == NULL || source == NULL)
if (p == nullptr || source == nullptr)
return false;
if (p->isMounted())

View File

@ -87,12 +87,12 @@ bool CreatePartitionTableOperation::execute(Report& parent)
}
/** Can a new partition table be created on a device?
@param device pointer to the device, can be NULL
@param device pointer to the device, can be nullptr
@return true if a new partition table can be created on @p device
*/
bool CreatePartitionTableOperation::canCreate(const Device* device)
{
return device != NULL && (device->partitionTable() == NULL || !device->partitionTable()->isChildMounted());
return device != nullptr && (device->partitionTable() == nullptr || !device->partitionTable()->isChildMounted());
}
QString CreatePartitionTableOperation::description() const

View File

@ -33,7 +33,7 @@
/** Creates a new DeleteOperation
@param d the Device to delete a Partition on
@param p pointer to the Partition to delete. May not be NULL
@param p pointer to the Partition to delete. May not be nullptr
*/
DeleteOperation::DeleteOperation(Device& d, Partition* p, ShredAction shred) :
Operation(),
@ -103,12 +103,12 @@ void DeleteOperation::checkAdjustLogicalNumbers(Partition& p, bool undo)
}
/** Can a Partition be deleted?
@param p the Partition in question, may be NULL.
@param p the Partition in question, may be nullptr.
@return true if @p p can be deleted.
*/
bool DeleteOperation::canDelete(const Partition* p)
{
if (p == NULL)
if (p == nullptr)
return false;
if (p->isMounted())

View File

@ -38,17 +38,17 @@
/** Creates a new NewOperation.
@param d the Device to create a new Partition on
@param p pointer to the new Partition to create. May not be NULL.
@param p pointer to the new Partition to create. May not be nullptr.
*/
NewOperation::NewOperation(Device& d, Partition* p) :
Operation(),
m_TargetDevice(d),
m_NewPartition(p),
m_CreatePartitionJob(new CreatePartitionJob(targetDevice(), newPartition())),
m_CreateFileSystemJob(NULL),
m_SetPartFlagsJob(NULL),
m_SetFileSystemLabelJob(NULL),
m_CheckFileSystemJob(NULL)
m_CreateFileSystemJob(nullptr),
m_SetPartFlagsJob(nullptr),
m_SetFileSystemLabelJob(nullptr),
m_CheckFileSystemJob(nullptr)
{
addJob(createPartitionJob());
@ -109,12 +109,12 @@ QString NewOperation::description() const
}
/** Can a Partition be created somewhere?
@param p the Partition where a new Partition is to be created, may be NULL
@param p the Partition where a new Partition is to be created, may be nullptr
@return true if a new Partition can be created in @p p
*/
bool NewOperation::canCreateNew(const Partition* p)
{
return p != NULL && p->roles().has(PartitionRole::Unallocated);
return p != nullptr && p->roles().has(PartitionRole::Unallocated);
}
Partition* NewOperation::createNew(const Partition& cloneFrom,

View File

@ -53,14 +53,14 @@ ResizeOperation::ResizeOperation(Device& d, Partition& p, qint64 newfirst, qint6
m_NewFirstSector(newfirst),
m_NewLastSector(newlast),
m_CheckOriginalJob(new CheckFileSystemJob(partition())),
m_MoveExtendedJob(NULL),
m_ShrinkResizeJob(NULL),
m_ShrinkSetGeomJob(NULL),
m_MoveSetGeomJob(NULL),
m_MoveFileSystemJob(NULL),
m_GrowResizeJob(NULL),
m_GrowSetGeomJob(NULL),
m_CheckResizedJob(NULL)
m_MoveExtendedJob(nullptr),
m_ShrinkResizeJob(nullptr),
m_ShrinkSetGeomJob(nullptr),
m_MoveSetGeomJob(nullptr),
m_MoveFileSystemJob(nullptr),
m_GrowResizeJob(nullptr),
m_GrowSetGeomJob(nullptr),
m_CheckResizedJob(nullptr)
{
addJob(checkOriginalJob());
@ -313,12 +313,12 @@ bool ResizeOperation::grow(Report& report)
}
/** Can a Partition be grown, i.e. increased in size?
@param p the Partition in question, may be NULL.
@param p the Partition in question, may be nullptr.
@return true if @p p can be grown.
*/
bool ResizeOperation::canGrow(const Partition* p)
{
if (p == NULL)
if (p == nullptr)
return false;
// we can always grow, shrink or move a partition not yet written to disk
@ -332,12 +332,12 @@ bool ResizeOperation::canGrow(const Partition* p)
}
/** Can a Partition be shrunk, i.e. decreased in size?
@param p the Partition in question, may be NULL.
@param p the Partition in question, may be nullptr.
@return true if @p p can be shrunk.
*/
bool ResizeOperation::canShrink(const Partition* p)
{
if (p == NULL)
if (p == nullptr)
return false;
// we can always grow, shrink or move a partition not yet written to disk
@ -354,12 +354,12 @@ bool ResizeOperation::canShrink(const Partition* p)
}
/** Can a Partition be moved?
@param p the Partition in question, may be NULL.
@param p the Partition in question, may be nullptr.
@return true if @p p can be moved.
*/
bool ResizeOperation::canMove(const Partition* p)
{
if (p == NULL)
if (p == nullptr)
return false;
// we can always grow, shrink or move a partition not yet written to disk

View File

@ -42,7 +42,7 @@
/** Creates a new RestoreOperation.
@param d the Device to restore the Partition to
@param p pointer to the Partition that will be restored. May not be NULL.
@param p pointer to the Partition that will be restored. May not be nullptr.
@param filename name of the image file to restore from
*/
RestoreOperation::RestoreOperation(Device& d, Partition* p, const QString& filename) :
@ -50,13 +50,13 @@ RestoreOperation::RestoreOperation(Device& d, Partition* p, const QString& filen
m_TargetDevice(d),
m_RestorePartition(p),
m_FileName(filename),
m_OverwrittenPartition(NULL),
m_OverwrittenPartition(nullptr),
m_MustDeleteOverwritten(false),
m_ImageLength(QFileInfo(filename).size() / 512), // 512 being the "sector size" of an image file.
m_CreatePartitionJob(NULL),
m_RestoreJob(NULL),
m_CheckTargetJob(NULL),
m_MaximizeJob(NULL)
m_CreatePartitionJob(nullptr),
m_RestoreJob(nullptr),
m_CheckTargetJob(nullptr),
m_MaximizeJob(nullptr)
{
restorePartition().setState(Partition::StateRestore);
@ -66,7 +66,7 @@ RestoreOperation::RestoreOperation(Device& d, Partition* p, const QString& filen
Q_ASSERT(dest);
if (dest == NULL)
if (dest == nullptr)
qWarning() << "destination partition not found at sector " << restorePartition().firstSector();
if (dest && !dest->roles().has(PartitionRole::Unallocated)) {
@ -178,17 +178,17 @@ void RestoreOperation::cleanupOverwrittenPartition()
{
if (mustDeleteOverwritten()) {
delete overwrittenPartition();
m_OverwrittenPartition = NULL;
m_OverwrittenPartition = nullptr;
}
}
/** Can a Partition be restored to somewhere?
@param p the Partition in question, may be NULL.
@param p the Partition in question, may be nullptr.
@return true if a Partition can be restored to @p p.
*/
bool RestoreOperation::canRestore(const Partition* p)
{
if (p == NULL)
if (p == nullptr)
return false;
if (p->isMounted())
@ -215,7 +215,7 @@ Partition* RestoreOperation::createRestorePartition(const Device& device, Partit
QFileInfo fileInfo(filename);
if (!fileInfo.exists())
return NULL;
return nullptr;
const qint64 end = start + fileInfo.size() / device.logicalSectorSize() - 1;
Partition* p = new Partition(&parent, device, PartitionRole(r), FileSystemFactory::create(FileSystem::Unknown, start, end), start, end, QString());

View File

@ -72,9 +72,9 @@ CoreBackendDevice* DummyBackend::openDevice(const QString& device_node)
{
DummyDevice* device = new DummyDevice(device_node);
if (device == NULL || !device->open()) {
if (device == nullptr || !device->open()) {
delete device;
device = NULL;
device = nullptr;
}
return device;
@ -84,9 +84,9 @@ CoreBackendDevice* DummyBackend::openDeviceExclusive(const QString& device_node)
{
DummyDevice* device = new DummyDevice(device_node);
if (device == NULL || !device->openExclusive()) {
if (device == nullptr || !device->openExclusive()) {
delete device;
device = NULL;
device = nullptr;
}
return device;

View File

@ -51,9 +51,9 @@ CoreBackendPartitionTable* DummyDevice::openPartitionTable()
{
CoreBackendPartitionTable* ptable = new DummyPartitionTable();
if (ptable == NULL || !ptable->open()) {
if (ptable == nullptr || !ptable->open()) {
delete ptable;
ptable = NULL;
ptable = nullptr;
}
return ptable;

View File

@ -299,7 +299,7 @@ void LibPartedBackend::scanDevicePartitions(PedDevice*, Device& d, PedDisk* pedD
Q_ASSERT(pedDisk);
Q_ASSERT(d.partitionTable());
PedPartition* pedPartition = NULL;
PedPartition* pedPartition = nullptr;
KMountPoint::List mountPoints = KMountPoint::currentMountPoints(KMountPoint::NeedRealDeviceName);
mountPoints.append(KMountPoint::possibleMountPoints(KMountPoint::NeedRealDeviceName));
@ -335,7 +335,7 @@ void LibPartedBackend::scanDevicePartitions(PedDevice*, Device& d, PedDisk* pedD
PartitionNode* parent = d.partitionTable()->findPartitionBySector(pedPartition->geom.start, PartitionRole(PartitionRole::Extended));
// None found, so it's a primary in the device's partition table.
if (parent == NULL)
if (parent == nullptr)
parent = d.partitionTable();
const QString node = QString::fromUtf8(ped_partition_get_path(pedPartition));
@ -385,9 +385,9 @@ Device* LibPartedBackend::scanDevice(const QString& device_node)
{
PedDevice* pedDevice = ped_device_get(device_node.toLocal8Bit().constData());
if (pedDevice == NULL) {
if (pedDevice == nullptr) {
Log(Log::warning) << xi18nc("@info/plain", "Could not access device <filename>%1</filename>", device_node);
return NULL;
return nullptr;
}
Log(Log::information) << i18nc("@info/plain", "Device found: %1", QString::fromUtf8(pedDevice->model));
@ -412,7 +412,7 @@ QList<Device*> LibPartedBackend::scanDevices()
QList<Device*> result;
ped_device_probe_all();
PedDevice* pedDevice = NULL;
PedDevice* pedDevice = nullptr;
QVector<QString> path;
quint32 totalDevices = 0;
while (true) {
@ -438,9 +438,9 @@ CoreBackendDevice* LibPartedBackend::openDevice(const QString& device_node)
{
LibPartedDevice* device = new LibPartedDevice(device_node);
if (device == NULL || !device->open()) {
if (device == nullptr || !device->open()) {
delete device;
device = NULL;
device = nullptr;
}
return device;
@ -450,9 +450,9 @@ CoreBackendDevice* LibPartedBackend::openDeviceExclusive(const QString& device_n
{
LibPartedDevice* device = new LibPartedDevice(device_node);
if (device == NULL || !device->openExclusive()) {
if (device == nullptr || !device->openExclusive()) {
delete device;
device = NULL;
device = nullptr;
}
return device;
@ -464,8 +464,8 @@ bool LibPartedBackend::closeDevice(CoreBackendDevice* core_device)
}
/** Detects the type of a FileSystem given a PedDevice and a PedPartition
@param pedDevice pointer to the pedDevice. Must not be NULL.
@param pedPartition pointer to the pedPartition. Must not be NULL
@param pedDevice pointer to the pedDevice. Must not be nullptr.
@param pedPartition pointer to the pedPartition. Must not be nullptr
@return the detected FileSystem type (FileSystem::Unknown if not detected)
*/
FileSystem::Type LibPartedBackend::detectFileSystem(PedPartition* pedPartition)
@ -473,12 +473,12 @@ FileSystem::Type LibPartedBackend::detectFileSystem(PedPartition* pedPartition)
FileSystem::Type rval = FileSystem::Unknown;
blkid_cache cache;
char* pedPath = NULL;
char* pedPath = nullptr;
if (blkid_get_cache(&cache, NULL) == 0 && (pedPath = ped_partition_get_path(pedPartition))) {
if (blkid_get_cache(&cache, nullptr) == 0 && (pedPath = ped_partition_get_path(pedPartition))) {
blkid_dev dev;
if ((dev = blkid_get_dev(cache, pedPath, BLKID_DEV_NORMAL)) != NULL) {
if ((dev = blkid_get_dev(cache, pedPath, BLKID_DEV_NORMAL)) != nullptr) {
QString s = QString::fromUtf8(blkid_get_tag_value(cache, "TYPE", pedPath));
if (s == QStringLiteral("ext2")) rval = FileSystem::Ext2;
@ -493,7 +493,7 @@ FileSystem::Type LibPartedBackend::detectFileSystem(PedPartition* pedPartition)
else if (s == QStringLiteral("hfs")) rval = FileSystem::Hfs;
else if (s == QStringLiteral("hfsplus")) rval = FileSystem::HfsPlus;
else if (s == QStringLiteral("ufs")) rval = FileSystem::Ufs;
else if (s == QStringLiteral("vfat") && pedPartition->fs_type != NULL) {
else if (s == QStringLiteral("vfat") && pedPartition->fs_type != nullptr) {
// libblkid does not distinguish between fat16 and fat32, so we're still using libparted
// for those
if (strcmp(pedPartition->fs_type->name, "fat16") == 0)

View File

@ -29,7 +29,7 @@
LibPartedDevice::LibPartedDevice(const QString& device_node) :
CoreBackendDevice(device_node),
m_PedDevice(NULL)
m_PedDevice(nullptr)
{
}
@ -41,14 +41,14 @@ LibPartedDevice::~LibPartedDevice()
bool LibPartedDevice::open()
{
Q_ASSERT(pedDevice() == NULL);
Q_ASSERT(pedDevice() == nullptr);
if (pedDevice())
return false;
m_PedDevice = ped_device_get(deviceNode().toLatin1().constData());
return m_PedDevice != NULL;
return m_PedDevice != nullptr;
}
bool LibPartedDevice::openExclusive()
@ -70,7 +70,7 @@ bool LibPartedDevice::close()
setExclusive(false);
}
m_PedDevice = NULL;
m_PedDevice = nullptr;
return true;
}
@ -78,9 +78,9 @@ CoreBackendPartitionTable* LibPartedDevice::openPartitionTable()
{
CoreBackendPartitionTable* ptable = new LibPartedPartitionTable(pedDevice());
if (ptable == NULL || !ptable->open()) {
if (ptable == nullptr || !ptable->open()) {
delete ptable;
ptable = NULL;
ptable = nullptr;
}
return ptable;
@ -90,21 +90,21 @@ bool LibPartedDevice::createPartitionTable(Report& report, const PartitionTable&
{
PedDiskType* pedDiskType = ped_disk_type_get(ptable.typeName().toLatin1().constData());
if (pedDiskType == NULL) {
if (pedDiskType == nullptr) {
report.line() << xi18nc("@info/plain", "Creating partition table failed: Could not retrieve partition table type \"%1\" for <filename>%2</filename>.", ptable.typeName(), deviceNode());
return false;
}
PedDevice* dev = ped_device_get(deviceNode().toLatin1().constData());
if (dev == NULL) {
if (dev == nullptr) {
report.line() << xi18nc("@info/plain", "Creating partition table failed: Could not open backend device <filename>%1</filename>.", deviceNode());
return false;
}
PedDisk* disk = ped_disk_new_fresh(dev, pedDiskType);
if (disk == NULL) {
if (disk == nullptr) {
report.line() << xi18nc("@info/plain", "Creating partition table failed: Could not create a new partition table in the backend for device <filename>%1</filename>.", deviceNode());
return false;
}

View File

@ -30,7 +30,7 @@ LibPartedPartition::LibPartedPartition(PedPartition* ped_partition) :
bool LibPartedPartition::setFlag(Report& report, PartitionTable::Flag partitionManagerFlag, bool state)
{
Q_ASSERT(pedPartition() != NULL);
Q_ASSERT(pedPartition() != nullptr);
const PedPartitionFlag f = LibPartedBackend::getPedFlag(partitionManagerFlag);

View File

@ -37,13 +37,13 @@
LibPartedPartitionTable::LibPartedPartitionTable(PedDevice* device) :
CoreBackendPartitionTable(),
m_PedDevice(device),
m_PedDisk(NULL)
m_PedDisk(nullptr)
{
}
LibPartedPartitionTable::~LibPartedPartitionTable()
{
if (m_PedDisk != NULL)
if (m_PedDisk != nullptr)
ped_disk_destroy(m_PedDisk);
}
@ -51,7 +51,7 @@ bool LibPartedPartitionTable::open()
{
m_PedDisk = ped_disk_new(pedDevice());
return m_PedDisk != NULL;
return m_PedDisk != nullptr;
}
bool LibPartedPartitionTable::commit(quint32 timeout)
@ -61,7 +61,7 @@ bool LibPartedPartitionTable::commit(quint32 timeout)
bool LibPartedPartitionTable::commit(PedDisk* pd, quint32 timeout)
{
if (pd == NULL)
if (pd == nullptr)
return false;
bool rval = ped_disk_commit_to_dev(pd);
@ -91,8 +91,8 @@ CoreBackendPartition* LibPartedPartitionTable::getExtendedPartition()
{
PedPartition* pedPartition = ped_disk_extended_partition(pedDisk());
if (pedPartition == NULL)
return NULL;
if (pedPartition == nullptr)
return nullptr;
return new LibPartedPartition(pedPartition);
}
@ -101,8 +101,8 @@ CoreBackendPartition* LibPartedPartitionTable::getPartitionBySector(qint64 secto
{
PedPartition* pedPartition = ped_disk_get_partition_by_sector(pedDisk(), sector);
if (pedPartition == NULL)
return NULL;
if (pedPartition == nullptr)
return nullptr;
return new LibPartedPartition(pedPartition);
}
@ -146,7 +146,7 @@ QString LibPartedPartitionTable::createPartition(Report& report, const Partition
QString rval = QString();
// According to libParted docs, PedPartitionType can be "NULL if unknown". That's obviously wrong,
// According to libParted docs, PedPartitionType can be "nullptr if unknown". That's obviously wrong,
// it's a typedef for an enum. So let's use something the libparted devs will hopefully never
// use...
PedPartitionType pedType = static_cast<PedPartitionType>(0xffffffff);
@ -163,22 +163,22 @@ QString LibPartedPartitionTable::createPartition(Report& report, const Partition
return QString();
}
PedFileSystemType* pedFsType = (partition.roles().has(PartitionRole::Extended) || partition.fileSystem().type() == FileSystem::Unformatted) ? NULL : getPedFileSystemType(partition.fileSystem().type());
PedFileSystemType* pedFsType = (partition.roles().has(PartitionRole::Extended) || partition.fileSystem().type() == FileSystem::Unformatted) ? nullptr : getPedFileSystemType(partition.fileSystem().type());
PedPartition* pedPartition = ped_partition_new(pedDisk(), pedType, pedFsType, partition.firstSector(), partition.lastSector());
if (pedPartition == NULL) {
if (pedPartition == nullptr) {
report.line() << xi18nc("@info/plain", "Failed to create new partition <filename>%1</filename>.", partition.deviceNode());
return QString();
}
PedConstraint* pedConstraint = NULL;
PedConstraint* pedConstraint = nullptr;
PedGeometry* pedGeometry = ped_geometry_new(pedDevice(), partition.firstSector(), partition.length());
if (pedGeometry)
pedConstraint = ped_constraint_exact(pedGeometry);
if (pedConstraint == NULL) {
if (pedConstraint == nullptr) {
report.line() << i18nc("@info/plain", "Failed to create a new partition: could not get geometry for constraint.");
return QString();
}
@ -281,7 +281,7 @@ bool LibPartedPartitionTable::resizeFileSystem(Report& report, const Partition&
if (PedGeometry* originalGeometry = ped_geometry_new(pedDevice(), partition.fileSystem().firstSector(), partition.fileSystem().length())) {
if (PedFileSystem* pedFileSystem = ped_file_system_open(originalGeometry)) {
if (PedGeometry* resizedGeometry = ped_geometry_new(pedDevice(), partition.fileSystem().firstSector(), newLength)) {
PedTimer* pedTimer = ped_timer_new(pedTimerHandler, NULL);
PedTimer* pedTimer = ped_timer_new(pedTimerHandler, nullptr);
rval = ped_file_system_resize(pedFileSystem, resizedGeometry, pedTimer);
ped_timer_destroy(pedTimer);
@ -320,15 +320,15 @@ FileSystem::Type LibPartedPartitionTable::detectFileSystemBySector(Report& repor
bool LibPartedPartitionTable::setPartitionSystemType(Report& report, const Partition& partition)
{
PedFileSystemType* pedFsType = (partition.roles().has(PartitionRole::Extended) || partition.fileSystem().type() == FileSystem::Unformatted) ? NULL : getPedFileSystemType(partition.fileSystem().type());
if (pedFsType == NULL) {
PedFileSystemType* pedFsType = (partition.roles().has(PartitionRole::Extended) || partition.fileSystem().type() == FileSystem::Unformatted) ? nullptr : getPedFileSystemType(partition.fileSystem().type());
if (pedFsType == nullptr) {
report.line() << xi18nc("@info/plain", "Could not update the system type for partition <filename>%1</filename>.", partition.deviceNode());
report.line() << xi18nc("@info/plain", "No file system defined.");
return false;
}
PedPartition* pedPartition = ped_disk_get_partition_by_sector(pedDisk(), partition.firstSector());
if (pedPartition == NULL) {
if (pedPartition == nullptr) {
report.line() << xi18nc("@info/plain", "Could not update the system type for partition <filename>%1</filename>.", partition.deviceNode());
report.line() << xi18nc("@info/plain", "No partition found at sector %1.", partition.firstSector());
return false;

View File

@ -31,7 +31,7 @@
@param args the arguments to pass to the command
*/
ExternalCommand::ExternalCommand(const QString& cmd, const QStringList& args) :
m_Report(NULL),
m_Report(nullptr),
m_ExitCode(-1),
m_Output()
{
@ -60,7 +60,7 @@ ExternalCommand::ExternalCommand(Report& report, const QString& cmd, const QStri
@param args the vector of the arguments to pass to the commands
*/
ExternalCommand::ExternalCommand(const std::vector<QString> cmd, const std::vector<QStringList> args) :
m_Report(NULL),
m_Report(nullptr),
m_Command(cmd),
m_Args(args),
m_ExitCode(-1),

View File

@ -83,7 +83,7 @@ public:
}
Report* report() {
return m_Report; /**< @return pointer to the Report or NULL */
return m_Report; /**< @return pointer to the Report or nullptr */
}
protected:

View File

@ -19,9 +19,9 @@
GlobalLog* GlobalLog::instance()
{
static GlobalLog* p = NULL;
static GlobalLog* p = nullptr;
if (p == NULL)
if (p == nullptr)
p = new GlobalLog();
return p;

View File

@ -59,7 +59,7 @@ void showColumnsContextMenu(const QPoint& p, QTreeWidget& tree)
QAction* action = headerMenu.exec(tree.header()->mapToGlobal(p));
if (action != NULL) {
if (action != nullptr) {
const bool hidden = !action->isChecked();
tree.setColumnHidden(action->data().toInt(), hidden);
if (!hidden)

View File

@ -27,7 +27,7 @@
#include <unistd.h>
/** Creates a new Report instance.
@param p pointer to the parent instance. May be NULL ig this is a new root Report.
@param p pointer to the parent instance. May be nullptr ig this is a new root Report.
@param cmd the command
*/
Report::Report(Report* p, const QString& cmd) :
@ -67,7 +67,7 @@ QString Report::toHtml() const
if (parent() == root())
s += QStringLiteral("<div>\n");
else if (parent() != NULL)
else if (parent() != nullptr)
s += QStringLiteral("<div style='margin-left:24px;margin-top:12px;margin-bottom:12px'>\n");
if (!command().isEmpty())
@ -85,7 +85,7 @@ QString Report::toHtml() const
if (!status().isEmpty())
s += QStringLiteral("<b>") + status().toHtmlEscaped() + QStringLiteral("</b><br/>\n\n");
if (parent() != NULL)
if (parent() != nullptr)
s += QStringLiteral("</div>\n\n");
return s;
@ -138,7 +138,7 @@ Report* Report::root()
{
Report* rval = this;
while (rval->parent() != NULL)
while (rval->parent() != nullptr)
rval = rval->parent();
return rval;
@ -151,7 +151,7 @@ const Report* Report::root() const
{
const Report* rval = this;
while (rval->parent() != NULL)
while (rval->parent() != nullptr)
rval = rval->parent();
return rval;

View File

@ -57,10 +57,10 @@ public:
}
Report* parent() {
return m_Parent; /**< @return pointer to this Reports parent. May be NULL if this is the root Report */
return m_Parent; /**< @return pointer to this Reports parent. May be nullptr if this is the root Report */
}
const Report* parent() const {
return m_Parent; /**< @return pointer to this Reports parent. May be NULL if this is the root Report */
return m_Parent; /**< @return pointer to this Reports parent. May be nullptr if this is the root Report */
}
Report* root();