Commit b222e459 authored by Daniel Vrátil's avatar Daniel Vrátil 🤖
Browse files

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.
parent 4cca867c
......@@ -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);
......
......@@ -40,7 +40,6 @@
#include <gpgme++/key.h>
#include <cassert>
using namespace Kleo;
using namespace GpgME;
......
......@@ -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;
}
......
......@@ -79,7 +79,6 @@ const char * auditlog =
#include <QDebug>
#include <assert.h>
#include <QApplication>
#include <KLocalizedString>
#include <QCommandLineParser>
......
......@@ -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: ";
......
......@@ -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);
......
......@@ -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)));
......
......@@ -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)),
......
......@@ -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);
......
......@@ -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:
......
......@@ -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);
......
......@@ -53,7 +53,6 @@
#include <gpgme++/key.h&g