]> sigrok.org Git - pulseview.git/commitdiff
Prefer Qt string multi-arg form over arg chaining.
authorUwe Hermann <redacted>
Sat, 6 Feb 2016 21:07:30 +0000 (22:07 +0100)
committerUwe Hermann <redacted>
Sat, 13 Feb 2016 19:41:33 +0000 (20:41 +0100)
This has performance/memory advantages and avoids some potential bugs
and/or security problems.

pv/data/decode/row.cpp
pv/dialogs/about.cpp
pv/dialogs/connect.cpp
pv/mainwindow.cpp
pv/view/decodetrace.cpp

index 70a060938aedb11642ae2eb8e7526ac8054d295c..ca16ae69fd0d496d7be33bb3e2cb73ea49d2ce1e 100644 (file)
@@ -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)
index 20a02993b59cafa1360ea227e7f0de032b9c241f..0a47bdda92fa48938e7b78a33096eca860ff7e29 100644 (file)
@@ -49,10 +49,10 @@ About::About(shared_ptr<Context> context, QWidget *parent) :
 
        /* Setup the version field */
        ui->versionInfo->setText(tr("%1 %2<br />%3<br /><a href=\"%4\">%4</a>")
-                                .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("<table>");
@@ -63,8 +63,8 @@ About::About(shared_ptr<Context> context, QWidget *parent) :
                "</b></td></tr>");
        for (auto entry : context->drivers()) {
                s.append(QString("<tr><td><i>%1</i></td><td>%2</td></tr>")
-                        .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("<tr><td colspan=\"2\"><b>" +
@@ -72,8 +72,8 @@ About::About(shared_ptr<Context> context, QWidget *parent) :
                "</b></td></tr>");
        for (auto entry : context->input_formats()) {
                s.append(QString("<tr><td><i>%1</i></td><td>%2</td></tr>")
-                        .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("<tr><td colspan=\"2\"><b>" +
@@ -81,8 +81,8 @@ About::About(shared_ptr<Context> context, QWidget *parent) :
                "</b></td></tr>");
        for (auto entry : context->output_formats()) {
                s.append(QString("<tr><td><i>%1</i></td><td>%2</td></tr>")
-                        .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> context, QWidget *parent) :
        for (const GSList *l = srd_decoder_list(); l; l = l->next) {
                dec = (struct srd_decoder *)l->data;
                s.append(QString("<tr><td><i>%1</i></td><td>%2</td></tr>")
-                        .arg(QString::fromUtf8(dec->id))
-                        .arg(QString::fromUtf8(dec->longname)));
+                        .arg(QString::fromUtf8(dec->id),
+                             QString::fromUtf8(dec->longname)));
        }
 #endif
 
index 4d33cc9f3b6d1d2e1ebbc798147f53e307d80744..d2cb2a313e24b8932c48a6e9ddb957f97109854c 100644 (file)
@@ -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> 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));
 }
 
index 65071330da07e1d24c5955448ad44efe3f929383..1a05907c9c1a4470be862fdf2691887411b915e3 100644 (file)
@@ -274,7 +274,7 @@ void MainWindow::export_file(shared_ptr<OutputFormat> 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<InputFormat> format)
        const vector<string> 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
index b2ead1a66848600e1ae11425fe874d708b73f39a..e5b84f9945b54788ed4b8c36ad1da5e56ddc7b51 100644 (file)
@@ -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("<b>%1</b> (%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("<b>%1</b> (%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);