]> sigrok.org Git - pulseview.git/commitdiff
Handle C-strings as UTF-8
authorJoel Holdsworth <redacted>
Sat, 28 Dec 2013 14:36:19 +0000 (15:36 +0100)
committerJoel Holdsworth <redacted>
Sat, 28 Dec 2013 14:49:05 +0000 (15:49 +0100)
pv/data/decode/annotation.cpp
pv/dialogs/about.cpp
pv/dialogs/connect.cpp
pv/prop/binding/deviceoptions.cpp
pv/prop/string.cpp
pv/sigsession.cpp
pv/toolbars/samplingbar.cpp
pv/view/decodetrace.cpp
pv/widgets/decodermenu.cpp

index 6a30921e71deec541a7e8e929bcdf13e8ead1fa4..e17dcb5177cd73ab818d31e08a8c84d60133df15 100644 (file)
@@ -43,7 +43,7 @@ Annotation::Annotation(const srd_proto_data *const pdata) :
 
        const char *const *annotations = (char**)pda->ann_text;
        while(*annotations) {
-               _annotations.push_back(QString(*annotations));
+               _annotations.push_back(QString::fromUtf8(*annotations));
                annotations++;
        }
 }
index 806dc4c5c057c6ee2bafa76e1700039230b18367..8484e47b371062426620dd2d4e27befa8c7c2dc3 100644 (file)
@@ -65,8 +65,8 @@ About::About(QWidget *parent) :
        drivers = sr_driver_list();
        for (int i = 0; drivers[i]; ++i) {
                s.append(QString("<tr><td><i>%1</i></td><td>%2</td></tr>")
-                        .arg(QString(drivers[i]->name))
-                        .arg(QString(drivers[i]->longname)));
+                        .arg(QString::fromUtf8(drivers[i]->name))
+                        .arg(QString::fromUtf8(drivers[i]->longname)));
        }
 
        s.append("<tr><td colspan=\"2\"><b>" +
@@ -75,8 +75,8 @@ About::About(QWidget *parent) :
        inputs = sr_input_list();
        for (int i = 0; inputs[i]; ++i) {
                s.append(QString("<tr><td><i>%1</i></td><td>%2</td></tr>")
-                        .arg(QString(inputs[i]->id))
-                        .arg(QString(inputs[i]->description)));
+                        .arg(QString::fromUtf8(inputs[i]->id))
+                        .arg(QString::fromUtf8(inputs[i]->description)));
        }
 
        s.append("<tr><td colspan=\"2\"><b>" +
@@ -85,8 +85,8 @@ About::About(QWidget *parent) :
        outputs = sr_output_list();
        for (int i = 0; outputs[i]; ++i) {
                s.append(QString("<tr><td><i>%1</i></td><td>%2</td></tr>")
-                       .arg(QString(outputs[i]->id))
-                       .arg(QString(outputs[i]->description)));
+                       .arg(QString::fromUtf8(outputs[i]->id))
+                       .arg(QString::fromUtf8(outputs[i]->description)));
        }
 
        s.append("<tr><td colspan=\"2\"><b>" +
@@ -95,8 +95,8 @@ About::About(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(dec->id))
-                        .arg(QString(dec->longname)));
+                        .arg(QString::fromUtf8(dec->id))
+                        .arg(QString::fromUtf8(dec->longname)));
        }
 
        s.append("</table>");
