Commit e492f184 authored by Rolf Eike Beer's avatar Rolf Eike Beer
Browse files

add some possible compiler safety guards

By default this does nothing, as these things are not defined in Qt4. They get
defined in Qt5 or when one explicitely sets them to the right values.
parent aad35095
......@@ -138,6 +138,7 @@ set(kgpg_HDRS
keytreeview.h
kgpg.h
kgpgchangekey.h
kgpgcompiler.h
kgpgexternalactions.h
kgpgfirstassistant.h
kgpginterface.h
......
......@@ -233,7 +233,7 @@ KGpgCaffPrivate::slotSigningFinished(int result)
int index = 1;
removeMode = KGpgDelUid::RemoveAllOther;
while ( (otherUid = key->getUid(index++)) != NULL) {
while ( (otherUid = key->getUid(index++)) != Q_NULLPTR) {
if (otherUid == uid) {
removeMode = KGpgDelUid::RemoveWithEmail;
break;
......@@ -302,7 +302,7 @@ KGpgCaffPrivate::slotExportFinished(int result)
const KGpgKeyNode *key = uid->getKeyNode();
KGpgExport *exp = qobject_cast<KGpgExport *>(sender());
Q_ASSERT(exp != NULL);
Q_ASSERT(exp != Q_NULLPTR);
QString body = KGpgSettings::emailTemplate();
body.replace(QLatin1Char( '%' ) + i18nc("Email template placeholder for key id", "KEYID") + QLatin1Char( '%' ), key->getId());
......@@ -329,7 +329,7 @@ KGpgCaffPrivate::slotTextEncrypted(int result)
switch (result) {
case KGpgTransaction::TS_OK: {
KGpgEncrypt *enc = qobject_cast<KGpgEncrypt *>(sender());
Q_ASSERT(enc != NULL);
Q_ASSERT(enc != Q_NULLPTR);
const QString text = enc->encryptedText().join(QLatin1String("\n"));
......
......@@ -17,15 +17,15 @@
#ifndef CONF_ENCRYPTION_H
#define CONF_ENCRYPTION_H
#include <kgpgcompiler.h>
#include "ui_conf_encryption.h"
class Encryption : public QWidget, public Ui_Encryption
{
Q_OBJECT
public:
explicit Encryption( QWidget* parent = 0 );
explicit Encryption(QWidget* parent = Q_NULLPTR);
public slots:
virtual void encrypt_to_always_toggled( bool );
......
......@@ -27,7 +27,7 @@
KGpgExpandableNode::KGpgExpandableNode(KGpgExpandableNode *parent)
: KGpgNode(parent)
{
if (parent != NULL)
if (parent != Q_NULLPTR)
parent->children.append(this);
}
......@@ -41,7 +41,7 @@ KGpgNode *
KGpgExpandableNode::getChild(const int index) const
{
if ((index < 0) || (index > children.count()))
return NULL;
return Q_NULLPTR;
return children.at(index);
}
......
......@@ -49,7 +49,7 @@ protected:
*/
virtual void readChildren() = 0;
explicit KGpgExpandableNode(KGpgExpandableNode *parent = NULL);
explicit KGpgExpandableNode(KGpgExpandableNode *parent = Q_NULLPTR);
public:
virtual ~KGpgExpandableNode();
......@@ -64,7 +64,7 @@ public:
* In contrast wasExpanded() will only return true if the child nodes
* are actually present in memory.
*/
virtual bool hasChildren() const;
virtual bool hasChildren() const Q_DECL_OVERRIDE;
/**
* check if there are any child nodes present in memory
*
......@@ -75,10 +75,10 @@ public:
* objects are not present in memory.
*/
virtual bool wasExpanded() const;
virtual int getChildCount();
virtual int getChildCount() Q_DECL_OVERRIDE;
virtual const KGpgNode::List &getChildren() const;
virtual KGpgNode *getChild(const int index) const;
virtual int getChildIndex(KGpgNode *node) const;
virtual KGpgNode *getChild(const int index) const Q_DECL_OVERRIDE;
virtual int getChildIndex(KGpgNode *node) const Q_DECL_OVERRIDE;
virtual void deleteChild(KGpgNode *child);
};
......
......@@ -40,7 +40,7 @@ KGpgGroupMemberNode::~KGpgGroupMemberNode()
KgpgKeyTrust
KGpgGroupMemberNode::getTrust() const
{
if (m_keynode != NULL)
if (m_keynode != Q_NULLPTR)
return m_keynode->getTrust();
return KgpgCore::TRUST_NOKEY;
}
......@@ -48,7 +48,7 @@ KGpgGroupMemberNode::getTrust() const
KgpgItemType
KGpgGroupMemberNode::getType() const
{
if (m_keynode != NULL)
if (m_keynode != Q_NULLPTR)
return m_keynode->getType() | KgpgCore::ITYPE_GROUP;
return KgpgCore::ITYPE_PUBLIC | KgpgCore::ITYPE_GROUP;
}
......@@ -56,7 +56,7 @@ KGpgGroupMemberNode::getType() const
QString
KGpgGroupMemberNode::getSize() const
{
if (m_keynode != NULL)
if (m_keynode != Q_NULLPTR)
return m_keynode->getSize();
return QString();
}
......@@ -64,7 +64,7 @@ KGpgGroupMemberNode::getSize() const
QDateTime
KGpgGroupMemberNode::getExpiration() const
{
if (m_keynode != NULL)
if (m_keynode != Q_NULLPTR)
return m_keynode->getExpiration();
return QDateTime();
}
......@@ -72,7 +72,7 @@ KGpgGroupMemberNode::getExpiration() const
QDateTime
KGpgGroupMemberNode::getCreation() const
{
if (m_keynode != NULL)
if (m_keynode != Q_NULLPTR)
return m_keynode->getCreation();
return QDateTime();
}
......@@ -80,7 +80,7 @@ KGpgGroupMemberNode::getCreation() const
unsigned int
KGpgGroupMemberNode::getSignKeySize() const
{
if (m_keynode != NULL)
if (m_keynode != Q_NULLPTR)
return m_keynode->getSignKeySize();
return 0;
}
......@@ -88,7 +88,7 @@ KGpgGroupMemberNode::getSignKeySize() const
unsigned int
KGpgGroupMemberNode::getEncryptionKeySize() const
{
if (m_keynode != NULL)
if (m_keynode != Q_NULLPTR)
return m_keynode->getEncryptionKeySize();
return 0;
}
......
......@@ -39,11 +39,11 @@ public:
explicit KGpgGroupMemberNode(KGpgGroupNode *parent, KGpgKeyNode *k);
virtual ~KGpgGroupMemberNode();
virtual KgpgCore::KgpgKeyTrust getTrust() const;
virtual KgpgCore::KgpgItemType getType() const;
virtual QString getSize() const;
virtual QDateTime getExpiration() const;
virtual QDateTime getCreation() const;
virtual KgpgCore::KgpgKeyTrust getTrust() const Q_DECL_OVERRIDE;
virtual KgpgCore::KgpgItemType getType() const Q_DECL_OVERRIDE;
virtual QString getSize() const Q_DECL_OVERRIDE;
virtual QDateTime getExpiration() const Q_DECL_OVERRIDE;
virtual QDateTime getCreation() const Q_DECL_OVERRIDE;
virtual KGpgGroupNode *getParentKeyNode() const;
/**
......
......@@ -140,7 +140,7 @@ KGpgGroupNode::~KGpgGroupNode()
{
KGpgRootNode *root = m_parent->toRootNode();
if (root != NULL)
if (root != Q_NULLPTR)
root->m_groups--;
}
......
......@@ -332,7 +332,7 @@ KGpgKeyNode::getUid(const unsigned int index) const
}
}
return NULL;
return Q_NULLPTR;
}
bool
......
......@@ -132,7 +132,7 @@ public:
* @param node node that no longer has the reference
*
* Note that this must not be called as reply when this object
* emits updated(NULL)
* emits updated(Q_NULLPTR)
*/
void delRef(KGpgRefNode *node);
/**
......@@ -155,7 +155,7 @@ public:
/**
* @brief get the user id or user attribute with the given number
* @param index the index of the user id to return
* @return the requested subitem or NULL if that is not present
* @return the requested subitem or Q_NULLPTR if that is not present
*
* User ids indexes are 1-based, so 0 is not a valid index. Passing
* 1 as index will return the object itself, representing the primary
......
......@@ -32,8 +32,8 @@
KGpgNode::KGpgNode(KGpgExpandableNode *parent)
: QObject(), m_parent(parent)
{
if (parent == NULL)
m_model = NULL;
if (parent == Q_NULLPTR)
m_model = Q_NULLPTR;
else
m_model = parent->m_model;
}
......@@ -43,7 +43,7 @@ KGpgNode::~KGpgNode()
Q_ASSERT(m_model);
m_model->invalidateIndexes(this);
if (m_parent != NULL)
if (m_parent != Q_NULLPTR)
m_parent->deleteChild(this);
}
......@@ -111,7 +111,7 @@ KGpgNode::toKeyNode() const
KGpgRootNode *
KGpgNode::toRootNode()
{
Q_ASSERT((m_parent == NULL) && (getType() == 0));
Q_ASSERT((m_parent == Q_NULLPTR) && (getType() == 0));
return static_cast<KGpgRootNode *>(this)->asRootNode();
}
......@@ -119,7 +119,7 @@ KGpgNode::toRootNode()
const KGpgRootNode *
KGpgNode::toRootNode() const
{
Q_ASSERT((m_parent == NULL) && (getType() == 0));
Q_ASSERT((m_parent == Q_NULLPTR) && (getType() == 0));
return static_cast<const KGpgRootNode *>(this)->asRootNode();
}
......@@ -268,7 +268,7 @@ KGpgNode *
KGpgNode::getChild(const int index) const
{
Q_UNUSED(index);
return NULL;
return Q_NULLPTR;
}
int
......
......@@ -45,7 +45,7 @@ class KGpgNode : public QObject
friend class KGpgItemModel;
KGpgNode(); // = delete C++0x
KGpgNode() Q_DECL_EQ_DELETE;
protected:
KGpgExpandableNode *m_parent;
KGpgItemModel *m_model;
......@@ -122,8 +122,8 @@ public:
*
* For all "primary" items like keys and key groups this will
* return the (invisible) root node. Calling this function for
* the root node will return %NULL. No other node but the root
* node has a %NULL parent.
* the root node will return %Q_NULLPTR. No other node but the root
* node has a %Q_NULLPTR parent.
*/
KGpgExpandableNode *getParentKeyNode() const;
......
......@@ -39,15 +39,15 @@ public:
explicit KGpgOrphanNode(KGpgExpandableNode *parent, const KgpgKey &k);
virtual ~KGpgOrphanNode();
virtual KgpgCore::KgpgItemType getType() const;
virtual KgpgCore::KgpgKeyTrust getTrust() const;
virtual KgpgCore::KgpgItemType getType() const Q_DECL_OVERRIDE;
virtual KgpgCore::KgpgKeyTrust getTrust() const Q_DECL_OVERRIDE;
const QString &getFingerprint() const;
virtual QString getSize() const;
virtual QString getName() const;
virtual QString getEmail() const;
virtual QDateTime getExpiration() const;
virtual QDateTime getCreation() const;
virtual QString getId() const;
virtual QString getSize() const Q_DECL_OVERRIDE;
virtual QString getName() const Q_DECL_OVERRIDE;
virtual QString getEmail() const Q_DECL_OVERRIDE;
virtual QDateTime getExpiration() const Q_DECL_OVERRIDE;
virtual QDateTime getCreation() const Q_DECL_OVERRIDE;
virtual QString getId() const Q_DECL_OVERRIDE;
};
#endif /* KGPGORPHANNODE_H */
......@@ -47,7 +47,7 @@ KGpgRefNode::KGpgRefNode(KGpgExpandableNode *parent, const QString &keyid)
if (!m_selfsig) {
m_keynode = root->findKey(keyid);
if (m_keynode != NULL) {
if (m_keynode != Q_NULLPTR) {
m_keynode->addRef(this);
} else {
connect(root, SIGNAL(newKeyNode(KGpgKeyNode*)), this, SLOT(keyUpdated(KGpgKeyNode*)));
......@@ -62,8 +62,8 @@ KGpgRefNode::KGpgRefNode(KGpgExpandableNode *parent, KGpgKeyNode *key)
m_id(key->getId()),
m_keynode(key)
{
Q_ASSERT(key != NULL);
Q_ASSERT(parent != NULL);
Q_ASSERT(key != Q_NULLPTR);
Q_ASSERT(parent != Q_NULLPTR);
m_keynode->addRef(this);
parent->children.append(this);
......@@ -84,7 +84,7 @@ KGpgRefNode::getRootNode() const
do {
root = pt;
pt = pt->getParentKeyNode();
} while (pt != NULL);
} while (pt != Q_NULLPTR);
return root->toRootNode();
}
......@@ -92,11 +92,11 @@ KGpgRefNode::getRootNode() const
void
KGpgRefNode::keyUpdated(KGpgKeyNode *nkey)
{
Q_ASSERT(m_keynode == NULL);
Q_ASSERT(nkey != NULL);
Q_ASSERT(m_keynode == Q_NULLPTR);
Q_ASSERT(nkey != Q_NULLPTR);
if (nkey->compareId(m_id)) {
disconnect(sender(), NULL, this, SLOT(keyUpdated(KGpgKeyNode*)));
disconnect(sender(), Q_NULLPTR, this, SLOT(keyUpdated(KGpgKeyNode*)));
m_keynode = nkey;
m_keynode->addRef(this);
}
......@@ -105,16 +105,16 @@ KGpgRefNode::keyUpdated(KGpgKeyNode *nkey)
void
KGpgRefNode::unRef(KGpgRootNode *root)
{
if (root != NULL)
if (root != Q_NULLPTR)
connect(root, SIGNAL(newKeyNode(KGpgKeyNode*)), this, SLOT(keyUpdated(KGpgKeyNode*)));
m_keynode = NULL;
m_keynode = Q_NULLPTR;
}
QString
KGpgRefNode::getId() const
{
if (m_keynode != NULL)
if (m_keynode != Q_NULLPTR)
return m_keynode->getFingerprint();
else
return m_id;
......@@ -123,7 +123,7 @@ KGpgRefNode::getId() const
QString
KGpgRefNode::getName() const
{
if (m_keynode != NULL)
if (m_keynode != Q_NULLPTR)
return m_keynode->getName();
return i18n("[No user id found]");
}
......@@ -131,7 +131,7 @@ KGpgRefNode::getName() const
QString
KGpgRefNode::getEmail() const
{
if (m_keynode != NULL)
if (m_keynode != Q_NULLPTR)
return m_keynode->getEmail();
return QString();
}
......@@ -139,7 +139,7 @@ KGpgRefNode::getEmail() const
bool
KGpgRefNode::isUnknown() const
{
return (m_keynode == NULL);
return (m_keynode == Q_NULLPTR);
}
KGpgKeyNode *
......
......@@ -62,17 +62,17 @@ public:
* Get the node of the primary key this node references to
*
* This will return the key node of the primary key this node
* references. This may be %NULL if the primary key is not in the key
* references. This may be %Q_NULLPTR if the primary key is not in the key
* ring, e.g. if this is a signature of an unknown key.
*
* @return the node of the primary key or %NULL
* @return the node of the primary key or %Q_NULLPTR
*/
virtual KGpgKeyNode *getRefNode() const;
/**
* Check if the referenced key exists
*
* @return if getRefNode() will return %NULL or not
* @return if getRefNode() will return %Q_NULLPTR or not
*/
bool isUnknown() const;
......
......@@ -27,7 +27,7 @@
#include <QStringList>
KGpgRootNode::KGpgRootNode(KGpgItemModel *model)
: KGpgExpandableNode(NULL),
: KGpgExpandableNode(Q_NULLPTR),
m_groups(0),
m_deleting(false)
{
......@@ -122,7 +122,7 @@ KGpgRootNode::findKey(const QString &keyId)
return children[i]->toKeyNode();
}
return NULL;
return Q_NULLPTR;
}
int
......@@ -166,7 +166,7 @@ KGpgRootNode *
KGpgRootNode::asRootNode()
{
if (m_deleting)
return NULL;
return Q_NULLPTR;
return this;
}
......@@ -175,7 +175,7 @@ const KGpgRootNode *
KGpgRootNode::asRootNode() const
{
if (m_deleting)
return NULL;
return Q_NULLPTR;
return this;
}
......
......@@ -31,7 +31,7 @@ class QStringList;
*
* This object is invisible to the user but acts as the internal base object for
* everything in the keyring. It is anchestor of all other KGpgNode objects and
* the only one that will ever return NULL when calling getParentKeyNode() on it.
* the only one that will ever return Q_NULLPTR when calling getParentKeyNode() on it.
*
* There is only one object of this type around at any time.
*/
......@@ -46,7 +46,7 @@ private:
int m_deleting;
protected:
virtual void readChildren();
virtual void readChildren() Q_DECL_OVERRIDE;
public:
explicit KGpgRootNode(KGpgItemModel *model);
......@@ -73,7 +73,7 @@ public:
* the complete fingerprint whenever possible.
*
* @param keyId the key id to find, any length is permitted
* @return pointer to key node or %NULL if no such key
* @return pointer to key node or %Q_NULLPTR if no such key
*/
KGpgKeyNode *findKey(const QString &keyId);
/**
......@@ -110,11 +110,11 @@ public:
int groupChildren() const;
/**
* Return a pointer to this object or NULL
* Return a pointer to this object or Q_NULLPTR
*
* This returns a pointer to this object if the object will persist,
* i.e. is not currently in destruction. If the object is already
* cleaning up NULL is returned.
* cleaning up Q_NULLPTR is returned.
*/
KGpgRootNode *asRootNode();
/**
......
......@@ -45,10 +45,10 @@ public:
explicit KGpgSignNode(KGpgSignableNode *parent, const QStringList &s);
virtual ~KGpgSignNode();
virtual KgpgCore::KgpgItemType getType() const;
virtual QDateTime getExpiration() const;
virtual QString getName() const;
virtual QDateTime getCreation() const;
virtual KgpgCore::KgpgItemType getType() const Q_DECL_OVERRIDE;
virtual QDateTime getExpiration() const Q_DECL_OVERRIDE;
virtual QString getName() const Q_DECL_OVERRIDE;
virtual QDateTime getCreation() const Q_DECL_OVERRIDE;
};
#endif /* KGPGSIGNNODE_H */
......@@ -36,7 +36,7 @@ public:
typedef QList<KGpgSignableNode *> List;
typedef QList<const KGpgSignableNode *> const_List;
explicit KGpgSignableNode(KGpgExpandableNode *parent = NULL);
explicit KGpgSignableNode(KGpgExpandableNode *parent = Q_NULLPTR);
virtual ~KGpgSignableNode();
KGpgSignNode::List getSignatures(void) const;
......
......@@ -27,7 +27,7 @@ KGpgSubkeyNode::KGpgSubkeyNode(KGpgKeyNode *parent, const KgpgKeySub &k)
: KGpgSignableNode(parent),
m_skey(k)
{
Q_ASSERT(parent != NULL);
Q_ASSERT(parent != Q_NULLPTR);
}
KGpgSubkeyNode::~KGpgSubkeyNode()
{
......
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