Commit 17b23428 authored by Kevin Funk's avatar Kevin Funk

Modernize: Use nullptr where possible

parent ea4f6702
......@@ -56,7 +56,7 @@ SensorAgent::~SensorAgent()
void SensorAgent::sendRequest( const QString &req, SensorClient *client, int id )
{
SensorRequest *sensorreq = 0;
SensorRequest *sensorreq = nullptr;
for(int i =0; i < mInputFIFO.size(); ++i) {
sensorreq = mInputFIFO.at(i);
if(id == sensorreq->id() && client == sensorreq->client() && req == sensorreq->request()) {
......@@ -226,10 +226,10 @@ void SensorAgent::disconnectClient( SensorClient *client )
{
for (int i = 0; i < mInputFIFO.size(); ++i)
if ( mInputFIFO[i]->client() == client )
mInputFIFO[i]->setClient(0);
mInputFIFO[i]->setClient(nullptr);
for (int i = 0; i < mProcessingFIFO.size(); ++i)
if ( mProcessingFIFO[i]->client() == client )
mProcessingFIFO[i]->setClient( 0 );
mProcessingFIFO[i]->setClient( nullptr );
}
......
......@@ -254,7 +254,7 @@ void SensorManager::retranslate()
mTypes.insert( QStringLiteral( "listview" ), i18n( "Table" ) );
mTypes.insert( QStringLiteral( "logfile" ), i18n( "Log File") );
mBroadcaster = NULL;
mBroadcaster = nullptr;
}
......@@ -266,7 +266,7 @@ bool SensorManager::engage( const QString &hostName, const QString &shell,
const QString &command, int port )
{
if ( !mAgents.contains( hostName ) ) {
SensorAgent *agent = 0;
SensorAgent *agent = nullptr;
if ( port == -1 )
......
......@@ -62,7 +62,7 @@ class Q_DECL_EXPORT SensorManager : public QObject
QString mMessage;
};
explicit SensorManager(QObject * parent = 0);
explicit SensorManager(QObject * parent = nullptr);
~SensorManager() override;
/*! Number of hosts connected to */
......
......@@ -35,7 +35,7 @@
using namespace KSGRD;
SensorShellAgent::SensorShellAgent( SensorManager *sm )
: SensorAgent( sm ), mDaemon( 0 )
: SensorAgent( sm ), mDaemon( nullptr )
{
}
......@@ -46,7 +46,7 @@ SensorShellAgent::~SensorShellAgent()
mDaemon->disconnect();
mDaemon->waitForFinished();
delete mDaemon;
mDaemon = 0;
mDaemon = nullptr;
}
}
......
......@@ -56,7 +56,7 @@ void KLsofWidget::finished ( int exitCode, QProcess::ExitStatus exitStatus )
Q_UNUSED(exitStatus);
char buf[1024];
QTreeWidgetItem *process = NULL;
QTreeWidgetItem *process = nullptr;
while(true) {
qint64 lineLength = d->process->readLine(buf, sizeof(buf));
......
......@@ -32,7 +32,7 @@ class Q_DECL_EXPORT KLsofWidget : public QTreeWidget {
Q_OBJECT
Q_PROPERTY( qlonglong pid READ pid WRITE setPid )
public:
KLsofWidget(QWidget *parent = NULL);
KLsofWidget(QWidget *parent = nullptr);
~KLsofWidget() override;
bool update();
......
......@@ -45,13 +45,13 @@ namespace KSysGuard
public:
Private(Processes *q_ptr) {
mFakeProcess.setParent(&mFakeProcess);
mAbstractProcesses = 0;
mHistoricProcesses = 0;
mAbstractProcesses = nullptr;
mHistoricProcesses = nullptr;
mIsLocalHost = true;
mProcesses.insert(-1, &mFakeProcess);
mElapsedTimeMilliSeconds = 0;
mHavePreviousIoValues = false;
mUpdateFlags = 0;
mUpdateFlags = nullptr;
mUsingHistoricalData = false;
q = q_ptr;
}
......@@ -87,7 +87,7 @@ Processes::Private::~Private() {
mProcesses.clear();
mListProcesses.clear();
delete mAbstractProcesses;
mAbstractProcesses = NULL;
mAbstractProcesses = nullptr;
}
Processes::Processes(const QString &host, QObject *parent) : QObject(parent), d(new Private(this))
......@@ -480,7 +480,7 @@ void Processes::useCurrentData()
{
if(d->mUsingHistoricalData) {
delete d->mHistoricProcesses;
d->mHistoricProcesses = NULL;
d->mHistoricProcesses = nullptr;
connect( d->mAbstractProcesses, &AbstractProcesses::processesUpdated, this, &Processes::processesUpdated);
d->mUsingHistoricalData = false;
}
......
......@@ -58,7 +58,7 @@ namespace KSysGuard
public:
Processes(const QString &hostname = QString::null, QObject * parent = 0);
Processes(const QString &hostname = QString::null, QObject * parent = nullptr);
~Processes() override;
enum UpdateFlag {
StandardInformation = 1,
......@@ -84,7 +84,7 @@ namespace KSysGuard
* For example, if you update every 2000ms, set this to 2000. That way it won't update
* more often than needed.
*/
void updateAllProcesses(long updateDurationMS = 0, Processes::UpdateFlags updateFlags = 0);
void updateAllProcesses(long updateDurationMS = 0, Processes::UpdateFlags updateFlags = nullptr);
/**
* Return information for one specific process. Call getProcess(0) to get the
......
......@@ -63,7 +63,7 @@ namespace KSysGuard
ProcessesATop::Private::Private() :
ready(false),
pstats(NULL),
pstats(nullptr),
currentlySelectedIndex(-1)
{
}
......@@ -138,7 +138,7 @@ bool ProcessesATop::Private::loadHistoryFile(const QString &filename) {
bool ProcessesATop::Private::loadDataForHistory(int index)
{
delete [] pstats;
pstats = NULL;
pstats = nullptr;
atopLog.seek(historyOffsets.at(index));
/*Read the first data header */
if( atopLog.read((char*)(&rr), sizeof(RawRecord)) != sizeof(RawRecord) ) {
......@@ -188,7 +188,7 @@ bool ProcessesATop::Private::loadDataForHistory(int index)
break;
}
delete [] pstats;
pstats = NULL;
pstats = nullptr;
return false;
}
......
......@@ -527,7 +527,7 @@ bool ProcessesLocal::updateProcessInfo( long pid, Process *process)
QSet<long> ProcessesLocal::getAllPids( )
{
QSet<long> pids;
if(d->mProcDir==NULL) return pids; //There's not much we can do without /proc
if(d->mProcDir==nullptr) return pids; //There's not much we can do without /proc
struct dirent* entry;
rewinddir(d->mProcDir);
while ( ( entry = readdir( d->mProcDir ) ) )
......
......@@ -47,7 +47,7 @@ bool ProcessFilter::filterAcceptsRow( int source_row, const QModelIndex & source
}
process = model->getProcessAtIndex(source_row);
} else {
KSysGuard::Process *parent_process = NULL;
KSysGuard::Process *parent_process = nullptr;
if(source_parent.isValid()) {
parent_process = reinterpret_cast<KSysGuard::Process *>(source_parent.internalPointer());
Q_ASSERT(parent_process);
......
......@@ -44,7 +44,7 @@ class KSYSGUARD_EXPORT ProcessFilter : public QSortFilterProxyModel
public:
enum State {AllProcesses=0,AllProcessesInTreeForm, SystemProcesses, UserProcesses, OwnProcesses, ProgramsOnly};
ProcessFilter(QObject *parent=0) : QSortFilterProxyModel(parent) {mFilter = AllProcesses;}
ProcessFilter(QObject *parent=nullptr) : QSortFilterProxyModel(parent) {mFilter = AllProcesses;}
~ProcessFilter() override {}
bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;
State filter() const {return mFilter; }
......
......@@ -113,7 +113,7 @@ ProcessModelPrivate::ProcessModelPrivate() : mBlankPixmap(HEADING_X_ICON_SIZE,1
mIsLocalhost = true;
mMemTotal = -1;
mNumProcessorCores = 1;
mProcesses = NULL;
mProcesses = nullptr;
mShowChildTotals = true;
mShowCommandLineOptions = false;
mShowingTooltips = true;
......@@ -140,7 +140,7 @@ ProcessModelPrivate::~ProcessModelPrivate()
qDeleteAll(mPidToWindowInfo);
#endif
delete mProcesses;
mProcesses = NULL;
mProcesses = nullptr;
}
ProcessModel::ProcessModel(QObject* parent, const QString &host)
......@@ -482,7 +482,7 @@ void ProcessModelPrivate::setupProcesses() {
mPidToWindowInfo.clear();
#endif
delete mProcesses;
mProcesses = 0;
mProcesses = nullptr;
q->beginResetModel();
q->endResetModel();
}
......@@ -679,7 +679,7 @@ QModelIndex ProcessModel::index ( int row, int column, const QModelIndex & paren
}
//Deal with the case that we are showing it as a tree
KSysGuard::Process *parent_process = 0;
KSysGuard::Process *parent_process = nullptr;
if(parent.isValid()) //not valid for init or children without parents, so use our special item with pid of 0
parent_process = reinterpret_cast< KSysGuard::Process * > (parent.internalPointer());
......
......@@ -49,7 +49,7 @@ class KSYSGUARD_EXPORT ProcessModel : public QAbstractItemModel
Q_ENUMS(Units)
public:
ProcessModel(QObject* parent = 0, const QString &host = QString() );
ProcessModel(QObject* parent = nullptr, const QString &host = QString() );
~ProcessModel() override;
/* Functions for our Model for QAbstractItemModel*/
......
......@@ -150,9 +150,9 @@ class ProgressBarItemDelegate : public QStyledItemDelegate
struct KSysGuardProcessListPrivate {
KSysGuardProcessListPrivate(KSysGuardProcessList* q, const QString &hostName)
: mModel(q, hostName), mFilterModel(q), mUi(new Ui::ProcessWidget()), mProcessContextMenu(NULL), mUpdateTimer(NULL)
: mModel(q, hostName), mFilterModel(q), mUi(new Ui::ProcessWidget()), mProcessContextMenu(nullptr), mUpdateTimer(nullptr)
{
mScripting = NULL;
mScripting = nullptr;
mNeedToExpandInit = false;
mNumItemsSelected = -1;
mResortCountDown = 2; //The items added initially will be already sorted, but without CPU info. On the second refresh we will have CPU usage, so /then/ we can resort
......@@ -184,7 +184,7 @@ struct KSysGuardProcessListPrivate {
jumpToSearchFilter->setShortcuts(QList<QKeySequence>() << QKeySequence::Find << '/');
}
~KSysGuardProcessListPrivate() { delete mUi; mUi = NULL; }
~KSysGuardProcessListPrivate() { delete mUi; mUi = nullptr; }
/** The number rows and their children for the given parent in the mFilterModel model */
int totalRowCount(const QModelIndex &parent) const;
......@@ -508,7 +508,7 @@ void KSysGuardProcessList::actionTriggered(QObject *object) {
//Reset the text back to normal
d->selectParent->setText(i18n("Jump to Parent Process"));
QAction *result = qobject_cast<QAction *>(object);
if(result == 0) {
if(result == nullptr) {
//Escape was pressed. Do nothing.
} else if(result == d->renice) {
reniceSelectedProcesses();
......@@ -629,19 +629,19 @@ void KSysGuardProcessList::showColumnContextMenu(const QPoint &point){
}
}
}
QAction *actionAuto = NULL;
QAction *actionKB = NULL;
QAction *actionMB = NULL;
QAction *actionGB = NULL;
QAction *actionPercentage = NULL;
QAction *actionShowCmdlineOptions = NULL;
QAction *actionShowTooltips = NULL;
QAction *actionNormalizeCPUUsage = NULL;
QAction *actionIoCharacters = NULL;
QAction *actionIoSyscalls = NULL;
QAction *actionIoActualCharacters = NULL;
QAction *actionIoShowRate = NULL;
QAction *actionAuto = nullptr;
QAction *actionKB = nullptr;
QAction *actionMB = nullptr;
QAction *actionGB = nullptr;
QAction *actionPercentage = nullptr;
QAction *actionShowCmdlineOptions = nullptr;
QAction *actionShowTooltips = nullptr;
QAction *actionNormalizeCPUUsage = nullptr;
QAction *actionIoCharacters = nullptr;
QAction *actionIoSyscalls = nullptr;
QAction *actionIoActualCharacters = nullptr;
QAction *actionIoShowRate = nullptr;
bool showIoRate = false;
if(index == ProcessModel::HeadingIoRead || index == ProcessModel::HeadingIoWrite)
showIoRate = d->mModel.ioInformation() == ProcessModel::BytesRate ||
......@@ -995,7 +995,7 @@ void KSysGuardProcessList::setUpdateIntervalMSecs(int intervalMSecs)
d->mUpdateIntervalMSecs = intervalMSecs;
if(intervalMSecs <= 0) { //no point keep the timer around if we aren't updating automatically
delete d->mUpdateTimer;
d->mUpdateTimer = NULL;
d->mUpdateTimer = nullptr;
return;
}
......@@ -1464,7 +1464,7 @@ void KSysGuardProcessList::setScriptingEnabled(bool enabled)
return; //Nothing changed
if(!enabled) {
delete d->mScripting;
d->mScripting = NULL;
d->mScripting = nullptr;
} else {
d->mScripting = new Scripting(this);
d->mScripting->hide();
......
......@@ -59,7 +59,7 @@ class Q_DECL_EXPORT KSysGuardProcessList : public QWidget
Q_ENUMS( ProcessModel::Units )
public:
KSysGuardProcessList(QWidget* parent = NULL, const QString &hostName = QString());
KSysGuardProcessList(QWidget* parent = nullptr, const QString &hostName = QString());
~KSysGuardProcessList() override;
QLineEdit *filterLineEdit() const;
......
......@@ -67,7 +67,7 @@ class ScriptingHtmlDialog : public QDialog {
m_webView.settings()->setObjectCacheCapacities(0,0,0);
m_webView.settings()->setAttribute(QWebSettings::PluginsEnabled, false);
m_webView.settings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, false);
m_webView.page()->setNetworkAccessManager(NULL); //Disable talking to remote servers
m_webView.page()->setNetworkAccessManager(nullptr); //Disable talking to remote servers
m_webView.page()->mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAsNeeded);
m_webView.page()->mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAsNeeded);
......@@ -119,7 +119,7 @@ QString ProcessObject::readFile(const QString &filename)
}
Scripting::Scripting(KSysGuardProcessList * parent) : QWidget(parent), mProcessList(parent) {
mScriptingHtmlDialog = NULL;
mScriptingHtmlDialog = nullptr;
loadContextMenu();
}
void Scripting::runScript(const QString &path, const QString &name) {
......@@ -183,8 +183,8 @@ void Scripting::stopAllScripts()
{
if (mScriptingHtmlDialog)
mScriptingHtmlDialog->deleteLater();
mScriptingHtmlDialog = NULL;
mProcessObject = NULL;
mScriptingHtmlDialog = nullptr;
mProcessObject = nullptr;
mScriptPath.clear();
mScriptName.clear();
}
......
......@@ -89,7 +89,7 @@ class Q_DECL_EXPORT KGraphicsSignalPlotter : public QGraphicsWidget
Q_PROPERTY(int fillOpacity READ fillOpacity WRITE setFillOpacity)
public:
KGraphicsSignalPlotter( QGraphicsItem *parent = 0);
KGraphicsSignalPlotter( QGraphicsItem *parent = nullptr);
~KGraphicsSignalPlotter() override;
/** \brief Add a new line to the graph plotter, with the specified color.
......@@ -448,7 +448,7 @@ class Q_DECL_EXPORT KGraphicsSignalPlotter : public QGraphicsWidget
protected:
/* Reimplemented */
void resizeEvent( QGraphicsSceneResizeEvent* event ) override;
void paint( QPainter * p, const QStyleOptionGraphicsItem * option, QWidget * widget = 0 ) override;
void paint( QPainter * p, const QStyleOptionGraphicsItem * option, QWidget * widget = nullptr ) override;
QSizeF sizeHint( Qt::SizeHint which, const QSizeF & constraint = QSizeF() ) const override;
void changeEvent ( QEvent * event ) override;
QPainterPath opaqueArea() const override;
......
......@@ -91,7 +91,7 @@ class Q_DECL_EXPORT KSignalPlotter : public QWidget
Q_PROPERTY(int fillOpacity READ fillOpacity WRITE setFillOpacity)
public:
KSignalPlotter( QWidget *parent = 0);
KSignalPlotter( QWidget *parent = nullptr);
~KSignalPlotter() override;
/** \brief Add a new line to the graph plotter, with the specified color.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment