Fix clazy warnings regarding range-for references
authorSoeren Apel <soeren@apelpie.net>
Sun, 21 Oct 2018 19:22:01 +0000 (21:22 +0200)
committerSoeren Apel <soeren@apelpie.net>
Sun, 21 Oct 2018 19:22:01 +0000 (21:22 +0200)
The warnings that are fixed are of this type:
warning: Missing reference in range-for with non trivial type (std::__cxx11::string) [-Wclazy-range-loop]

25 files changed:
main.cpp
pv/application.cpp
pv/binding/inputoutput.cpp
pv/data/analog.cpp
pv/data/decodesignal.cpp
pv/data/logic.cpp
pv/data/signalbase.cpp
pv/devicemanager.cpp
pv/devices/inputfile.cpp
pv/dialogs/connect.cpp
pv/dialogs/settings.cpp
pv/globalsettings.cpp
pv/mainwindow.cpp
pv/popups/channels.cpp
pv/session.cpp
pv/storesession.cpp
pv/views/trace/analogsignal.cpp
pv/views/trace/header.cpp
pv/views/trace/tracegroup.cpp
pv/views/trace/tracetreeitemowner.cpp
pv/views/trace/view.cpp
pv/views/trace/viewport.cpp
pv/views/trace/viewwidget.cpp
pv/views/viewbase.cpp
pv/widgets/devicetoolbutton.cpp

index 4bd6388e1051fd506d99ae24f19fa5d43704346f..455d7afd3d2b7e49f182da829437b0d459f785df 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -316,7 +316,7 @@ int main(int argc, char *argv[])
                        if (open_files.empty())
                                w.add_default_session();
                        else
-                               for (string open_file : open_files)
+                               for (string& open_file : open_files)
                                        w.add_session_with_file(open_file, open_file_format);
 
 #ifdef ENABLE_SIGNALS
index f588fa3714ea44b8a17d63dbd3957923742018da..5a6e28a1da996034aa24218df7ef2d66eb425543 100644 (file)
@@ -127,17 +127,17 @@ void Application::collect_version_info(shared_ptr<sigrok::Context> context)
 #endif
 
        // Device drivers
-       for (auto entry : context->drivers())
+       for (auto& entry : context->drivers())
                driver_list_.emplace_back(QString::fromUtf8(entry.first.c_str()),
                        QString::fromUtf8(entry.second->long_name().c_str()));
 
        // Input formats
-       for (auto entry : context->input_formats())
+       for (auto& entry : context->input_formats())
                input_format_list_.emplace_back(QString::fromUtf8(entry.first.c_str()),
                        QString::fromUtf8(entry.second->description().c_str()));
 
        // Output formats
-       for (auto entry : context->output_formats())
+       for (auto& entry : context->output_formats())
                output_format_list_.emplace_back(QString::fromUtf8(entry.first.c_str()),
                        QString::fromUtf8(entry.second->description().c_str()));
 
@@ -159,35 +159,35 @@ void Application::print_version_info()
        cout << PV_TITLE << " " << PV_VERSION_STRING << endl;
 
        cout << endl << "Libraries and features:" << endl;
-       for (pair<QString, QString> &entry : version_info_)
+       for (pair<QString, QString>entry : version_info_)
                cout << "  " << entry.first.toStdString() << " " << entry.second.toStdString() << endl;
 
        cout << endl << "Firmware search paths:" << endl;
-       for (QString &entry : fw_path_list_)
+       for (QStringentry : fw_path_list_)
                cout << "  " << entry.toStdString() << endl;
 
        cout << endl << "Protocol decoder search paths:" << endl;
-       for (QString &entry : pd_path_list_)
+       for (QStringentry : pd_path_list_)
                cout << "  " << entry.toStdString() << endl;
 
        cout << endl << "Supported hardware drivers:" << endl;
-       for (pair<QString, QString> &entry : driver_list_)
+       for (pair<QString, QString>entry : driver_list_)
                cout << "  " << entry.first.leftJustified(21, ' ').toStdString() <<
                entry.second.toStdString() << endl;
 
        cout << endl << "Supported input formats:" << endl;
-       for (pair<QString, QString> &entry : input_format_list_)
+       for (pair<QString, QString>entry : input_format_list_)
                cout << "  " << entry.first.leftJustified(21, ' ').toStdString() <<
                entry.second.toStdString() << endl;
 
        cout << endl << "Supported output formats:" << endl;
-       for (pair<QString, QString> &entry : output_format_list_)
+       for (pair<QString, QString>entry : output_format_list_)
                cout << "  " << entry.first.leftJustified(21, ' ').toStdString() <<
                entry.second.toStdString() << endl;
 
 #ifdef ENABLE_DECODE
        cout << endl << "Supported protocol decoders:" << endl;
-       for (pair<QString, QString> &entry : pd_list_)
+       for (pair<QString, QString>entry : pd_list_)
                cout << "  " << entry.first.leftJustified(21, ' ').toStdString() <<
                entry.second.toStdString() << endl;
 #endif
