Skip to content

Commit 3a0e76f

Browse files
committed
Replace remaining 0 with nullptr in Qt code
Also used type-appropriate enum values such as Qt::NoItemFlags in some cases. All cases identified via -Wzero-as-null-pointer-constant
1 parent 9096276 commit 3a0e76f

18 files changed

+34
-36
lines changed

src/qt/addresstablemodel.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,8 +300,8 @@ QVariant AddressTableModel::headerData(int section, Qt::Orientation orientation,
300300

301301
Qt::ItemFlags AddressTableModel::flags(const QModelIndex &index) const
302302
{
303-
if(!index.isValid())
304-
return 0;
303+
if (!index.isValid()) return Qt::NoItemFlags;
304+
305305
AddressTableEntry *rec = static_cast<AddressTableEntry*>(index.internalPointer());
306306

307307
Qt::ItemFlags retval = Qt::ItemIsSelectable | Qt::ItemIsEnabled;

src/qt/bantablemodel.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,7 @@ QVariant BanTableModel::headerData(int section, Qt::Orientation orientation, int
145145

146146
Qt::ItemFlags BanTableModel::flags(const QModelIndex &index) const
147147
{
148-
if(!index.isValid())
149-
return 0;
148+
if (!index.isValid()) return Qt::NoItemFlags;
150149

151150
Qt::ItemFlags retval = Qt::ItemIsSelectable | Qt::ItemIsEnabled;
152151
return retval;

src/qt/bitcoin.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -243,15 +243,15 @@ void BitcoinApplication::createOptionsModel(bool resetSettings)
243243

244244
void BitcoinApplication::createWindow(const NetworkStyle *networkStyle)
245245
{
246-
window = new BitcoinGUI(m_node, platformStyle, networkStyle, 0);
246+
window = new BitcoinGUI(m_node, platformStyle, networkStyle, nullptr);
247247

248248
pollShutdownTimer = new QTimer(window);
249249
connect(pollShutdownTimer, &QTimer::timeout, window, &BitcoinGUI::detectShutdown);
250250
}
251251

252252
void BitcoinApplication::createSplashScreen(const NetworkStyle *networkStyle)
253253
{
254-
SplashScreen *splash = new SplashScreen(m_node, 0, networkStyle);
254+
SplashScreen *splash = new SplashScreen(m_node, nullptr, networkStyle);
255255
// We don't hold a direct pointer to the splash screen after creation, but the splash
256256
// screen will take care of deleting itself when finish() happens.
257257
splash->show();
@@ -429,7 +429,7 @@ void BitcoinApplication::shutdownResult()
429429

430430
void BitcoinApplication::handleRunawayException(const QString &message)
431431
{
432-
QMessageBox::critical(0, "Runaway exception", BitcoinGUI::tr("A fatal error occurred. Bitcoin can no longer continue safely and will quit.") + QString("\n\n") + message);
432+
QMessageBox::critical(nullptr, "Runaway exception", BitcoinGUI::tr("A fatal error occurred. Bitcoin can no longer continue safely and will quit.") + QString("\n\n") + message);
433433
::exit(EXIT_FAILURE);
434434
}
435435

@@ -503,7 +503,7 @@ int GuiMain(int argc, char* argv[])
503503
SetupUIArgs();
504504
std::string error;
505505
if (!node->parseParameters(argc, argv, error)) {
506-
QMessageBox::critical(0, QObject::tr(PACKAGE_NAME),
506+
QMessageBox::critical(nullptr, QObject::tr(PACKAGE_NAME),
507507
QObject::tr("Error parsing command line arguments: %1.").arg(QString::fromStdString(error)));
508508
return EXIT_FAILURE;
509509
}
@@ -540,12 +540,12 @@ int GuiMain(int argc, char* argv[])
540540
/// - Do not call GetDataDir(true) before this step finishes
541541
if (!fs::is_directory(GetDataDir(false)))
542542
{
543-
QMessageBox::critical(0, QObject::tr(PACKAGE_NAME),
544-
QObject::tr("Error: Specified data directory \"%1\" does not exist.").arg(QString::fromStdString(gArgs.GetArg("-datadir", ""))));
543+
QMessageBox::critical(nullptr, QObject::tr(PACKAGE_NAME),
544+
QObject::tr("Error: Specified data directory \"%1\" does not exist.").arg(QString::fromStdString(gArgs.GetArg("-datadir", ""))));
545545
return EXIT_FAILURE;
546546
}
547547
if (!node->readConfigFiles(error)) {
548-
QMessageBox::critical(0, QObject::tr(PACKAGE_NAME),
548+
QMessageBox::critical(nullptr, QObject::tr(PACKAGE_NAME),
549549
QObject::tr("Error: Cannot parse configuration file: %1.").arg(QString::fromStdString(error)));
550550
return EXIT_FAILURE;
551551
}
@@ -560,7 +560,7 @@ int GuiMain(int argc, char* argv[])
560560
try {
561561
node->selectParams(gArgs.GetChainName());
562562
} catch(std::exception &e) {
563-
QMessageBox::critical(0, QObject::tr(PACKAGE_NAME), QObject::tr("Error: %1").arg(e.what()));
563+
QMessageBox::critical(nullptr, QObject::tr(PACKAGE_NAME), QObject::tr("Error: %1").arg(e.what()));
564564
return EXIT_FAILURE;
565565
}
566566
#ifdef ENABLE_WALLET

src/qt/bitcoinamountfield.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ class AmountSpinBox: public QAbstractSpinBox
196196
if (text().isEmpty()) // Allow step-up with empty field
197197
return StepUpEnabled;
198198

199-
StepEnabled rv = 0;
199+
StepEnabled rv = StepNone;
200200
bool valid = false;
201201
CAmount val = value(&valid);
202202
if (valid) {
@@ -216,7 +216,7 @@ class AmountSpinBox: public QAbstractSpinBox
216216

217217
BitcoinAmountField::BitcoinAmountField(QWidget *parent) :
218218
QWidget(parent),
219-
amount(0)
219+
amount(nullptr)
220220
{
221221
amount = new AmountSpinBox(this);
222222
amount->setLocale(QLocale::c());

src/qt/intro.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ bool Intro::pickDataDirectory(interfaces::Node& node)
226226
}
227227
break;
228228
} catch (const fs::filesystem_error&) {
229-
QMessageBox::critical(0, tr(PACKAGE_NAME),
229+
QMessageBox::critical(nullptr, tr(PACKAGE_NAME),
230230
tr("Error: Specified data directory \"%1\" cannot be created.").arg(dataDir));
231231
/* fall through, back to choosing screen */
232232
}
@@ -286,7 +286,7 @@ void Intro::on_dataDirectory_textChanged(const QString &dataDirStr)
286286

287287
void Intro::on_ellipsisButton_clicked()
288288
{
289-
QString dir = QDir::toNativeSeparators(QFileDialog::getExistingDirectory(0, "Choose data directory", ui->dataDirectory->text()));
289+
QString dir = QDir::toNativeSeparators(QFileDialog::getExistingDirectory(nullptr, "Choose data directory", ui->dataDirectory->text()));
290290
if(!dir.isEmpty())
291291
ui->dataDirectory->setText(dir);
292292
}

src/qt/networkstyle.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,5 +88,5 @@ const NetworkStyle *NetworkStyle::instantiate(const QString &networkId)
8888
network_styles[x].titleAddText);
8989
}
9090
}
91-
return 0;
91+
return nullptr;
9292
}

src/qt/paymentserver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ PaymentServer::PaymentServer(QObject* parent, bool startLocalServer) :
223223

224224
if (!uriServer->listen(name)) {
225225
// constructor is called early in init, so don't use "Q_EMIT message()" here
226-
QMessageBox::critical(0, tr("Payment request error"),
226+
QMessageBox::critical(nullptr, tr("Payment request error"),
227227
tr("Cannot start bitcoin: click-to-pay handler"));
228228
}
229229
else {

src/qt/peertablemodel.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,15 +96,15 @@ class PeerTablePriv
9696
if (idx >= 0 && idx < cachedNodeStats.size())
9797
return &cachedNodeStats[idx];
9898

99-
return 0;
99+
return nullptr;
100100
}
101101
};
102102

103103
PeerTableModel::PeerTableModel(interfaces::Node& node, ClientModel *parent) :
104104
QAbstractTableModel(parent),
105105
m_node(node),
106106
clientModel(parent),
107-
timer(0)
107+
timer(nullptr)
108108
{
109109
columns << tr("NodeId") << tr("Node/Service") << tr("Ping") << tr("Sent") << tr("Received") << tr("User Agent");
110110
priv.reset(new PeerTablePriv());
@@ -197,8 +197,7 @@ QVariant PeerTableModel::headerData(int section, Qt::Orientation orientation, in
197197

198198
Qt::ItemFlags PeerTableModel::flags(const QModelIndex &index) const
199199
{
200-
if(!index.isValid())
201-
return 0;
200+
if (!index.isValid()) return Qt::NoItemFlags;
202201

203202
Qt::ItemFlags retval = Qt::ItemIsSelectable | Qt::ItemIsEnabled;
204203
return retval;

src/qt/platformstyle.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,6 @@ const PlatformStyle *PlatformStyle::instantiate(const QString &platformId)
139139
platform_styles[x].useExtraSpacing);
140140
}
141141
}
142-
return 0;
142+
return nullptr;
143143
}
144144

src/qt/qvalidatedlineedit.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
QValidatedLineEdit::QValidatedLineEdit(QWidget *parent) :
1111
QLineEdit(parent),
1212
valid(true),
13-
checkValidator(0)
13+
checkValidator(nullptr)
1414
{
1515
connect(this, &QValidatedLineEdit::textChanged, this, &QValidatedLineEdit::markValid);
1616
}

0 commit comments

Comments
 (0)