From: Uwe Hermann Date: Sat, 6 Feb 2016 21:07:30 +0000 (+0100) Subject: Prefer Qt string multi-arg form over arg chaining. X-Git-Tag: pulseview-0.4.0~335 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=744aa24fc5a7084461e4e70595b96f1c3eac65e4;p=pulseview.git Prefer Qt string multi-arg form over arg chaining. This has performance/memory advantages and avoids some potential bugs and/or security problems. --- diff --git a/pv/data/decode/row.cpp b/pv/data/decode/row.cpp index 70a06093..ca16ae69 100644 --- a/pv/data/decode/row.cpp +++ b/pv/data/decode/row.cpp @@ -52,8 +52,8 @@ const QString Row::title() const { if (decoder_ && decoder_->name && row_ && row_->desc) return QString("%1: %2") - .arg(QString::fromUtf8(decoder_->name)) - .arg(QString::fromUtf8(row_->desc)); + .arg(QString::fromUtf8(decoder_->name), + QString::fromUtf8(row_->desc)); if (decoder_ && decoder_->name) return QString::fromUtf8(decoder_->name); if (row_ && row_->desc) diff --git a/pv/dialogs/about.cpp b/pv/dialogs/about.cpp index 20a02993..0a47bdda 100644 --- a/pv/dialogs/about.cpp +++ b/pv/dialogs/about.cpp @@ -49,10 +49,10 @@ About::About(shared_ptr context, QWidget *parent) : /* Setup the version field */ ui->versionInfo->setText(tr("%1 %2
%3
%4") - .arg(QApplication::applicationName()) - .arg(QApplication::applicationVersion()) - .arg(tr("GNU GPL, version 3 or later")) - .arg(QApplication::organizationDomain())); + .arg(QApplication::applicationName(), + QApplication::applicationVersion(), + tr("GNU GPL, version 3 or later"), + QApplication::organizationDomain())); ui->versionInfo->setOpenExternalLinks(true); s.append(""); @@ -63,8 +63,8 @@ About::About(shared_ptr context, QWidget *parent) : ""); for (auto entry : context->drivers()) { s.append(QString("") - .arg(QString::fromUtf8(entry.first.c_str())) - .arg(QString::fromUtf8(entry.second->long_name().c_str()))); + .arg(QString::fromUtf8(entry.first.c_str()), + QString::fromUtf8(entry.second->long_name().c_str()))); } s.append(""); for (auto entry : context->input_formats()) { s.append(QString("") - .arg(QString::fromUtf8(entry.first.c_str())) - .arg(QString::fromUtf8(entry.second->description().c_str()))); + .arg(QString::fromUtf8(entry.first.c_str()), + QString::fromUtf8(entry.second->description().c_str()))); } s.append(""); for (auto entry : context->output_formats()) { s.append(QString("") - .arg(QString::fromUtf8(entry.first.c_str())) - .arg(QString::fromUtf8(entry.second->description().c_str()))); + .arg(QString::fromUtf8(entry.first.c_str()), + QString::fromUtf8(entry.second->description().c_str()))); } #ifdef ENABLE_DECODE @@ -92,8 +92,8 @@ About::About(shared_ptr context, QWidget *parent) : for (const GSList *l = srd_decoder_list(); l; l = l->next) { dec = (struct srd_decoder *)l->data; s.append(QString("") - .arg(QString::fromUtf8(dec->id)) - .arg(QString::fromUtf8(dec->longname))); + .arg(QString::fromUtf8(dec->id), + QString::fromUtf8(dec->longname))); } #endif diff --git a/pv/dialogs/connect.cpp b/pv/dialogs/connect.cpp index 4d33cc9f..d2cb2a31 100644 --- a/pv/dialogs/connect.cpp +++ b/pv/dialogs/connect.cpp @@ -113,7 +113,7 @@ void Connect::populate_drivers() if (supported_device) drivers_.addItem(QString("%1 (%2)").arg( - driver->long_name().c_str()).arg(name.c_str()), + driver->long_name().c_str(), name.c_str()), qVariantFromValue(driver)); } } @@ -123,7 +123,7 @@ void Connect::populate_serials(shared_ptr driver) serial_devices_.clear(); for (auto serial : device_manager_.context()->serials(driver)) serial_devices_.addItem(QString("%1 (%2)").arg( - serial.first.c_str()).arg(serial.second.c_str()), + serial.first.c_str(), serial.second.c_str()), QString::fromStdString(serial.first)); } diff --git a/pv/mainwindow.cpp b/pv/mainwindow.cpp index 65071330..1a05907c 100644 --- a/pv/mainwindow.cpp +++ b/pv/mainwindow.cpp @@ -274,7 +274,7 @@ void MainWindow::export_file(shared_ptr format, filter += "(*.*)"; else filter += QString("(*.%1);;%2 (*.*)").arg( - QString::fromStdString(join(exts, ", *."))).arg( + QString::fromStdString(join(exts, ", *.")), tr("All Files")); // Show the file dialog @@ -315,7 +315,7 @@ void MainWindow::import_file(shared_ptr format) const vector exts = format->extensions(); const QString filter = exts.empty() ? "" : tr("%1 files (*.%2)").arg( - QString::fromStdString(format->description())).arg( + QString::fromStdString(format->description()), QString::fromStdString(join(exts, ", *."))); // Show the file dialog diff --git a/pv/view/decodetrace.cpp b/pv/view/decodetrace.cpp index b2ead1a6..e5b84f99 100644 --- a/pv/view/decodetrace.cpp +++ b/pv/view/decodetrace.cpp @@ -793,8 +793,8 @@ void DecodeTrace::create_decoder_form(int index, connect(combo, SIGNAL(currentIndexChanged(int)), this, SLOT(on_channel_selected(int))); decoder_form->addRow(tr("%1 (%2) *") - .arg(QString::fromUtf8(pdch->name)) - .arg(QString::fromUtf8(pdch->desc)), combo); + .arg(QString::fromUtf8(pdch->name), + QString::fromUtf8(pdch->desc)), combo); const ChannelSelector s = {combo, dec, pdch}; channel_selectors_.push_back(s); @@ -808,8 +808,8 @@ void DecodeTrace::create_decoder_form(int index, connect(combo, SIGNAL(currentIndexChanged(int)), this, SLOT(on_channel_selected(int))); decoder_form->addRow(tr("%1 (%2)") - .arg(QString::fromUtf8(pdch->name)) - .arg(QString::fromUtf8(pdch->desc)), combo); + .arg(QString::fromUtf8(pdch->name), + QString::fromUtf8(pdch->desc)), combo); const ChannelSelector s = {combo, dec, pdch}; channel_selectors_.push_back(s);
%1%2
" + @@ -72,8 +72,8 @@ About::About(shared_ptr context, QWidget *parent) : "
%1%2
" + @@ -81,8 +81,8 @@ About::About(shared_ptr context, QWidget *parent) : "
%1%2
%1%2