index 0d9b2d0d72298bc66e18c5f0faa40615c36d091e..f9a061c76e78c7b7e77a33ec1d04250328263b70 100644 (file)
@@ -59,7 +59,7 @@ namespace binding {
 InputOutput::InputOutput(
        const map<string, shared_ptr<Option>> &options)
 {
-       for (pair<string, shared_ptr<Option>> o : options) {
+       for (const pair<string, shared_ptr<Option>>& o : options) {
                const shared_ptr<Option> &opt = o.second;
                assert(opt);
 
index da025882949ea8486638198fcb5fe124c22fa7ff..f8fe473d3681ebc31f0850d052af2d952d8fbae4 100644 (file)
@@ -74,7 +74,7 @@ double Analog::get_samplerate() const
 uint64_t Analog::max_sample_count() const
 {
        uint64_t l = 0;
-       for (const shared_ptr<AnalogSegment> s : segments_) {
+       for (const shared_ptr<AnalogSegment>& s : segments_) {
                assert(s);
                l = max(l, s->get_sample_count());
        }
index 9b40540c7032b058f988f8cb8d903d6763b3d97f..68b17a65d076668b182172bee71f5a30605cb232 100644 (file)
@@ -200,12 +200,12 @@ void DecodeSignal::begin_decode()
        // Make sure that all assigned channels still provide logic data
        // (can happen when a converted signal was assigned but the
        // conversion removed in the meanwhile)
-       for (data::DecodeChannel &ch : channels_)
+       for (data::DecodeChannelch : channels_)
                if (ch.assigned_signal && !(ch.assigned_signal->logic_data() != nullptr))
                        ch.assigned_signal = nullptr;
 
        // Check that all decoders have the required channels
-       for (const shared_ptr<decode::Decoder> &dec : stack_)
+       for (const shared_ptr<decode::Decoder>dec : stack_)
                if (!dec->have_required_channels()) {
                        set_error_message(tr("One or more required channels "
                                "have not been specified"));
@@ -214,7 +214,7 @@ void DecodeSignal::begin_decode()
 
        // Map out all the annotation classes
        int row_index = 0;
-       for (const shared_ptr<decode::Decoder> &dec : stack_) {
+       for (const shared_ptr<decode::Decoder>dec : stack_) {
                assert(dec);
                const srd_decoder *const decc = dec->decoder();
                assert(dec->decoder());
@@ -295,7 +295,7 @@ void DecodeSignal::auto_assign_signals(const shared_ptr<Decoder> dec)
        bool new_assignment = false;
 
        // Try to auto-select channels that don't have signals assigned yet
-       for (data::DecodeChannel &ch : channels_) {
+       for (data::DecodeChannelch : channels_) {
                // If a decoder is given, auto-assign only its channels
                if (dec && (ch.decoder_ != dec))
                        continue;
@@ -307,7 +307,7 @@ void DecodeSignal::auto_assign_signals(const shared_ptr<Decoder> dec)
                ch_name = ch_name.replace(QRegExp("[-_.]"), " ");
 
                shared_ptr<data::SignalBase> match;
-               for (shared_ptr<data::SignalBase> s : session_.signalbases()) {
+               for (const shared_ptr<data::SignalBase>& s : session_.signalbases()) {
                        if (!s->enabled())
                                continue;
 
@@ -344,7 +344,7 @@ void DecodeSignal::auto_assign_signals(const shared_ptr<Decoder> dec)
 
 void DecodeSignal::assign_signal(const uint16_t channel_id, const SignalBase *signal)
 {
-       for (data::DecodeChannel &ch : channels_)
+       for (data::DecodeChannelch : channels_)
                if (ch.id == channel_id) {
                        ch.assigned_signal = signal;
                        logic_mux_data_invalid_ = true;
@@ -365,7 +365,7 @@ int DecodeSignal::get_assigned_signal_count() const
 
 void DecodeSignal::set_initial_pin_state(const uint16_t channel_id, const int init_state)
 {
-       for (data::DecodeChannel &ch : channels_)
+       for (data::DecodeChannelch : channels_)
                if (ch.id == channel_id)
                        ch.initial_pin_state = init_state;
 
@@ -405,7 +405,7 @@ int64_t DecodeSignal::get_working_sample_count(uint32_t segment_id) const
        int64_t count = std::numeric_limits<int64_t>::max();
        bool no_signals_assigned = true;
 
-       for (const data::DecodeChannel &ch : channels_)
+       for (const data::DecodeChannelch : channels_)
                if (ch.assigned_signal) {
                        no_signals_assigned = false;
 
@@ -450,7 +450,7 @@ vector<Row> DecodeSignal::visible_rows() const
 
        vector<Row> rows;
 
-       for (const shared_ptr<decode::Decoder> &dec : stack_) {
+       for (const shared_ptr<decode::Decoder>dec : stack_) {
                assert(dec);
                if (!dec->shown())
                        continue;
@@ -531,7 +531,7 @@ void DecodeSignal::save_settings(QSettings &settings) const
 
        // Save decoder stack
        int decoder_idx = 0;
-       for (shared_ptr<decode::Decoder> decoder : stack_) {
+       for (const shared_ptr<decode::Decoder>& decoder : stack_) {
                settings.beginGroup("decoder" + QString::number(decoder_idx++));
 
                settings.setValue("id", decoder->decoder()->id);
@@ -544,7 +544,7 @@ void DecodeSignal::save_settings(QSettings &settings) const
                // Note: decode::Decoder::options() returns only the options
                // that differ from the default. See binding::Decoder::getter()
                int i = 0;
-               for (auto option : options) {
+               for (auto& option : options) {
                        settings.beginGroup("option" + QString::number(i));
                        settings.setValue("name", QString::fromStdString(option.first));
                        GlobalSettings::store_gvariant(settings, option.second);
@@ -644,7 +644,7 @@ void DecodeSignal::restore_settings(QSettings &settings)
 
                QString assigned_signal_name = settings.value("assigned_signal_name").toString();
 
-               for (shared_ptr<data::SignalBase> signal : signalbases)
+               for (const shared_ptr<data::SignalBase>& signal : signalbases)
                        if (signal->name() == assigned_signal_name)
                                channel->assigned_signal = signal.get();
 
@@ -673,7 +673,7 @@ uint32_t DecodeSignal::get_input_segment_count() const
        uint64_t count = std::numeric_limits<uint64_t>::max();
        bool no_signals_assigned = true;
 
-       for (const data::DecodeChannel &ch : channels_)
+       for (const data::DecodeChannelch : channels_)
                if (ch.assigned_signal) {
                        no_signals_assigned = false;
 
@@ -693,7 +693,7 @@ uint32_t DecodeSignal::get_input_samplerate(uint32_t segment_id) const
 {
        double samplerate = 0;
 
-       for (const data::DecodeChannel &ch : channels_)
+       for (const data::DecodeChannelch : channels_)
                if (ch.assigned_signal) {
                        const shared_ptr<Logic> logic_data = ch.assigned_signal->logic_data();
                        if (!logic_data || logic_data->logic_segments().empty())
@@ -719,7 +719,7 @@ void DecodeSignal::update_channel_list()
        uint16_t id = 0;
 
        // Copy existing entries, create new as needed
-       for (shared_ptr<Decoder> decoder : stack_) {
+       for (shared_ptr<Decoder>& decoder : stack_) {
                const srd_decoder* srd_d = decoder->decoder();
                const GSList *l;
 
@@ -729,7 +729,7 @@ void DecodeSignal::update_channel_list()
                        bool ch_added = false;
 
                        // Copy but update ID if this channel was in the list before
-                       for (data::DecodeChannel &ch : prev_channels)
+                       for (data::DecodeChannelch : prev_channels)
                                if (ch.pdch_ == pdch) {
                                        ch.id = id++;
                                        channels_.push_back(ch);
@@ -752,7 +752,7 @@ void DecodeSignal::update_channel_list()
                        bool ch_added = false;
 
                        // Copy but update ID if this channel was in the list before
-                       for (data::DecodeChannel &ch : prev_channels)
+                       for (data::DecodeChannelch : prev_channels)
                                if (ch.pdch_ == pdch) {
                                        ch.id = id++;
                                        channels_.push_back(ch);
@@ -777,8 +777,8 @@ void DecodeSignal::update_channel_list()
        } else {
                // Same number but assignment may still differ, so compare all channels
                for (size_t i = 0; i < channels_.size(); i++) {
-                       const data::DecodeChannel &p_ch = prev_channels[i];
-                       const data::DecodeChannel &ch = channels_[i];
+                       const data::DecodeChannelp_ch = prev_channels[i];
+                       const data::DecodeChannelch = channels_[i];
 
                        if ((p_ch.pdch_ != ch.pdch_) ||
                                (p_ch.assigned_signal != ch.assigned_signal)) {
@@ -798,7 +798,7 @@ void DecodeSignal::commit_decoder_channels()
        for (shared_ptr<decode::Decoder> dec : stack_) {
                vector<data::DecodeChannel*> channel_list;
 
-               for (data::DecodeChannel &ch : channels_)
+               for (data::DecodeChannelch : channels_)
                        if (ch.decoder_ == dec)
                                channel_list.push_back(&ch);
 
@@ -807,7 +807,7 @@ void DecodeSignal::commit_decoder_channels()
 
        // Channel bit IDs must be in sync with the channel's apperance in channels_
        int id = 0;
-       for (data::DecodeChannel &ch : channels_)
+       for (data::DecodeChannelch : channels_)
                if (ch.assigned_signal)
                        ch.bit_id = id++;
 }
@@ -824,7 +824,7 @@ void DecodeSignal::mux_logic_samples(uint32_t segment_id, const int64_t start, c
        vector<uint8_t> signal_in_bytepos;
        vector<uint8_t> signal_in_bitpos;
 
-       for (data::DecodeChannel &ch : channels_)
+       for (data::DecodeChannelch : channels_)
                if (ch.assigned_signal) {
                        const shared_ptr<Logic> logic_data = ch.assigned_signal->logic_data();
 
@@ -1110,7 +1110,7 @@ void DecodeSignal::start_srd_session()
                if (samplerate)
                        srd_session_metadata_set(srd_session_, SRD_CONF_SAMPLERATE,
                                g_variant_new_uint64(samplerate));
-               for (const shared_ptr<decode::Decoder> &dec : stack_)
+               for (const shared_ptr<decode::Decoder>dec : stack_)
                        dec->apply_all_options();
                srd_session_start(srd_session_);
 
@@ -1123,7 +1123,7 @@ void DecodeSignal::start_srd_session()
 
        // Create the decoders
        srd_decoder_inst *prev_di = nullptr;
-       for (const shared_ptr<decode::Decoder> &dec : stack_) {
+       for (const shared_ptr<decode::Decoder>dec : stack_) {
                srd_decoder_inst *const di = dec->create_decoder_inst(srd_session_);
 
                if (!di) {
@@ -1170,7 +1170,7 @@ void DecodeSignal::terminate_srd_session()
                if (samplerate)
                        srd_session_metadata_set(srd_session_, SRD_CONF_SAMPLERATE,
                                g_variant_new_uint64(samplerate));
-               for (const shared_ptr<decode::Decoder> &dec : stack_)
+               for (const shared_ptr<decode::Decoder>dec : stack_)
                        dec->apply_all_options();
        }
 }
@@ -1183,7 +1183,7 @@ void DecodeSignal::stop_srd_session()
                srd_session_ = nullptr;
 
                // Mark the decoder instances as non-existant since they were deleted
-               for (const shared_ptr<decode::Decoder> &dec : stack_)
+               for (const shared_ptr<decode::Decoder>dec : stack_)
                        dec->invalidate_decoder_inst();
        }
 }
@@ -1195,7 +1195,7 @@ void DecodeSignal::connect_input_notifiers()
        disconnect(this, SLOT(on_data_received()));
 
        // Connect the currently used signals to our slot
-       for (data::DecodeChannel &ch : channels_) {
+       for (data::DecodeChannelch : channels_) {
                if (!ch.assigned_signal)
                        continue;
 
@@ -1213,7 +1213,7 @@ void DecodeSignal::create_decode_segment()
        segments_.emplace_back(DecodeSegment());
 
        // Add annotation classes
-       for (const shared_ptr<decode::Decoder> &dec : stack_) {
+       for (const shared_ptr<decode::Decoder>dec : stack_) {
                assert(dec);
                const srd_decoder *const decc = dec->decoder();
                assert(dec->decoder());
index b094a0c828334059029936cd48d40cbd22844dc8..516060a0aec9013c139f8597dc0bf9bfd70de6aa 100644 (file)
@@ -80,7 +80,7 @@ double Logic::get_samplerate() const
 uint64_t Logic::max_sample_count() const
 {
        uint64_t l = 0;
-       for (shared_ptr<LogicSegment> s : segments_) {
+       for (const shared_ptr<LogicSegment>& s : segments_) {
                assert(s);
                l = max(l, s->get_sample_count());
        }
index 01206e7e24b1eae570a3626b25468f1c8546389d..9f35725f8df1cc540e032680cb70d31b4fe6b5ad 100644 (file)
@@ -455,7 +455,7 @@ void SignalBase::save_settings(QSettings &settings) const
 
        settings.setValue("conv_options", (int)(conversion_options_.size()));
        int i = 0;
-       for (auto kvp : conversion_options_) {
+       for (auto& kvp : conversion_options_) {
                settings.setValue(QString("conv_option%1_key").arg(i), kvp.first);
                settings.setValue(QString("conv_option%1_value").arg(i), kvp.second);
                i++;
index ca8f66bee5316e6116d4fb38afcbdd93ca78a24d..ebf140fd725c793f340e089cbb49d412a0348297 100644 (file)
@@ -84,7 +84,7 @@ DeviceManager::DeviceManager(shared_ptr<Context> context,
         * Scan for devices. No specific options apply here, this is
         * best effort auto detection.
         */
-       for (auto entry : context->drivers()) {
+       for (auto& entry : context->drivers()) {
                if (!do_scan)
                        break;
 
@@ -187,7 +187,7 @@ DeviceManager::drive_scan_options(vector<string> user_spec,
 {
        map<const ConfigKey *, Glib::VariantBase> result;
 
-       for (auto entry : user_spec) {
+       for (auto& entry : user_spec) {
                /*
                 * Split key=value specs. Accept entries without separator
                 * (for simplified boolean specifications).
@@ -256,7 +256,7 @@ DeviceManager::driver_scan(
        auto devices = driver->scan(drvopts);
 
        // Add the scanned devices to the main list, set display names and sort.
-       for (shared_ptr<sigrok::HardwareDevice> device : devices) {
+       for (shared_ptr<sigrok::HardwareDevice>& device : devices) {
                const shared_ptr<devices::HardwareDevice> d(
                        new devices::HardwareDevice(context_, device));
                driver_devices.push_back(d);
index 65331563937058e92d0716844f49088fc1760ee6..94fb9c82cb6d4df2e2a47d261ff8220bb471ad3e 100644 (file)
@@ -101,7 +101,7 @@ void InputFile::save_meta_to_settings(QSettings &settings)
        settings.setValue("options", (int)options_.size());
 
        int i = 0;
-       for (pair<string, Glib::VariantBase> option : options_) {
+       for (const pair<string, Glib::VariantBase>& option : options_) {
                settings.beginGroup("option" + QString::number(i));
                settings.setValue("name", QString::fromStdString(option.first));
                GlobalSettings::store_variantbase(settings, option.second);
index 81f1aee411061ed48f6bea86bd3ec68c05615115..ee05a0e1a06e09f12f6f524da5afc2d9c864af7f 100644 (file)
@@ -154,7 +154,7 @@ shared_ptr<HardwareDevice> Connect::get_selected_device() const
 
 void Connect::populate_drivers()
 {
-       for (auto entry : device_manager_.context()->drivers()) {
+       for (auto& entry : device_manager_.context()->drivers()) {
                auto name = entry.first;
                auto driver = entry.second;
                /**
@@ -179,7 +179,7 @@ void Connect::populate_drivers()
 void Connect::populate_serials(shared_ptr<Driver> driver)
 {
        serial_devices_.clear();
-       for (auto serial : device_manager_.context()->serials(driver))
+       for (auto& serial : device_manager_.context()->serials(driver))
                serial_devices_.addItem(QString("%1 (%2)").arg(
                        serial.first.c_str(), serial.second.c_str()),
                        QString::fromStdString(serial.first));
@@ -245,7 +245,7 @@ void Connect::scan_pressed()
        const list< shared_ptr<HardwareDevice> > devices =
                device_manager_.driver_scan(driver, drvopts);
 
-       for (shared_ptr<HardwareDevice> device : devices) {
+       for (const shared_ptr<HardwareDevice>& device : devices) {
                assert(device);
 
                QString text = QString::fromStdString(device->display_name(device_manager_));
index d17f5d04c35cd61d02be0fec28da8af89750701f..491bbfc2b6c13e88c67d0dad6efc73f636b4bcfd 100644 (file)
@@ -215,7 +215,7 @@ QWidget *Settings::get_general_settings_form(QWidget *parent) const
        general_group->setLayout(general_layout);
 
        QComboBox *theme_cb = new QComboBox();
-       for (pair<QString, QString> entry : Themes)
+       for (const pair<QString, QString>& entry : Themes)
                theme_cb->addItem(entry.first, entry.second);
 
        theme_cb->setCurrentIndex(
index 55ceb5a9e4e382b80cef0ad61cde72f0e0142888..3f3711b8ec63a8397892f26eafc1db845e8dfab1 100644 (file)
@@ -224,7 +224,7 @@ void GlobalSettings::undo_tracked_changes()
 {
        tracking_ = false;
 
-       for (auto entry : tracked_changes_)
+       for (auto& entry : tracked_changes_)
                setValue(entry.first, entry.second);
 
        tracked_changes_.clear();
index 25377024278ca8f7475a572c3d9867d7a64efdb8..6b3319bed152f993e76eb0bf7dc51e63dbccbc17 100644 (file)
@@ -123,7 +123,7 @@ shared_ptr<views::ViewBase> MainWindow::get_active_view() const
        }
 
        // Get the view contained in the dock widget
-       for (auto entry : view_docks_)
+       for (auto& entry : view_docks_)
                if (entry.first == dock)
                        return entry.second;
 
@@ -137,7 +137,7 @@ shared_ptr<views::ViewBase> MainWindow::add_view(const QString &title,
        shared_ptr<views::ViewBase> v;
 
        QMainWindow *main_window = nullptr;
-       for (auto entry : session_windows_)
+       for (auto& entry : session_windows_)
                if (entry.first.get() == &session)
                        main_window = entry.second;
 
@@ -226,7 +226,7 @@ void MainWindow::remove_view(shared_ptr<views::ViewBase> view)
                        continue;
 
                // Find the dock the view is contained in and remove it
-               for (auto entry : view_docks_)
+               for (auto& entry : view_docks_)
                        if (entry.second == view) {
                                // Remove the view from the session
                                session->deregister_view(view);
@@ -294,7 +294,7 @@ void MainWindow::remove_session(shared_ptr<Session> session)
        session->stop_capture();
        QApplication::processEvents();
 
-       for (shared_ptr<views::ViewBase> view : session->views())
+       for (const shared_ptr<views::ViewBase>& view : session->views())
                remove_view(view);
 
        QMainWindow *window = session_windows_.at(session);
@@ -346,7 +346,7 @@ void MainWindow::add_default_session()
        // one of the auto detected devices that are not the demo device.
        // Pick demo in the absence of "genuine" hardware devices.
        shared_ptr<devices::HardwareDevice> user_device, other_device, demo_device;
-       for (shared_ptr<devices::HardwareDevice> dev : device_manager_.devices()) {
+       for (const shared_ptr<devices::HardwareDevice>& dev : device_manager_.devices()) {
                if (dev == device_manager_.user_spec_device()) {
                        user_device = dev;
                } else if (dev->hardware_device()->driver()->name() == "demo") {
@@ -368,7 +368,7 @@ void MainWindow::save_sessions()
        QSettings settings;
        int id = 0;
 
-       for (shared_ptr<Session> session : sessions_) {
+       for (shared_ptr<Session>& session : sessions_) {
                // Ignore sessions using the demo device or no device at all
                if (session->device()) {
                        shared_ptr<devices::HardwareDevice> device =
@@ -532,7 +532,7 @@ void MainWindow::restore_ui_settings()
 shared_ptr<Session> MainWindow::get_tab_session(int index) const
 {
        // Find the session that belongs to the tab's main window
-       for (auto entry : session_windows_)
+       for (auto& entry : session_windows_)
                if (entry.second == session_selector_.widget(index))
                        return entry.first;
 
@@ -543,7 +543,7 @@ void MainWindow::closeEvent(QCloseEvent *event)
 {
        bool data_saved = true;
 
-       for (auto entry : session_windows_)
+       for (auto& entry : session_windows_)
                if (!entry.first->data_saved())
                        data_saved = false;
 
@@ -578,7 +578,7 @@ void MainWindow::on_add_view(const QString &title, views::ViewType type,
        Session *session)
 {
        // We get a pointer and need a reference
-       for (shared_ptr<Session> s : sessions_)
+       for (shared_ptr<Session>& s : sessions_)
                if (s.get() == session)
                        add_view(title, type, *s);
 }
@@ -656,9 +656,9 @@ void MainWindow::on_session_name_changed()
        Session *session = qobject_cast<Session*>(QObject::sender());
        assert(session);
 
-       for (shared_ptr<views::ViewBase> view : session->views()) {
+       for (const shared_ptr<views::ViewBase>& view : session->views()) {
                // Get the dock that contains the view
-               for (auto entry : view_docks_)
+               for (auto& entry : view_docks_)
                        if (entry.second == view) {
                                entry.first->setObjectName(session->name());
                                entry.first->setWindowTitle(session->name());
@@ -666,7 +666,7 @@ void MainWindow::on_session_name_changed()
        }
 
        // Update the tab widget by finding the main window and the tab from that
-       for (auto entry : session_windows_)
+       for (auto& entry : session_windows_)
                if (entry.first.get() == session) {
                        QMainWindow *window = entry.second;
                        const int index = session_selector_.indexOf(window);
@@ -698,7 +698,7 @@ void MainWindow::on_capture_state_changed(QObject *obj)
 void MainWindow::on_new_view(Session *session)
 {
        // We get a pointer and need a reference
-       for (shared_ptr<Session> s : sessions_)
+       for (shared_ptr<Session>& s : sessions_)
                if (s.get() == session)
                        add_view(session->name(), views::ViewTypeTrace, *s);
 }
@@ -719,7 +719,7 @@ void MainWindow::on_view_close_clicked()
        // Get the view contained in the dock widget
        shared_ptr<views::ViewBase> view;
 
-       for (auto entry : view_docks_)
+       for (auto& entry : view_docks_)
                if (entry.first == dock)
                        view = entry.second;
 
@@ -799,7 +799,7 @@ void MainWindow::on_settingViewColoredBg_changed(const QVariant new_value)
 {
        bool state = new_value.toBool();
 
-       for (auto entry : view_docks_) {
+       for (auto& entry : view_docks_) {
                shared_ptr<views::ViewBase> viewbase = entry.second;
 
                // Only trace views have this setting
@@ -814,7 +814,7 @@ void MainWindow::on_settingViewShowSamplingPoints_changed(const QVariant new_val
 {
        bool state = new_value.toBool();
 
-       for (auto entry : view_docks_) {
+       for (auto& entry : view_docks_) {
                shared_ptr<views::ViewBase> viewbase = entry.second;
 
                // Only trace views have this setting
@@ -829,7 +829,7 @@ void MainWindow::on_settingViewShowAnalogMinorGrid_changed(const QVariant new_va
 {
        bool state = new_value.toBool();
 
-       for (auto entry : view_docks_) {
+       for (auto& entry : view_docks_) {
                shared_ptr<views::ViewBase> viewbase = entry.second;
 
                // Only trace views have this setting
index 8aca2921566ffef531cf29739dc8f3914813d2e4..acd7079b7616d0a37a31d682eb7459c3bf0e5738 100644 (file)
@@ -80,18 +80,18 @@ Channels::Channels(Session &session, QWidget *parent) :
        map<shared_ptr<Channel>, shared_ptr<SignalBase> > signal_map;
 
        unordered_set< shared_ptr<SignalBase> > sigs;
-       for (const shared_ptr<data::SignalBase> b : session_.signalbases())
+       for (const shared_ptr<data::SignalBase>& b : session_.signalbases())
                sigs.insert(b);
 
        for (const shared_ptr<SignalBase> &sig : sigs)
                signal_map[sig->channel()] = sig;
 
        // Populate channel groups
-       for (auto entry : device->channel_groups()) {
+       for (auto& entry : device->channel_groups()) {
                const shared_ptr<ChannelGroup> group = entry.second;
                // Make a set of signals and remove these signals from the signal map
                vector< shared_ptr<SignalBase> > group_sigs;
-               for (auto channel : group->channels()) {
+               for (auto& channel : group->channels()) {
                        const auto iter = signal_map.find(channel);
 
                        if (iter == signal_map.end())
@@ -106,7 +106,7 @@ Channels::Channels(Session &session, QWidget *parent) :
 
        // Make a vector of the remaining channels
        vector< shared_ptr<SignalBase> > global_analog_sigs, global_logic_sigs;
-       for (auto channel : device->channels()) {
+       for (auto& channel : device->channels()) {
                const map<shared_ptr<Channel>, shared_ptr<SignalBase> >::
                        const_iterator iter = signal_map.find(channel);
 
@@ -165,7 +165,7 @@ void Channels::set_all_channels(bool set)
 {
        updating_channels_ = true;
 
-       for (auto entry : check_box_signal_map_) {
+       for (auto& entry : check_box_signal_map_) {
                QCheckBox *cb = entry.first;
                const shared_ptr<SignalBase> sig = entry.second;
                assert(sig);
@@ -182,7 +182,7 @@ void Channels::enable_channels_conditionally(
 {
        updating_channels_ = true;
 
-       for (auto entry : check_box_signal_map_) {
+       for (auto& entry : check_box_signal_map_) {
                QCheckBox *cb = entry.first;
                const shared_ptr<SignalBase> sig = entry.second;
                assert(sig);
@@ -201,7 +201,7 @@ void Channels::disable_channels_conditionally(
 {
        updating_channels_ = true;
 
-       for (auto entry : check_box_signal_map_) {
+       for (auto& entry : check_box_signal_map_) {
                QCheckBox *cb = entry.first;
                const shared_ptr<SignalBase> sig = entry.second;
                assert(sig);
@@ -280,7 +280,7 @@ void Channels::showEvent(QShowEvent *event)
        assert(device);
 
        // Update group labels
-       for (auto entry : device->channel_groups()) {
+       for (auto& entry : device->channel_groups()) {
                const shared_ptr<ChannelGroup> group = entry.second;
 
                try {
@@ -293,7 +293,7 @@ void Channels::showEvent(QShowEvent *event)
 
        updating_channels_ = true;
 
-       for (auto entry : check_box_signal_map_) {
+       for (auto& entry : check_box_signal_map_) {
                QCheckBox *cb = entry.first;
                const shared_ptr<SignalBase> sig = entry.second;
                assert(sig);
index 5356433f9027e8fa5298db01dff5256d8a28a674..c0bcd670de26d0af866bf9cb87705ad506d5a57e 100644 (file)
@@ -195,7 +195,7 @@ void Session::save_settings(QSettings &settings) const
 
                        dev_info = device_manager_.get_device_info(device_);
 
-                       for (string key : key_list) {
+                       for (string& key : key_list) {
                                if (dev_info.count(key))
                                        settings.setValue(QString::fromUtf8(key.c_str()),
                                                        QString::fromUtf8(dev_info.at(key).c_str()));
@@ -228,7 +228,7 @@ void Session::save_settings(QSettings &settings) const
                }
 
                // Save channels and decoders
-               for (shared_ptr<data::SignalBase> base : signalbases_) {
+               for (const shared_ptr<data::SignalBase>& base : signalbases_) {
 #ifdef ENABLE_DECODE
                        if (base->is_decode_signal()) {
                                settings.beginGroup("decode_signal" + QString::number(decode_signals++));
@@ -251,7 +251,7 @@ void Session::save_settings(QSettings &settings) const
                main_view_->save_settings(settings);
                settings.endGroup();
 
-               for (shared_ptr<views::ViewBase> view : views_) {
+               for (const shared_ptr<views::ViewBase>& view : views_) {
                        if (view != main_view_) {
                                settings.beginGroup("view" + QString::number(views++));
                                view->save_settings(settings);
@@ -405,13 +405,13 @@ void Session::set_device(shared_ptr<devices::Device> device)
 #endif
                view->reset_view_state();
        }
-       for (const shared_ptr<data::SignalData> d : all_signal_data_)
+       for (const shared_ptr<data::SignalData>& d : all_signal_data_)
                d->clear();
        all_signal_data_.clear();
        signalbases_.clear();
        cur_logic_segment_.reset();
 
-       for (auto entry : cur_analog_segments_) {
+       for (auto& entry : cur_analog_segments_) {
                shared_ptr<sigrok::Channel>(entry.first).reset();
                shared_ptr<data::AnalogSegment>(entry.second).reset();
        }
@@ -470,7 +470,7 @@ Session::input_format_options(vector<string> user_spec,
 {
        map<string, Glib::VariantBase> result;
 
-       for (auto entry : user_spec) {
+       for (auto& entry : user_spec) {
                /*
                 * Split key=value specs. Accept entries without separator
                 * (for simplified boolean specifications).
@@ -594,7 +594,7 @@ void Session::start_capture(function<void (const QString)> error_handler)
        }
 
        // Clear signal data
-       for (const shared_ptr<data::SignalData> d : all_signal_data_)
+       for (const shared_ptr<data::SignalData>& d : all_signal_data_)
                d->clear();
 
        trigger_list_.clear();
@@ -643,7 +643,7 @@ void Session::register_view(shared_ptr<views::ViewBase> view)
                qobject_cast<views::trace::View*>(view.get());
 
        if (trace_view) {
-               for (shared_ptr<data::SignalBase> signalbase : signalbases_) {
+               for (const shared_ptr<data::SignalBase>& signalbase : signalbases_) {
                        const int sb_exists = count_if(
                                view_signalbases.cbegin(), view_signalbases.cend(),
                                [&](const shared_ptr<data::SignalBase> &sb) {
@@ -684,7 +684,7 @@ void Session::deregister_view(shared_ptr<views::ViewBase> view)
 
 bool Session::has_view(shared_ptr<views::ViewBase> view)
 {
-       for (shared_ptr<views::ViewBase> v : views_)
+       for (shared_ptr<views::ViewBase>& v : views_)
                if (v == view)
                        return true;
 
@@ -695,11 +695,11 @@ double Session::get_samplerate() const
 {
        double samplerate = 0.0;
 
-       for (const shared_ptr<pv::data::SignalData> d : all_signal_data_) {
+       for (const shared_ptr<pv::data::SignalData>& d : all_signal_data_) {
                assert(d);
                const vector< shared_ptr<pv::data::Segment> > segments =
                        d->segments();
-               for (const shared_ptr<pv::data::Segment> &s : segments)
+               for (const shared_ptr<pv::data::Segment>s : segments)
                        samplerate = max(samplerate, s->samplerate());
        }
        // If there is no sample rate given we use samples as unit
@@ -714,7 +714,7 @@ uint32_t Session::get_segment_count() const
        uint32_t value = 0;
 
        // Find the highest number of segments
-       for (shared_ptr<data::SignalData> data : all_signal_data_)
+       for (const shared_ptr<data::SignalData>& data : all_signal_data_)
                if (data->get_segment_count() > value)
                        value = data->get_segment_count();
 
@@ -725,7 +725,7 @@ vector<util::Timestamp> Session::get_triggers(uint32_t segment_id) const
 {
        vector<util::Timestamp> result;
 
-       for (pair<uint32_t, util::Timestamp> entry : trigger_list_)
+       for (const pair<uint32_t, util::Timestamp>& entry : trigger_list_)
                if (entry.first == segment_id)
                        result.push_back(entry.second);
 
@@ -741,7 +741,7 @@ bool Session::all_segments_complete(uint32_t segment_id) const
 {
        bool all_complete = true;
 
-       for (shared_ptr<data::SignalBase> base : signalbases_)
+       for (const shared_ptr<data::SignalBase>& base : signalbases_)
                if (!base->segment_is_complete(segment_id))
                        all_complete = false;
 
@@ -760,7 +760,7 @@ shared_ptr<data::DecodeSignal> Session::add_decode_signal()
                signalbases_.insert(signal);
 
                // Add the decode signal to all views
-               for (shared_ptr<views::ViewBase> view : views_)
+               for (shared_ptr<views::ViewBase>& view : views_)
                        view->add_decode_signal(signal);
        } catch (runtime_error& e) {
                remove_decode_signal(signal);
@@ -776,7 +776,7 @@ void Session::remove_decode_signal(shared_ptr<data::DecodeSignal> signal)
 {
        signalbases_.erase(signal);
 
-       for (shared_ptr<views::ViewBase> view : views_)
+       for (shared_ptr<views::ViewBase>& view : views_)
                view->remove_decode_signal(signal);
 
        signals_changed();
@@ -802,7 +802,7 @@ void Session::update_signals()
        if (!device_) {
                signalbases_.clear();
                logic_data_.reset();
-               for (shared_ptr<views::ViewBase> view : views_) {
+               for (shared_ptr<views::ViewBase>& view : views_) {
                        view->clear_signals();
 #ifdef ENABLE_DECODE
                        view->clear_decode_signals();
@@ -817,7 +817,7 @@ void Session::update_signals()
        if (!sr_dev) {
                signalbases_.clear();
                logic_data_.reset();
-               for (shared_ptr<views::ViewBase> view : views_) {
+               for (shared_ptr<views::ViewBase>& view : views_) {
                        view->clear_signals();
 #ifdef ENABLE_DECODE
                        view->clear_decode_signals();
@@ -848,7 +848,7 @@ void Session::update_signals()
        }
 
        // Make the signals list
-       for (shared_ptr<views::ViewBase> viewbase : views_) {
+       for (shared_ptr<views::ViewBase>& viewbase : views_) {
                views::trace::View *trace_view =
                        qobject_cast<views::trace::View*>(viewbase.get());
 
@@ -874,7 +874,7 @@ void Session::update_signals()
                                } else {
                                        // Find the signalbase for this channel if possible
                                        signalbase.reset();
-                                       for (const shared_ptr<data::SignalBase> b : signalbases_)
+                                       for (const shared_ptr<data::SignalBase>& b : signalbases_)
                                                if (b->channel() == channel)
                                                        signalbase = b;
 
@@ -1006,12 +1006,11 @@ void Session::sample_thread_proc(function<void (const QString)> error_handler)
 
 void Session::free_unused_memory()
 {
-       for (shared_ptr<data::SignalData> data : all_signal_data_) {
+       for (const shared_ptr<data::SignalData>& data : all_signal_data_) {
                const vector< shared_ptr<data::Segment> > segments = data->segments();
 
-               for (shared_ptr<data::Segment> segment : segments) {
+               for (const shared_ptr<data::Segment>& segment : segments)
                        segment->free_unused_memory();
-               }
        }
 }
 
@@ -1049,7 +1048,7 @@ void Session::signal_segment_completed()
 {
        int segment_id = 0;
 
-       for (shared_ptr<data::SignalBase> signalbase : signalbases_) {
+       for (const shared_ptr<data::SignalBase>& signalbase : signalbases_) {
                // We only care about analog and logic channels, not derived ones
                if (signalbase->type() == data::SignalBase::AnalogChannel) {
                        segment_id = signalbase->analog_data()->get_segment_count() - 1;
@@ -1073,7 +1072,7 @@ void Session::feed_in_header()
 
 void Session::feed_in_meta(shared_ptr<Meta> meta)
 {
-       for (auto entry : meta->config()) {
+       for (auto& entry : meta->config()) {
                switch (entry.first->id()) {
                case SR_CONF_SAMPLERATE:
                        cur_samplerate_ = g_variant_get_uint64(entry.second.gobj());
@@ -1093,7 +1092,7 @@ void Session::feed_in_trigger()
        uint64_t sample_count = 0;
 
        {
-               for (const shared_ptr<pv::data::SignalData> d : all_signal_data_) {
+               for (const shared_ptr<pv::data::SignalData>& d : all_signal_data_) {
                        assert(d);
                        uint64_t temp_count = 0;
 
@@ -1143,7 +1142,7 @@ void Session::feed_in_frame_end()
                if (cur_logic_segment_)
                        cur_logic_segment_->set_complete();
 
-               for (auto entry : cur_analog_segments_) {
+               for (auto& entry : cur_analog_segments_) {
                        shared_ptr<data::AnalogSegment> segment = entry.second;
                        segment->set_complete();
                }
@@ -1224,7 +1223,7 @@ void Session::feed_in_analog(shared_ptr<Analog> analog)
                update_signals();
 
        float *channel_data = data.get();
-       for (auto channel : channels) {
+       for (auto& channel : channels) {
                shared_ptr<data::AnalogSegment> segment;
 
                // Try to get the segment of the channel
@@ -1329,7 +1328,7 @@ void Session::data_feed_in(shared_ptr<sigrok::Device> device,
                        if (cur_logic_segment_)
                                cur_logic_segment_->set_complete();
 
-                       for (auto entry : cur_analog_segments_) {
+                       for (auto& entry : cur_analog_segments_) {
                                shared_ptr<data::AnalogSegment> segment = entry.second;
                                segment->set_complete();
                        }
index 3d7b058a87034b6c02cc4109347e798b94702b40..ee1a3a03f096cf5c55d3a0ce16ea3f3c85496669 100644 (file)
@@ -97,7 +97,7 @@ bool StoreSession::start()
        vector< shared_ptr<data::SignalBase> > achannel_list;
        vector< shared_ptr<data::AnalogSegment> > asegment_list;
 
-       for (shared_ptr<data::SignalBase> signal : sigs) {
+       for (const shared_ptr<data::SignalBase>& signal : sigs) {
                if (!signal->enabled())
                        continue;
 
index 2643c643fe9ca919028b5c82a44dbfa70a576d22..3fda4cb6251de1d95326288b19eeb1ae949e1480 100644 (file)
@@ -788,7 +788,7 @@ void AnalogSignal::update_conversion_widgets()
        conv_threshold_cb_->blockSignals(true);
 
        // Set available options depending on chosen conversion
-       for (pair<QString, int> preset : presets)
+       for (pair<QString, int>& preset : presets)
                conv_threshold_cb_->addItem(preset.first, preset.second);
 
        map < QString, QVariant > options = base_->get_conversion_options();
@@ -857,7 +857,7 @@ void AnalogSignal::perform_autoranging(bool keep_divs, bool force_update)
        static double prev_min = 0, prev_max = 0;
        double min = 0, max = 0;
 
-       for (shared_ptr<pv::data::AnalogSegment> segment : segments) {
+       for (const shared_ptr<pv::data::AnalogSegment>& segment : segments) {
                pair<double, double> mm = segment->get_min_max();
                min = std::min(min, mm.first);
                max = std::max(max, mm.second);
index fd2d85e227c4b70e82ecfcf415b7da9a5f0f4816..d7da7e03706bdab45389f127c8bc874871a3c74a 100644 (file)
@@ -108,7 +108,7 @@ void Header::paintEvent(QPaintEvent*)
        QPainter painter(this);
        painter.setRenderHint(QPainter::Antialiasing);
 
-       for (const shared_ptr<RowItem> r : items) {
+       for (const shared_ptr<RowItem>& r : items) {
                assert(r);
 
                const bool highlight = !item_dragging_ &&
@@ -201,7 +201,7 @@ void Header::on_ungroup()
                restart = false;
                const vector< shared_ptr<TraceGroup> > groups(
                        view_.list_by_type<TraceGroup>());
-               for (const shared_ptr<TraceGroup> tg : groups)
+               for (const shared_ptr<TraceGroup>& tg : groups)
                        if (tg->selected()) {
                                tg->ungroup();
                                restart = true;
index a639ce9cea426f0224e91e15f585c2df520d9cb0..3cbca90934d68a8417e17d5feb6bc70fd79bb3a6 100644 (file)
@@ -116,7 +116,7 @@ void TraceGroup::paint_label(QPainter &p, const QRect &rect, bool hover)
 QRectF TraceGroup::label_rect(const QRectF &rect) const
 {
        QRectF child_rect;
-       for (const shared_ptr<ViewItem> r : child_items())
+       for (const shared_ptr<ViewItem>& r : child_items())
                if (r && r->enabled())
                        child_rect = child_rect.united(r->label_rect(rect));
 
@@ -166,7 +166,7 @@ void TraceGroup::ungroup()
        const vector<shared_ptr<TraceTreeItem>> items(trace_tree_child_items());
        clear_child_items();
 
-       for (shared_ptr<TraceTreeItem> r : items)
+       for (const shared_ptr<TraceTreeItem>& r : items)
                owner_->add_child_item(r);
 
        owner_->remove_child_item(shared_from_this());
index d2512332830a7e9784798e83364c2ff16264a862..ccf9b9123637ea498abfe800145eca070f03d211 100644 (file)
@@ -89,7 +89,7 @@ pair<int, int> TraceTreeItemOwner::v_extents() const
        bool has_children = false;
 
        pair<int, int> extents(INT_MAX, INT_MIN);
-       for (const shared_ptr<TraceTreeItem> t : trace_tree_child_items()) {
+       for (const shared_ptr<TraceTreeItem>& t : trace_tree_child_items()) {
                assert(t);
                if (!t->enabled())
                        continue;
index 54c6fae6561cc70fac0dd661a61c1e1be879e15e..f1d7aa3dfca872a29bc81f5c0c2c444e4a34e03e 100644 (file)
@@ -375,7 +375,7 @@ void View::save_settings(QSettings &settings) const
                settings.setValue("offset", QString::fromStdString(ss.str()));
        }
 
-       for (shared_ptr<Signal> signal : signals_) {
+       for (const shared_ptr<Signal>& signal : signals_) {
                settings.beginGroup(signal->base()->internal_name());
                signal->save_settings(settings);
                settings.endGroup();
@@ -457,7 +457,7 @@ vector< shared_ptr<TimeItem> > View::time_items() const
                items.push_back(cursors_->second());
        }
 
-       for (auto trigger_marker : trigger_markers_)
+       for (auto& trigger_marker : trigger_markers_)
                items.push_back(trigger_marker);
 
        return items;
@@ -596,10 +596,10 @@ void View::set_current_segment(uint32_t segment_id)
 {
        current_segment_ = segment_id;
 
-       for (shared_ptr<Signal> signal : signals_)
+       for (const shared_ptr<Signal>& signal : signals_)
                signal->set_current_segment(current_segment_);
 #ifdef ENABLE_DECODE
-       for (shared_ptr<DecodeTrace> dt : decode_traces_)
+       for (shared_ptr<DecodeTrace>& dt : decode_traces_)
                dt->set_current_segment(current_segment_);
 #endif
 
@@ -635,7 +635,7 @@ void View::set_segment_display_mode(Trace::SegmentDisplayMode mode)
 {
        segment_display_mode_ = mode;
 
-       for (shared_ptr<Signal> signal : signals_)
+       for (const shared_ptr<Signal>& signal : signals_)
                signal->set_segment_display_mode(mode);
 
        uint32_t last_segment = session_.get_segment_count() - 1;
@@ -744,7 +744,7 @@ set< shared_ptr<SignalData> > View::get_visible_data() const
 {
        // Make a set of all the visible data objects
        set< shared_ptr<SignalData> > visible_data;
-       for (const shared_ptr<Signal> sig : signals_)
+       for (const shared_ptr<Signal>& sig : signals_)
                if (sig->enabled())
                        visible_data.insert(sig->data());
 
@@ -755,9 +755,9 @@ pair<Timestamp, Timestamp> View::get_time_extents() const
 {
        boost::optional<Timestamp> left_time, right_time;
        const set< shared_ptr<SignalData> > visible_data = get_visible_data();
-       for (const shared_ptr<SignalData> d : visible_data) {
+       for (const shared_ptr<SignalData>& d : visible_data) {
                const vector< shared_ptr<Segment> > segments = d->segments();
-               for (const shared_ptr<Segment> &s : segments) {
+               for (const shared_ptr<Segment>s : segments) {
                        double samplerate = s->samplerate();
                        samplerate = (samplerate <= 0.0) ? 1.0 : samplerate;
 
@@ -1260,8 +1260,8 @@ TraceTreeItemOwner* View::find_prevalent_trace_group(
        vector<TraceTreeItemOwner*> owner_list;
 
        // Make a set and a list of all the owners
-       for (const auto &channel : group->channels()) {
-               for (auto entry : signal_map) {
+       for (const autochannel : group->channels()) {
+               for (auto& entry : signal_map) {
                        if (entry.first->channel() == channel) {
                                TraceTreeItemOwner *const o = (entry.second)->owner();
                                owner_list.push_back(o);
@@ -1294,8 +1294,8 @@ vector< shared_ptr<Trace> > View::extract_new_traces_for_channels(
 {
        vector< shared_ptr<Trace> > filtered_traces;
 
-       for (const auto &channel : channels) {
-               for (auto entry : signal_map) {
+       for (const autochannel : channels) {
+               for (auto& entry : signal_map) {
                        if (entry.first->channel() == channel) {
                                shared_ptr<Trace> trace = entry.second;
                                const auto list_iter = add_list.find(trace);
@@ -1316,7 +1316,7 @@ void View::determine_time_unit()
        // Check whether we know the sample rate and hence can use time as the unit
        if (time_unit_ == util::TimeUnit::Samples) {
                // Check all signals but...
-               for (const shared_ptr<Signal> signal : signals_) {
+               for (const shared_ptr<Signal>& signal : signals_) {
                        const shared_ptr<SignalData> data = signal->data();
 
                        // ...only check first segment of each
@@ -1410,7 +1410,7 @@ void View::update_hover_point()
        // Determine signal that the mouse cursor is hovering over
        signal_under_mouse_cursor_.reset();
        if (hover_widget_ == this) {
-               for (shared_ptr<Signal> s : signals_) {
+               for (const shared_ptr<Signal>& s : signals_) {
                        const pair<int, int> extents = s->v_extents();
                        const int top = s->get_visual_y() + extents.first;
                        const int btm = s->get_visual_y() + extents.second;
@@ -1423,7 +1423,7 @@ void View::update_hover_point()
        // Update all trace tree items
        const vector<shared_ptr<TraceTreeItem>> trace_tree_items(
                list_by_type<TraceTreeItem>());
-       for (shared_ptr<TraceTreeItem> r : trace_tree_items)
+       for (const shared_ptr<TraceTreeItem>& r : trace_tree_items)
                r->hover_point_changed(hover_point_);
 
        // Notify any other listeners
@@ -1558,12 +1558,12 @@ void View::signals_changed()
        // Make a look-up table of sigrok Channels to pulseview Signals
        unordered_map<shared_ptr<data::SignalBase>, shared_ptr<Signal> >
                signal_map;
-       for (const shared_ptr<Signal> &sig : signals_)
+       for (const shared_ptr<Signal>sig : signals_)
                signal_map[sig->base()] = sig;
 
        // Populate channel groups
        if (sr_dev)
-               for (auto entry : sr_dev->channel_groups()) {
+               for (auto& entry : sr_dev->channel_groups()) {
                        const shared_ptr<sigrok::ChannelGroup> &group = entry.second;
 
                        if (group->channels().size() <= 1)
@@ -1589,7 +1589,7 @@ void View::signals_changed()
                        // Add the traces to the group
                        const pair<int, int> prev_v_extents = owner->v_extents();
                        int offset = prev_v_extents.second - prev_v_extents.first;
-                       for (shared_ptr<Trace> trace : new_traces_in_group) {
+                       for (const shared_ptr<Trace>& trace : new_traces_in_group) {
                                assert(trace);
                                owner->add_child_item(trace);
 
@@ -1624,7 +1624,7 @@ void View::signals_changed()
        if (non_grouped_logic_signals.size() > 0) {
                const shared_ptr<TraceGroup> non_grouped_trace_group(
                        make_shared<TraceGroup>());
-               for (shared_ptr<Trace> trace : non_grouped_logic_signals)
+               for (const shared_ptr<Trace>& trace : non_grouped_logic_signals)
                        non_grouped_trace_group->add_child_item(trace);
 
                non_grouped_trace_group->restack_items();
@@ -1642,7 +1642,7 @@ void View::signals_changed()
                add_traces.begin(), add_traces.end());
 
        // Remove any removed traces
-       for (shared_ptr<Trace> trace : remove_traces) {
+       for (const shared_ptr<Trace>& trace : remove_traces) {
                TraceTreeItemOwner *const owner = trace->owner();
                assert(owner);
                owner->remove_child_item(trace);
index e5fb607639eac3b6ae7a2985c1c7735988c16f40..83abb7b6cbd5273f699a204d2720e4404f6c00e2 100644 (file)
@@ -177,11 +177,11 @@ void Viewport::paintEvent(QPaintEvent*)
        for (LayerPaintFunc *paint_func = layer_paint_funcs;
                        *paint_func; paint_func++) {
                ViewItemPaintParams time_pp(rect(), view_.scale(), view_.offset());
-               for (const shared_ptr<TimeItem> t : time_items)
+               for (const shared_ptr<TimeItem>& t : time_items)
                        (t.get()->*(*paint_func))(p, time_pp);
 
                ViewItemPaintParams row_pp(rect(), view_.scale(), view_.offset());
-               for (const shared_ptr<RowItem> r : row_items)
+               for (const shared_ptr<RowItem>& r : row_items)
                        (r.get()->*(*paint_func))(p, row_pp);
        }
 
index c3461614ab637db740659666482d6b12ee24445c..d5b949c0dabcf89e196dadeeb35bf37a230c2cf2 100644 (file)
@@ -77,7 +77,7 @@ bool ViewWidget::accept_drag() const
        if (any_row_items_selected && !any_time_items_selected) {
                // Check all the drag items share a common owner
                TraceTreeItemOwner *item_owner = nullptr;
-               for (shared_ptr<TraceTreeItem> r : trace_tree_items)
+               for (const shared_ptr<TraceTreeItem>& r : trace_tree_items)
                        if (r->dragging()) {
                                if (!item_owner)
                                        item_owner = r->owner();
@@ -107,7 +107,7 @@ void ViewWidget::drag_items(const QPoint &delta)
        // Drag the row items
        const vector< shared_ptr<RowItem> > row_items(
                view_.list_by_type<RowItem>());
-       for (shared_ptr<RowItem> r : row_items)
+       for (const shared_ptr<RowItem>& r : row_items)
                if (r->dragging()) {
                        r->drag_by(delta);
 
@@ -121,7 +121,7 @@ void ViewWidget::drag_items(const QPoint &delta)
        TraceTreeItemOwner *item_owner = nullptr;
        const vector< shared_ptr<TraceTreeItem> > trace_tree_items(
                view_.list_by_type<TraceTreeItem>());
-       for (shared_ptr<TraceTreeItem> i : trace_tree_items)
+       for (const shared_ptr<TraceTreeItem>& i : trace_tree_items)
                if (i->dragging())
                        item_owner = i->owner();
 
index c463ecc2d1a8dc16792a2c25a58f45836b8caaf7..3c9bc8c0eebc045b034eb8088464f5a4e98d5547 100644 (file)
@@ -82,7 +82,7 @@ unordered_set< shared_ptr<data::SignalBase> > ViewBase::signalbases() const
 
 void ViewBase::clear_signalbases()
 {
-       for (shared_ptr<data::SignalBase> signalbase : signalbases_) {
+       for (const shared_ptr<data::SignalBase>& signalbase : signalbases_) {
                disconnect(signalbase.get(), SIGNAL(samples_cleared()),
                        this, SLOT(on_data_updated()));
                disconnect(signalbase.get(), SIGNAL(samples_added(uint64_t, uint64_t, uint64_t)),
index bb18b792788cd3592eba4b46ddcb967cd17e89a7..6a12aa25c446904651b60bfe6de58e13d27eaa12 100644 (file)
@@ -91,7 +91,7 @@ void DeviceToolButton::update_device_list()
        menu_.setDefaultAction(connect_action_);
        menu_.addSeparator();
 
-       for (weak_ptr<Device> dev_weak_ptr : devices_) {
+       for (weak_ptr<Device>& dev_weak_ptr : devices_) {
                shared_ptr<Device> dev(dev_weak_ptr.lock());
                if (!dev)
                        continue;
@@ -117,7 +117,7 @@ void DeviceToolButton::on_action(QObject *action)
        selected_device_.reset();
 
        Device *const dev = (Device*)((QAction*)action)->data().value<void*>();
-       for (weak_ptr<Device> dev_weak_ptr : devices_) {
+       for (weak_ptr<Device>& dev_weak_ptr : devices_) {
                shared_ptr<Device> dev_ptr(dev_weak_ptr);
                if (dev_ptr.get() == dev) {
                        selected_device_ = shared_ptr<Device>(dev_ptr);