index f8fbe67f79bb1bf2260f7e3749e0044c2b139abd..b7efe4f3442a875bd40dc37c2ea01d56852ff2d2 100644 (file)
@@ -163,7 +163,7 @@ void Connect::scan_pressed()
        BOOST_FOREACH(sr_dev_inst *const sdi, devices)
        {
                const string title = DeviceManager::format_device_title(sdi);
-               QString text(title.c_str());
+               QString text = QString::fromUtf8(title.c_str());
                if (sdi->probes) {
                        text += QString(" with %1 probes").arg(
                                g_slist_length(sdi->probes));
index e8ae002bae8ba0c0339b2da1fb5f9861d71fb5c3..ff7be104feb8406af3bdcfc4bd22c7dd34ef0e2b 100644 (file)
@@ -66,7 +66,7 @@ DeviceOptions::DeviceOptions(struct sr_dev_inst *sdi) :
                if (sr_config_list(_sdi->driver, _sdi, NULL, key, &gvar_list) != SR_OK)
                        gvar_list = NULL;
 
-               const QString name(info->name);
+               const QString name = QString::fromUtf8(info->name);
 
                switch(key)
                {
@@ -169,11 +169,11 @@ QString DeviceOptions::print_gvariant(GVariant *const gvar)
        QString s;
 
        if (g_variant_is_of_type(gvar, G_VARIANT_TYPE("s")))
-               s = QString(g_variant_get_string(gvar, NULL));
+               s = QString::fromUtf8(g_variant_get_string(gvar, NULL));
        else
        {
                gchar *const text = g_variant_print(gvar, FALSE);
-               s = QString(text);
+               s = QString::fromUtf8(text);
                g_free(text);
        }
 
@@ -184,14 +184,14 @@ QString DeviceOptions::print_timebase(GVariant *const gvar)
 {
        uint64_t p, q;
        g_variant_get(gvar, "(tt)", &p, &q);
-       return QString(sr_period_string(p * q));
+       return QString::fromUtf8(sr_period_string(p * q));
 }
 
 QString DeviceOptions::print_vdiv(GVariant *const gvar)
 {
        uint64_t p, q;
        g_variant_get(gvar, "(tt)", &p, &q);
-       return QString(sr_voltage_string(p, q));
+       return QString::fromUtf8(sr_voltage_string(p, q));
 }
 
 QString DeviceOptions::print_voltage_threshold(GVariant *const gvar)
@@ -200,7 +200,7 @@ QString DeviceOptions::print_voltage_threshold(GVariant *const gvar)
        char buf[64];
        g_variant_get(gvar, "(dd)", &lo, &hi);
        snprintf(buf, sizeof(buf), "L<%.1fV H>%.1fV", lo, hi);
-       return QString(buf);
+       return QString::fromUtf8(buf);
 }
 
 } // binding
index c2b2c67c26a5c97377dff2b853759206ef65ffe7..4921129e9242bdb61c22e1c9ddb5aedfed958091 100644 (file)
@@ -48,7 +48,7 @@ QWidget* String::get_widget(QWidget *parent, bool auto_commit)
 
        GVariant *const value = _getter ? _getter() : NULL;
        if (value) {
-               _line_edit->setText(QString(
+               _line_edit->setText(QString::fromUtf8(
                        g_variant_get_string(value, NULL)));
                g_variant_unref(value);
        }
index 3213758ef263894c215cc83055849593700aa099..2e7be37f9fb499e85156bd8480330d80059e7b89 100644 (file)
@@ -223,7 +223,8 @@ bool SigSession::add_decoder(srd_decoder *const dec)
                        {
                                shared_ptr<view::LogicSignal> l =
                                        dynamic_pointer_cast<view::LogicSignal>(s);
-                               if (l && QString(probe->name).toLower().contains(
+                               if (l && QString::fromUtf8(probe->name).
+                                       toLower().contains(
                                        l->get_name().toLower()))
                                        probes[probe] = l;
                        }
index db7e8e0b1a1dc330397099ea0cfb63794db093a6..3bd2cb39519eaab2872a439a1f0fabc26c8c9e07 100644 (file)
@@ -92,7 +92,7 @@ SamplingBar::SamplingBar(SigSession &session, QWidget *parent) :
        {
                const uint64_t &l = RecordLengths[i];
                char *const text = sr_si_string_u64(l, " samples");
-               _record_length_selector.addItem(QString(text),
+               _record_length_selector.addItem(QString::fromUtf8(text),
                        qVariantFromValue(l));
                g_free(text);
 
@@ -219,7 +219,7 @@ void SamplingBar::update_sample_rate_selector()
                for (unsigned int i = 0; i < num_elements; i++)
                {
                        char *const s = sr_samplerate_string(elements[i]);
-                       _sample_rate_list.addItem(QString(s),
+                       _sample_rate_list.addItem(QString::fromUtf8(s),
                                qVariantFromValue(elements[i]));
                        g_free(s);
                }
index e275a112ba82d889c0f5b0a51613e2f6b4c91d5d..cf5cd2ee35e1cc496f953a44b63fdd711756bdfc 100644 (file)
@@ -78,7 +78,8 @@ const QColor DecodeTrace::Colours[7] = {
 
 DecodeTrace::DecodeTrace(pv::SigSession &session,
        boost::shared_ptr<pv::data::DecoderStack> decoder_stack, int index) :
-       Trace(session, QString(decoder_stack->stack().front()->decoder()->name)),
+       Trace(session, QString::fromUtf8(
+               decoder_stack->stack().front()->decoder()->name)),
        _decoder_stack(decoder_stack),
        _delete_mapper(this)
 {
@@ -403,7 +404,8 @@ void DecodeTrace::create_decoder_form(int index,
        assert(decoder);
 
        pv::widgets::DecoderGroupBox *const group =
-               new pv::widgets::DecoderGroupBox(decoder->name);
+               new pv::widgets::DecoderGroupBox(
+                       QString::fromUtf8(decoder->name));
 
        _delete_mapper.setMapping(group, index);
        connect(group, SIGNAL(delete_decoder()), &_delete_mapper, SLOT(map()));
index 68fc478124e0718d5fc9b22263766d8db1582f5f..3273123ecc40cf6bbf66b8c5122765a8561c570d 100644 (file)
@@ -33,7 +33,7 @@ DecoderMenu::DecoderMenu(QWidget *parent) :
                (GSList*)srd_decoder_list()), decoder_name_cmp);
        for(; l; l = l->next)
        {
-               QAction *const action = addAction(QString(
+               QAction *const action = addAction(QString::fromUtf8(
                        ((srd_decoder*)l->data)->name));
                action->setData(qVariantFromValue(l->data));
                _mapper.setMapping(action, action);