summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Vrátil <dvratil@kde.org>2016-10-12 12:41:49 (GMT)
committerDaniel Vrátil <dvratil@kde.org>2016-10-12 17:26:10 (GMT)
commitb222e4591be27a8ba840ed985ffc473d9f54d580 (patch)
tree6e220383bf51878c0cf03d404e0a1fa211b2b9b5
parent4cca867c9d89beb484164ef6e9a67ac0abab4ba8 (diff)
Port from cassert to Q_ASSERT
Some of the asserts may be expensive, so let's not execute them in release mode thanks to Q_ASSERT.
-rw-r--r--src/models/keylistmodel.cpp27
-rw-r--r--src/models/keylistsortfilterproxymodel.cpp1
-rw-r--r--src/models/keyrearrangecolumnsproxymodel.cpp3
-rw-r--r--src/tests/test_auditlog.cpp1
-rw-r--r--src/tests/test_cryptoconfig.cpp105
-rw-r--r--src/tests/test_jobs.cpp7
-rw-r--r--src/tests/test_keygen.cpp5
-rw-r--r--src/tests/test_keylister.cpp3
-rw-r--r--src/ui/cryptoconfigmodule.cpp7
-rw-r--r--src/ui/directoryserviceswidget.cpp21
-rw-r--r--src/ui/dnattributeorderconfigwidget.cpp3
-rw-r--r--src/ui/keyapprovaldialog.cpp7
-rw-r--r--src/ui/keylistview.cpp7
-rw-r--r--src/ui/keyrequester.cpp3
-rw-r--r--src/ui/keyselectiondialog.cpp19
-rw-r--r--src/ui/progressdialog.cpp3
-rw-r--r--src/utils/classify.cpp5
-rw-r--r--src/utils/filesystemwatcher.cpp7
-rw-r--r--src/utils/formatting.cpp5
19 files changed, 110 insertions, 129 deletions
diff --git a/src/models/keylistmodel.cpp b/src/models/keylistmodel.cpp
index ceb636b..305ae49 100644
--- a/src/models/keylistmodel.cpp
+++ b/src/models/keylistmodel.cpp
@@ -63,7 +63,6 @@
#include <map>
#include <set>
#include <iterator>
-#include <cassert>
using namespace GpgME;
using namespace Kleo;
@@ -480,7 +479,7 @@ FlatKeyListModel::~FlatKeyListModel() {}
Key FlatKeyListModel::doMapToKey(const QModelIndex &idx) const
{
- assert(idx.isValid());
+ Q_ASSERT(idx.isValid());
if (static_cast<unsigned>(idx.row()) < mKeysByFingerprint.size() && idx.column() < NumColumns) {
return mKeysByFingerprint[ idx.row() ];
} else {
@@ -490,7 +489,7 @@ Key FlatKeyListModel::doMapToKey(const QModelIndex &idx) const
QModelIndex FlatKeyListModel::doMapFromKey(const Key &key, int col) const
{
- assert(!key.isNull());
+ Q_ASSERT(!key.isNull());
const std::vector<Key>::const_iterator it
= std::lower_bound(mKeysByFingerprint.begin(), mKeysByFingerprint.end(),
key, _detail::ByFingerprint<std::less>());
@@ -503,7 +502,7 @@ QModelIndex FlatKeyListModel::doMapFromKey(const Key &key, int col) const
QList<QModelIndex> FlatKeyListModel::doAddKeys(const std::vector<Key> &keys)
{
- assert(std::is_sorted(keys.begin(), keys.end(), _detail::ByFingerprint<std::less>()));
+ Q_ASSERT(std::is_sorted(keys.begin(), keys.end(), _detail::ByFingerprint<std::less>()));
if (keys.empty()) {
return QList<QModelIndex>();
@@ -684,7 +683,7 @@ QModelIndex HierarchicalKeyListModel::doMapFromKey(const Key &key, int col) cons
void HierarchicalKeyListModel::addKeyWithParent(const char *issuer_fpr, const Key &key)
{
- assert(issuer_fpr); assert(*issuer_fpr); assert(!key.isNull());
+ Q_ASSERT(issuer_fpr); Q_ASSERT(*issuer_fpr); Q_ASSERT(!key.isNull());
std::vector<Key> &subjects = mKeysByExistingParent[issuer_fpr];
@@ -699,7 +698,7 @@ void HierarchicalKeyListModel::addKeyWithParent(const char *issuer_fpr, const Ke
} else {
// doesn't exist -> insert
const std::vector<Key>::const_iterator pos = qBinaryFind(mKeysByFingerprint.begin(), mKeysByFingerprint.end(), issuer_fpr, _detail::ByFingerprint<std::less>());
- assert(pos != mKeysByFingerprint.end());
+ Q_ASSERT(pos != mKeysByFingerprint.end());
beginInsertRows(index(*pos), row, row);
subjects.insert(it, key);
endInsertRows();
@@ -709,7 +708,7 @@ void HierarchicalKeyListModel::addKeyWithParent(const char *issuer_fpr, const Ke
void HierarchicalKeyListModel::addKeyWithoutParent(const char *issuer_fpr, const Key &key)
{
- assert(issuer_fpr); assert(*issuer_fpr); assert(!key.isNull());
+ Q_ASSERT(issuer_fpr); Q_ASSERT(*issuer_fpr); Q_ASSERT(!key.isNull());
std::vector<Key> &subjects = mKeysByNonExistingParent[issuer_fpr];
@@ -773,7 +772,7 @@ static std::vector<Key> topological_sort(const std::vector<Key> &keys)
order.reserve(keys.size());
topological_sort(graph, std::back_inserter(order));
- assert(order.size() == keys.size());
+ Q_ASSERT(order.size() == keys.size());
std::vector<Key> result;
result.reserve(keys.size());
@@ -785,7 +784,7 @@ static std::vector<Key> topological_sort(const std::vector<Key> &keys)
QList<QModelIndex> HierarchicalKeyListModel::doAddKeys(const std::vector<Key> &keys)
{
- assert(std::is_sorted(keys.begin(), keys.end(), _detail::ByFingerprint<std::less>()));
+ Q_ASSERT(std::is_sorted(keys.begin(), keys.end(), _detail::ByFingerprint<std::less>()));
if (keys.empty()) {
return QList<QModelIndex>();
@@ -827,11 +826,11 @@ QList<QModelIndex> HierarchicalKeyListModel::doAddKeys(const std::vector<Key> &k
Q_FOREACH (const Key &k, children) {
last = qBinaryFind(last, mTopLevels.end(), k, _detail::ByFingerprint<std::less>());
- assert(last != mTopLevels.end());
+ Q_ASSERT(last != mTopLevels.end());
const int row = std::distance(mTopLevels.begin(), last);
lastFP = qBinaryFind(lastFP, mKeysByFingerprint.end(), k, _detail::ByFingerprint<std::less>());
- assert(lastFP != mKeysByFingerprint.end());
+ Q_ASSERT(lastFP != mKeysByFingerprint.end());
Q_EMIT rowAboutToBeMoved(QModelIndex(), row);
beginRemoveRows(QModelIndex(), row, row);
@@ -916,9 +915,9 @@ void HierarchicalKeyListModel::doRemoveKey(const Key &key)
const std::vector<Key>::iterator it = qBinaryFind(mKeysByFingerprint.begin(), mKeysByFingerprint.end(),
key, _detail::ByFingerprint<std::less>());
- assert(it != mKeysByFingerprint.end());
- assert(mKeysByNonExistingParent.find(fpr) == mKeysByNonExistingParent.end());
- assert(mKeysByExistingParent.find(fpr) == mKeysByExistingParent.end());
+ Q_ASSERT(it != mKeysByFingerprint.end());
+ Q_ASSERT(mKeysByNonExistingParent.find(fpr) == mKeysByNonExistingParent.end());
+ Q_ASSERT(mKeysByExistingParent.find(fpr) == mKeysByExistingParent.end());
beginRemoveRows(parent(idx), idx.row(), idx.row());
mKeysByFingerprint.erase(it);
diff --git a/src/models/keylistsortfilterproxymodel.cpp b/src/models/keylistsortfilterproxymodel.cpp
index e6f8902..f0d6446 100644
--- a/src/models/keylistsortfilterproxymodel.cpp
+++ b/src/models/keylistsortfilterproxymodel.cpp
@@ -40,7 +40,6 @@
#include <gpgme++/key.h>
-#include <cassert>
using namespace Kleo;
using namespace GpgME;
diff --git a/src/models/keyrearrangecolumnsproxymodel.cpp b/src/models/keyrearrangecolumnsproxymodel.cpp
index 8db3faf..525560b 100644
--- a/src/models/keyrearrangecolumnsproxymodel.cpp
+++ b/src/models/keyrearrangecolumnsproxymodel.cpp
@@ -31,7 +31,6 @@
#include "keyrearrangecolumnsproxymodel.h"
#include <gpgme++/key.h>
-#include <cassert>
using namespace Kleo;
using namespace GpgME;
@@ -46,7 +45,7 @@ KeyRearrangeColumnsProxyModel::KeyRearrangeColumnsProxyModel(QObject *parent) :
KeyListModelInterface *KeyRearrangeColumnsProxyModel::klm() const
{
KeyListModelInterface *ret = dynamic_cast<KeyListModelInterface *>(sourceModel());
- assert(ret);
+ Q_ASSERT(ret);
return ret;
}
diff --git a/src/tests/test_auditlog.cpp b/src/tests/test_auditlog.cpp
index 94f7cb1..5236d27 100644
--- a/src/tests/test_auditlog.cpp
+++ b/src/tests/test_auditlog.cpp
@@ -79,7 +79,6 @@ const char * auditlog =
#include <QDebug>
-#include <assert.h>
#include <QApplication>
#include <KLocalizedString>
#include <QCommandLineParser>
diff --git a/src/tests/test_cryptoconfig.cpp b/src/tests/test_cryptoconfig.cpp
index 587115f..c93579a 100644
--- a/src/tests/test_cryptoconfig.cpp
+++ b/src/tests/test_cryptoconfig.cpp
@@ -41,7 +41,6 @@ using namespace QGpgME;
#include <gpgme++/error.h>
#include <stdlib.h>
-#include <assert.h>
int main(int argc, char **argv)
{
@@ -62,17 +61,17 @@ int main(int argc, char **argv)
for (QStringList::Iterator compit = components.begin(); compit != components.end(); ++compit) {
cout << "Component " << (*compit).toLocal8Bit().constData() << ":" << endl;
const QGpgME::CryptoConfigComponent *comp = config->component(*compit);
- assert(comp);
+ Q_ASSERT(comp);
QStringList groups = comp->groupList();
for (QStringList::Iterator groupit = groups.begin(); groupit != groups.end(); ++groupit) {
const QGpgME::CryptoConfigGroup *group = comp->group(*groupit);
- assert(group);
+ Q_ASSERT(group);
cout << " Group " << (*groupit).toLocal8Bit().constData() << ": descr=\"" << group->description().toLocal8Bit().constData() << "\""
<< " level=" << group->level() << endl;
QStringList entries = group->entryList();
for (QStringList::Iterator entryit = entries.begin(); entryit != entries.end(); ++entryit) {
const QGpgME::CryptoConfigEntry *entry = group->entry(*entryit);
- assert(entry);
+ Q_ASSERT(entry);
cout << " Entry " << (*entryit).toLocal8Bit().constData() << ":"
<< " descr=\"" << entry->description().toLocal8Bit().constData() << "\""
<< " " << (entry->isSet() ? "is set" : "is not set");
@@ -106,8 +105,8 @@ int main(int argc, char **argv)
break;
}
case QGpgME::CryptoConfigEntry::ArgType_Int: {
- // (marc) if an entry isn't optional, you have to unset it for the default to take effect, so this assert is wrong:
- // assert( entry->isOptional() ); // empty lists must be allowed (see https://www.intevation.de/roundup/aegypten/issue121)
+ // (marc) if an entry isn't optional, you have to unset it for the default to take effect, so this Q_ASSERT is wrong:
+ // Q_ASSERT( entry->isOptional() ); // empty lists must be allowed (see https://www.intevation.de/roundup/aegypten/issue121)
std::vector<int> lst = entry->intValueList();
QString str;
for (std::vector<int>::const_iterator it = lst.begin(); it != lst.end(); ++it) {
@@ -117,8 +116,8 @@ int main(int argc, char **argv)
break;
}
case QGpgME::CryptoConfigEntry::ArgType_UInt: {
- // (marc) if an entry isn't optional, you have to unset it for the default to take effect, so this assert is wrong:
- // assert( entry->isOptional() ); // empty lists must be allowed (see https://www.intevation.de/roundup/aegypten/issue121)
+ // (marc) if an entry isn't optional, you have to unset it for the default to take effect, so this Q_ASSERT is wrong:
+ // Q_ASSERT( entry->isOptional() ); // empty lists must be allowed (see https://www.intevation.de/roundup/aegypten/issue121)
std::vector<uint> lst = entry->uintValueList();
QString str;
for (std::vector<uint>::const_iterator it = lst.begin(); it != lst.end(); ++it) {
@@ -128,8 +127,8 @@ int main(int argc, char **argv)
break;
}
case QGpgME::CryptoConfigEntry::ArgType_LDAPURL: {
- // (marc) if an entry isn't optional, you have to unset it for the default to take effect, so this assert is wrong:
- // assert( entry->isOptional() ); // empty lists must be allowed (see https://www.intevation.de/roundup/aegypten/issue121)
+ // (marc) if an entry isn't optional, you have to unset it for the default to take effect, so this Q_ASSERT is wrong:
+ // Q_ASSERT( entry->isOptional() ); // empty lists must be allowed (see https://www.intevation.de/roundup/aegypten/issue121)
QList<QUrl> urls = entry->urlValueList();
cout << " url values ";
Q_FOREACH (const QUrl &url, urls) {
@@ -162,12 +161,12 @@ int main(int argc, char **argv)
static const char s_entryName[] = "quiet";
QGpgME::CryptoConfigEntry *entry = config->entry(QStringLiteral("dirmngr"), s_groupName, s_entryName);
if (entry) {
- assert(entry->argType() == QGpgME::CryptoConfigEntry::ArgType_None);
+ Q_ASSERT(entry->argType() == QGpgME::CryptoConfigEntry::ArgType_None);
bool val = entry->boolValue();
cout << "quiet option initially: " << (val ? "is set" : "is not set") << endl;
entry->setBoolValue(!val);
- assert(entry->isDirty());
+ Q_ASSERT(entry->isDirty());
config->sync(true);
// Clear cached values!
@@ -175,29 +174,29 @@ int main(int argc, char **argv)
// Check new value
QGpgME::CryptoConfigEntry *entry = config->entry(QStringLiteral("dirmngr"), s_groupName, s_entryName);
- assert(entry);
- assert(entry->argType() == QGpgME::CryptoConfigEntry::ArgType_None);
+ Q_ASSERT(entry);
+ Q_ASSERT(entry->argType() == QGpgME::CryptoConfigEntry::ArgType_None);
cout << "quiet option now: " << (val ? "is set" : "is not set") << endl;
- assert(entry->boolValue() == !val);
+ Q_ASSERT(entry->boolValue() == !val);
// Set to default
entry->resetToDefault();
- assert(entry->boolValue() == false); // that's the default
- assert(entry->isDirty());
- assert(!entry->isSet());
+ Q_ASSERT(entry->boolValue() == false); // that's the default
+ Q_ASSERT(entry->isDirty());
+ Q_ASSERT(!entry->isSet());
config->sync(true);
config->clear();
// Check value
entry = config->entry(QStringLiteral("dirmngr"), s_groupName, s_entryName);
- assert(!entry->isDirty());
- assert(!entry->isSet());
+ Q_ASSERT(!entry->isDirty());
+ Q_ASSERT(!entry->isSet());
cout << "quiet option reset to default: " << (entry->boolValue() ? "is set" : "is not set") << endl;
- assert(entry->boolValue() == false);
+ Q_ASSERT(entry->boolValue() == false);
// Reset old value
entry->setBoolValue(val);
- assert(entry->isDirty());
+ Q_ASSERT(entry->isDirty());
config->sync(true);
cout << "quiet option reset to initial: " << (val ? "is set" : "is not set") << endl;
@@ -212,7 +211,7 @@ int main(int argc, char **argv)
static const char s_entryName[] = "ldaptimeout";
QGpgME::CryptoConfigEntry *entry = config->entry(QStringLiteral("dirmngr"), s_groupName, s_entryName);
if (entry) {
- assert(entry->argType() == QGpgME::CryptoConfigEntry::ArgType_UInt);
+ Q_ASSERT(entry->argType() == QGpgME::CryptoConfigEntry::ArgType_UInt);
uint val = entry->uintValue();
cout << "LDAP timeout initially: " << val << " seconds." << endl;
@@ -220,7 +219,7 @@ int main(int argc, char **argv)
//system( "echo 'ldaptimeout:0:101' | gpgconf --change-options dirmngr" );
// Now let's do it with the C++ API instead
entry->setUIntValue(101);
- assert(entry->isDirty());
+ Q_ASSERT(entry->isDirty());
config->sync(true);
// Clear cached values!
@@ -228,29 +227,29 @@ int main(int argc, char **argv)
// Check new value
QGpgME::CryptoConfigEntry *entry = config->entry(QStringLiteral("dirmngr"), s_groupName, s_entryName);
- assert(entry);
- assert(entry->argType() == QGpgME::CryptoConfigEntry::ArgType_UInt);
+ Q_ASSERT(entry);
+ Q_ASSERT(entry->argType() == QGpgME::CryptoConfigEntry::ArgType_UInt);
cout << "LDAP timeout now: " << entry->uintValue() << " seconds." << endl;
- assert(entry->uintValue() == 101);
+ Q_ASSERT(entry->uintValue() == 101);
// Set to default
entry->resetToDefault();
- assert(entry->uintValue() == 100);
- assert(entry->isDirty());
- assert(!entry->isSet());
+ Q_ASSERT(entry->uintValue() == 100);
+ Q_ASSERT(entry->isDirty());
+ Q_ASSERT(!entry->isSet());
config->sync(true);
config->clear();
// Check value
entry = config->entry(QStringLiteral("dirmngr"), s_groupName, s_entryName);
- assert(!entry->isDirty());
- assert(!entry->isSet());
+ Q_ASSERT(!entry->isDirty());
+ Q_ASSERT(!entry->isSet());
cout << "LDAP timeout reset to default, " << entry->uintValue() << " seconds." << endl;
- assert(entry->uintValue() == 100);
+ Q_ASSERT(entry->uintValue() == 100);
// Reset old value
entry->setUIntValue(val);
- assert(entry->isDirty());
+ Q_ASSERT(entry->isDirty());
config->sync(true);
cout << "LDAP timeout reset to initial " << val << " seconds." << endl;
@@ -265,13 +264,13 @@ int main(int argc, char **argv)
static const char s_entryName[] = "log-file";
QGpgME::CryptoConfigEntry *entry = config->entry(QStringLiteral("dirmngr"), s_groupName, s_entryName);
if (entry) {
- assert(entry->argType() == QGpgME::CryptoConfigEntry::ArgType_Path);
+ Q_ASSERT(entry->argType() == QGpgME::CryptoConfigEntry::ArgType_Path);
QString val = entry->stringValue();
cout << "Log-file initially: " << val.toLocal8Bit().constData() << endl;
// Test setting the option, sync'ing, then querying again
entry->setStringValue(QStringLiteral("/tmp/test:%e5ä"));
- assert(entry->isDirty());
+ Q_ASSERT(entry->isDirty());
config->sync(true);
// Let's see how it prints it
@@ -282,10 +281,10 @@ int main(int argc, char **argv)
// Check new value
QGpgME::CryptoConfigEntry *entry = config->entry(QStringLiteral("dirmngr"), s_groupName, s_entryName);
- assert(entry);
- assert(entry->argType() == QGpgME::CryptoConfigEntry::ArgType_Path);
+ Q_ASSERT(entry);
+ Q_ASSERT(entry->argType() == QGpgME::CryptoConfigEntry::ArgType_Path);
cout << "Log-file now: " << entry->stringValue().toLocal8Bit().constData() << endl;
- assert(entry->stringValue() == QStringLiteral("/tmp/test:%e5ä")); // (or even with %e5 decoded)
+ Q_ASSERT(entry->stringValue() == QStringLiteral("/tmp/test:%e5ä")); // (or even with %e5 decoded)
// Reset old value
#if 0
@@ -298,7 +297,7 @@ int main(int argc, char **argv)
system(sys.data());
#endif
entry->setStringValue(val);
- assert(entry->isDirty());
+ Q_ASSERT(entry->isDirty());
config->sync(true);
cout << "Log-file reset to initial " << val.toLocal8Bit().constData() << endl;
@@ -313,8 +312,8 @@ int main(int argc, char **argv)
static const char s_entryName[] = "LDAP Server";
QGpgME::CryptoConfigEntry *entry = config->entry(QStringLiteral("dirmngr"), s_groupName, s_entryName);
if (entry) {
- assert(entry->argType() == QGpgME::CryptoConfigEntry::ArgType_LDAPURL);
- assert(entry->isList());
+ Q_ASSERT(entry->argType() == QGpgME::CryptoConfigEntry::ArgType_LDAPURL);
+ Q_ASSERT(entry->isList());
QList<QUrl> val = entry->urlValueList();
cout << "URL list initially: ";
Q_FOREACH (const QUrl &url, val) {
@@ -328,10 +327,10 @@ int main(int argc, char **argv)
lst << QUrl(QStringLiteral("ldap://foo:389?a:b c"));
lst << QUrl(QStringLiteral("ldap://server:389?a=b,c=DE")); // the query contains a literal ','
//cout << " trying to set: " << lst.toStringList().join(", ").local8Bit() << endl;
- assert(lst[0].query() == "b");
- assert(lst[1].query() == "a:b c"); // see, the space got _not_escaped
+ Q_ASSERT(lst[0].query() == "b");
+ Q_ASSERT(lst[1].query() == "a:b c"); // see, the space got _not_escaped
entry->setURLValueList(lst);
- assert(entry->isDirty());
+ Q_ASSERT(entry->isDirty());
config->sync(true);
// Let's see how it prints it
@@ -342,9 +341,9 @@ int main(int argc, char **argv)
// Check new value
QGpgME::CryptoConfigEntry *entry = config->entry(QStringLiteral("dirmngr"), s_groupName, s_entryName);
- assert(entry);
- assert(entry->argType() == QGpgME::CryptoConfigEntry::ArgType_LDAPURL);
- assert(entry->isList());
+ Q_ASSERT(entry);
+ Q_ASSERT(entry->argType() == QGpgME::CryptoConfigEntry::ArgType_LDAPURL);
+ Q_ASSERT(entry->isList());
// Get QUrl form
QList<QUrl> newlst = entry->urlValueList();
cout << "URL list now: ";
@@ -352,14 +351,14 @@ int main(int argc, char **argv)
cout << url.toString().toLocal8Bit().constData() << endl;
}
cout << endl;
- assert(newlst.count() == 3);
- assert(newlst[0].url() == lst[0].url());
- assert(newlst[1].url() == lst[1].url());
- assert(newlst[2].url() == lst[2].url());
+ Q_ASSERT(newlst.count() == 3);
+ Q_ASSERT(newlst[0].url() == lst[0].url());
+ Q_ASSERT(newlst[1].url() == lst[1].url());
+ Q_ASSERT(newlst[2].url() == lst[2].url());
// Reset old value
entry->setURLValueList(val);
- assert(entry->isDirty());
+ Q_ASSERT(entry->isDirty());
config->sync(true);
cout << "URL list reset to initial: ";
diff --git a/src/tests/test_jobs.cpp b/src/tests/test_jobs.cpp
index c6bdff3..edb5a6c 100644
--- a/src/tests/test_jobs.cpp
+++ b/src/tests/test_jobs.cpp
@@ -38,7 +38,6 @@
#include <gpgme++/keylistresult.h>
#include <QDebug>
-#include <assert.h>
#include <KAboutData>
#include <memory>
@@ -51,7 +50,7 @@ static const char *protocol = 0;
static void testSign()
{
const QGpgME::Protocol *proto = !strcmp(protocol, "openpgp") ? QGpgME::openpgp() : QGpgME::smime();
- assert(proto);
+ Q_ASSERT(proto);
qDebug() << "Using protocol" << proto->name();
@@ -61,9 +60,9 @@ static void testSign()
if (listJob.get()) {
// ##### Adjust this to your own identity
listJob->exec(QStringList(QStringLiteral("kloecker@kde.org")), true /*secret*/, signingKeys);
- assert(!signingKeys.empty());
+ Q_ASSERT(!signingKeys.empty());
} else {
- assert(0); // job failed
+ Q_ASSERT(0); // job failed
}
QGpgME::SignJob *job = proto->signJob(true, true);
diff --git a/src/tests/test_keygen.cpp b/src/tests/test_keygen.cpp
index 616419d..0606b2b 100644
--- a/src/tests/test_keygen.cpp
+++ b/src/tests/test_keygen.cpp
@@ -47,7 +47,6 @@
#include <QLabel>
#include <QGridLayout>
-#include <assert.h>
#include <QApplication>
#include <KLocalizedString>
#include <QCommandLineParser>
@@ -127,12 +126,12 @@ void KeyGenerator::slotStartKeyGeneration()
if (!proto) {
proto = QGpgME::smime();
}
- assert(proto);
+ Q_ASSERT(proto);
qDebug() << "Using protocol" << proto->name();
QGpgME::KeyGenerationJob *job = proto->keyGenerationJob();
- assert(job);
+ Q_ASSERT(job);
connect(job, SIGNAL(result(GpgME::KeyGenerationResult,QByteArray)),
SLOT(slotResult(GpgME::KeyGenerationResult,QByteArray)));
diff --git a/src/tests/test_keylister.cpp b/src/tests/test_keylister.cpp
index ca4ff6f..784a07d 100644
--- a/src/tests/test_keylister.cpp
+++ b/src/tests/test_keylister.cpp
@@ -45,7 +45,6 @@
#include <QStringList>
#include <QTimer>
-#include <assert.h>
#include <QApplication>
#include <KLocalizedString>
#include <QCommandLineParser>
@@ -124,7 +123,7 @@ void CertListView::slotStart()
{
qDebug() << "CertListView::slotStart()";
QGpgME::KeyListJob *job = QGpgME::smime()->keyListJob(false);
- assert(job);
+ Q_ASSERT(job);
QObject::connect(job, SIGNAL(nextKey(GpgME::Key)),
this, SLOT(slotAddKey(GpgME::Key)));
QObject::connect(job, SIGNAL(result(GpgME::KeyListResult)),
diff --git a/src/ui/cryptoconfigmodule.cpp b/src/ui/cryptoconfigmodule.cpp
index 0d57143..d46fed0 100644
--- a/src/ui/cryptoconfigmodule.cpp
+++ b/src/ui/cryptoconfigmodule.cpp
@@ -61,7 +61,6 @@
#include <QComboBox>
#include <QGroupBox>
-#include <cassert>
#include <memory>
using namespace Kleo;
@@ -205,7 +204,7 @@ void Kleo::CryptoConfigModule::init(Layout layout)
} else { // small (800x600, 640x480) desktop
dialogHeight = 400;
}
- assert(scrollArea->widget());
+ Q_ASSERT(scrollArea->widget());
if (type != Tabbed) {
scrollArea->setMinimumHeight(qMin(compGUISize.height(), dialogHeight));
}
@@ -438,7 +437,7 @@ static const constructor scalarWidgets[QGpgME::CryptoConfigEntry::NumArgType] =
CryptoConfigEntryGUI *Kleo::CryptoConfigEntryGUIFactory::createEntryGUI(CryptoConfigModule *module, QGpgME::CryptoConfigEntry *entry, const QString &entryName, QGridLayout *glay, QWidget *widget)
{
- assert(entry);
+ Q_ASSERT(entry);
// try to lookup by path:
const QString path = entry->path();
@@ -449,7 +448,7 @@ CryptoConfigEntryGUI *Kleo::CryptoConfigEntryGUIFactory::createEntryGUI(CryptoCo
// none found, so look up by type:
const unsigned int argType = entry->argType();
- assert(argType < QGpgME::CryptoConfigEntry::NumArgType);
+ Q_ASSERT(argType < QGpgME::CryptoConfigEntry::NumArgType);
if (entry->isList())
if (const constructor create = listWidgets[argType]) {
return create(module, entry, entryName, glay, widget);
diff --git a/src/ui/directoryserviceswidget.cpp b/src/ui/directoryserviceswidget.cpp
index c61e550..beae288 100644
--- a/src/ui/directoryserviceswidget.cpp
+++ b/src/ui/directoryserviceswidget.cpp
@@ -47,7 +47,6 @@
#include <vector>
#include <climits>
-#include <cassert>
#include <algorithm>
#include <functional>
@@ -417,18 +416,18 @@ private:
if (m_schemes & protocols[i].base) {
cb->addItem(i18n(protocols[i].label), QLatin1String(protocols[i].label));
}
- assert(cb->count() > 0);
+ Q_ASSERT(cb->count() > 0);
return cb;
}
void setSchemeEditorData(QComboBox *cb, const QString &scheme) const
{
- assert(cb);
+ Q_ASSERT(cb);
cb->setCurrentIndex(cb->findData(scheme, Qt::UserRole, Qt::MatchFixedString));
}
void setSchemeModelData(const QComboBox *cb, QAbstractItemModel *model, const QModelIndex &idx) const
{
- assert(cb);
- assert(model);
+ Q_ASSERT(cb);
+ Q_ASSERT(model);
model->setData(idx, cb->itemData(cb->currentIndex()));
}
@@ -440,13 +439,13 @@ private:
}
void setPortEditorData(QSpinBox *sb, unsigned short port) const
{
- assert(sb);
+ Q_ASSERT(sb);
sb->setValue(port);
}
void setPortModelData(const QSpinBox *sb, QAbstractItemModel *model, const QModelIndex &idx) const
{
- assert(sb);
- assert(model);
+ Q_ASSERT(sb);
+ Q_ASSERT(model);
model->setData(idx, sb->value());
}
@@ -497,7 +496,7 @@ private:
} else if (protocols & X509Protocol) {
slotNewX509Clicked();
} else {
- assert(!"This should not happen.");
+ Q_ASSERT(!"This should not happen.");
}
else {
edit(model.duplicateRow(row));
@@ -530,7 +529,7 @@ private:
void slotShowUserAndPasswordToggled(bool on)
{
QHeaderView *const hv = ui.treeView->header();
- assert(hv);
+ Q_ASSERT(hv);
hv->setSectionHidden(Model::UserName, !on);
hv->setSectionHidden(Model::Password, !on);
}
@@ -699,7 +698,7 @@ void DirectoryServicesWidget::clear()
void DirectoryServicesWidget::Private::showHideColumns()
{
QHeaderView *const hv = ui.treeView->header();
- assert(hv);
+ Q_ASSERT(hv);
// don't show 'scheme' column when only accepting X509Protocol (###?)
hv->setSectionHidden(Model::Scheme, protocols == X509Protocol);
// hide the scheme selection columns for if only one scheme is allowed anyway:
diff --git a/src/ui/dnattributeorderconfigwidget.cpp b/src/ui/dnattributeorderconfigwidget.cpp
index 56a772f..db872bb 100644
--- a/src/ui/dnattributeorderconfigwidget.cpp
+++ b/src/ui/dnattributeorderconfigwidget.cpp
@@ -46,7 +46,6 @@
#include <QTreeWidget>
#include <QHeaderView>
-#include <cassert>
class Kleo::DNAttributeOrderConfigWidget::Private
{
@@ -78,7 +77,7 @@ static void prepare(QTreeWidget *lv)
Kleo::DNAttributeOrderConfigWidget::DNAttributeOrderConfigWidget(DNAttributeMapper *mapper, QWidget *parent, Qt::WindowFlags f)
: QWidget(parent, f), d(new Private)
{
- assert(mapper);
+ Q_ASSERT(mapper);
d->mapper = mapper;
QGridLayout *glay = new QGridLayout(this);
diff --git a/src/ui/keyapprovaldialog.cpp b/src/ui/keyapprovaldialog.cpp
index 69d1731..1b3a7d9 100644
--- a/src/ui/keyapprovaldialog.cpp
+++ b/src/ui/keyapprovaldialog.cpp
@@ -53,7 +53,6 @@
#include <gpgme++/key.h>
#include <qgpgme/protocol.h>
-#include <assert.h>
#include <QApplication>
#include <QDesktopWidget>
#include <QDialogButtonBox>
@@ -119,7 +118,7 @@ Kleo::KeyApprovalDialog::KeyApprovalDialog(const std::vector<Item> &recipients,
connect(buttonBox, &QDialogButtonBox::accepted, this, &KeyApprovalDialog::accept);
connect(buttonBox, &QDialogButtonBox::rejected, this, &KeyApprovalDialog::reject);
okButton->setDefault(true);
- assert(!recipients.empty());
+ Q_ASSERT(!recipients.empty());
QFrame *page = new QFrame(this);
mainLayout->addWidget(page);
@@ -197,8 +196,8 @@ std::vector<GpgME::Key> Kleo::KeyApprovalDialog::senderKeys() const
std::vector<Kleo::KeyApprovalDialog::Item> Kleo::KeyApprovalDialog::items() const
{
- assert(d->requesters.size() == static_cast<unsigned int>(d->addresses.size()));
- assert(d->requesters.size() == d->preferences.size());
+ Q_ASSERT(d->requesters.size() == static_cast<unsigned int>(d->addresses.size()));
+ Q_ASSERT(d->requesters.size() == d->preferences.size());
std::vector<Item> result;
result.reserve(d->requesters.size());
diff --git a/src/ui/keylistview.cpp b/src/ui/keylistview.cpp
index e9cd0b7..8073306 100644
--- a/src/ui/keylistview.cpp
+++ b/src/ui/keylistview.cpp
@@ -45,7 +45,6 @@
#include <vector>
#include <map>
-#include <assert.h>
#include <QKeyEvent>
static const int updateDelayMilliSecs = 500;
@@ -123,7 +122,7 @@ Kleo::KeyListView::~KeyListView()
// a valid listView() pointing to us anymore, and their dtors try to
// unregister from us.
clear();
- assert(d->itemMap.size() == 0);
+ Q_ASSERT(d->itemMap.size() == 0);
// need to delete the tooltip ourselves, as ~QToolTip isn't virtual :o
delete d;
delete mColumnStrategy; mColumnStrategy = 0;
@@ -225,7 +224,7 @@ void Kleo::KeyListView::deregisterItem(const KeyListViewItem *item)
if (it == d->itemMap.end()) {
return;
}
- // This assert triggers, though it shouldn't. Print some more
+ // This Q_ASSERT triggers, though it shouldn't. Print some more
// information when it happens.
//Q_ASSERT( it->second == item );
if (it->second != item) {
@@ -283,7 +282,7 @@ void Kleo::KeyListView::scatterGathered(KeyListViewItem *start)
item = item->nextSibling();
scatterGathered(Kleo::lvi_cast<Kleo::KeyListViewItem>(cur->child(0)));
- assert(cur->childCount() == 0);
+ Q_ASSERT(cur->childCount() == 0);
// ### todo: optimize by suppressing removing/adding the item to the itemMap...
if (cur->parent()) {
diff --git a/src/ui/keyrequester.cpp b/src/ui/keyrequester.cpp
index 75830c4..964c90e 100644
--- a/src/ui/keyrequester.cpp
+++ b/src/ui/keyrequester.cpp
@@ -72,7 +72,6 @@
#include <QHBoxLayout>
-#include <assert.h>
using namespace QGpgME;
@@ -243,7 +242,7 @@ void Kleo::KeyRequester::updateKeys()
#define __KLEO_UI_SHOW_KEY_LIST_ERROR_H__
static void showKeyListError(QWidget *parent, const GpgME::Error &err)
{
- assert(err);
+ Q_ASSERT(err);
const QString msg = i18n("<qt><p>An error occurred while fetching "
"the keys from the backend:</p>"
"<p><b>%1</b></p></qt>",
diff --git a/src/ui/keyselectiondialog.cpp b/src/ui/keyselectiondialog.cpp
index 4ab81bb..8c11acc 100644
--- a/src/ui/keyselectiondialog.cpp
+++ b/src/ui/keyselectiondialog.cpp
@@ -78,7 +78,6 @@
#include <iterator>
#include <string.h>
-#include <assert.h>
#include <qscrollbar.h>
#include <KSharedConfig>
#include <KConfigGroup>
@@ -660,7 +659,7 @@ void Kleo::KeySelectionDialog::slotStartCertificateManager(const QString &query)
#define __KLEO_UI_SHOW_KEY_LIST_ERROR_H__
static void showKeyListError(QWidget *parent, const GpgME::Error &err)
{
- assert(err);
+ Q_ASSERT(err);
const QString msg = i18n("<qt><p>An error occurred while fetching "
"the keys from the backend:</p>"
"<p><b>%1</b></p></qt>",
@@ -682,7 +681,7 @@ struct ExtractFingerprint {
void Kleo::KeySelectionDialog::startKeyListJobForBackend(const QGpgME::Protocol *backend, const std::vector<GpgME::Key> &keys, bool validate)
{
- assert(backend);
+ Q_ASSERT(backend);
QGpgME::KeyListJob *job = backend->keyListJob(false, false, validate); // local, w/o sigs, validation as givem
if (!job) {
return;
@@ -838,15 +837,15 @@ void Kleo::KeySelectionDialog::startValidatingKeyListing()
}
if (!openpgp.empty()) {
- assert(mOpenPGPBackend);
+ Q_ASSERT(mOpenPGPBackend);
startKeyListJobForBackend(mOpenPGPBackend, openpgp, true /*validate*/);
}
if (!smime.empty()) {
- assert(mSMIMEBackend);
+ Q_ASSERT(mSMIMEBackend);
startKeyListJobForBackend(mSMIMEBackend, smime, true /*validate*/);
}
- assert(mListJobCount > 0);
+ Q_ASSERT(mListJobCount > 0);
}
bool Kleo::KeySelectionDialog::rememberSelection() const
@@ -945,8 +944,8 @@ void Kleo::KeySelectionDialog::slotFilter()
void Kleo::KeySelectionDialog::filterByKeyID(const QString &keyID)
{
- assert(keyID.length() <= 8);
- assert(!keyID.isEmpty()); // regexp in slotFilter should prevent these
+ Q_ASSERT(keyID.length() <= 8);
+ Q_ASSERT(!keyID.isEmpty()); // regexp in slotFilter should prevent these
if (keyID.isEmpty()) {
showAllItems();
} else
@@ -971,7 +970,7 @@ static bool anyUIDMatches(const Kleo::KeyListViewItem *item, QRegExp &rx)
void Kleo::KeySelectionDialog::filterByKeyIDOrUID(const QString &str)
{
- assert(!str.isEmpty());
+ Q_ASSERT(!str.isEmpty());
// match beginnings of words:
QRegExp rx(QLatin1String("\\b") + QRegExp::escape(str), Qt::CaseInsensitive);
@@ -984,7 +983,7 @@ void Kleo::KeySelectionDialog::filterByKeyIDOrUID(const QString &str)
void Kleo::KeySelectionDialog::filterByUID(const QString &str)
{
- assert(!str.isEmpty());
+ Q_ASSERT(!str.isEmpty());
// match beginnings of words:
QRegExp rx(QLatin1String("\\b") + QRegExp::escape(str), Qt::CaseInsensitive);
diff --git a/src/ui/progressdialog.cpp b/src/ui/progressdialog.cpp
index 4dc89ea..32696a2 100644
--- a/src/ui/progressdialog.cpp
+++ b/src/ui/progressdialog.cpp
@@ -44,13 +44,12 @@
#include <QTimer>
-#include <assert.h>
Kleo::ProgressDialog::ProgressDialog(QGpgME::Job *job, const QString &baseText,
QWidget *creator, Qt::WindowFlags f)
: QProgressDialog(creator, f), mBaseText(baseText)
{
- assert(job);
+ Q_ASSERT(job);
setBar(new ProgressBar(this/*, "replacement progressbar in Kleo::ProgressDialog"*/));
setMinimumDuration(2000 /*ms*/);
diff --git a/src/utils/classify.cpp b/src/utils/classify.cpp
index 1ea878e..4eb6e8b 100644
--- a/src/utils/classify.cpp
+++ b/src/utils/classify.cpp
@@ -47,7 +47,6 @@
#include <gpgme++/data.h>
#include <qgpgme/dataprovider.h>
-#include <cassert>
#include <iterator>
#include <functional>
@@ -196,7 +195,7 @@ static unsigned int classifyExtension(const QFileInfo fi)
unsigned int Kleo::classify(const QString &filename)
{
- assert(std::is_sorted(std::begin(classifications), std::end(classifications), ByExtension<std::less>()));
+ Q_ASSERT(std::is_sorted(std::begin(classifications), std::end(classifications), ByExtension<std::less>()));
const QFileInfo fi(filename);
@@ -236,7 +235,7 @@ unsigned int Kleo::classify(const QString &filename)
static unsigned int classifyContentInteral(const QByteArray &data)
{
- assert(std::is_sorted(std::begin(content_classifications), std::end(content_classifications), ByContent<std::less>(100)));
+ Q_ASSERT(std::is_sorted(std::begin(content_classifications), std::end(content_classifications), ByContent<std::less>(100)));
static const char beginString[] = "-----BEGIN ";
static const QByteArrayMatcher beginMatcher(beginString);
diff --git a/src/utils/filesystemwatcher.cpp b/src/utils/filesystemwatcher.cpp
index 6492307..237b041 100644
--- a/src/utils/filesystemwatcher.cpp
+++ b/src/utils/filesystemwatcher.cpp
@@ -42,7 +42,6 @@
#include <QDir>
#include <set>
-#include <cassert>
using namespace Kleo;
@@ -225,14 +224,14 @@ void FileSystemWatcher::setEnabled(bool enable)
return;
}
if (enable) {
- assert(!d->m_watcher);
+ Q_ASSERT(!d->m_watcher);
d->m_watcher = new QFileSystemWatcher;
if (!d->m_paths.empty()) {
d->m_watcher->addPaths(d->m_paths);
}
d->connectWatcher();
} else {
- assert(d->m_watcher);
+ Q_ASSERT(d->m_watcher);
delete d->m_watcher;
d->m_watcher = 0;
}
@@ -249,7 +248,7 @@ FileSystemWatcher::~FileSystemWatcher()
void FileSystemWatcher::setDelay(int ms)
{
- assert(ms >= 0);
+ Q_ASSERT(ms >= 0);
d->m_timer.setInterval(ms);
}
diff --git a/src/utils/formatting.cpp b/src/utils/formatting.cpp
index 6828673..c1612b3 100644
--- a/src/utils/formatting.cpp
+++ b/src/utils/formatting.cpp
@@ -46,7 +46,6 @@
#include <QLocale>
#include <QIcon>
-#include <cassert>
using namespace GpgME;
using namespace Kleo;
@@ -514,7 +513,7 @@ QString Formatting::ownerTrustShort(Key::OwnerTrust trust)
case Key::Ultimate: return i18nc("ultimate trust", "ultimate");
case Key::Undefined: return i18nc("undefined trust", "undefined");
default:
- assert(!"unexpected owner trust value");
+ Q_ASSERT(!"unexpected owner trust value");
break;
}
return QString();
@@ -602,7 +601,7 @@ namespace
static QString keyToString(const Key &key)
{
- assert(!key.isNull());
+ Q_ASSERT(!key.isNull());
const QString email = Formatting::prettyEMail(key);
const QString name = Formatting::prettyName(key);