6464#include < libxml/xmlschemas.h>
6565#include < libxml/xmlstring.h>
6666#include < libxml/xmlversion.h>
67+ #include < array>
6768#include < limits>
6869#include < numeric>
6970#include < optional>
@@ -1847,16 +1848,16 @@ struct Player {
18471848 double final_time = 0 ;
18481849
18491850 fluid_settings_t &settings = []() -> fluid_settings_t & {
1850- fluid_settings_t &settings = get_reference (new_fluid_settings ());
1851+ fluid_settings_t &result = get_reference (new_fluid_settings ());
18511852 const auto cores = std::thread::hardware_concurrency ();
1852- set_fluid_int (settings , " synth.midi-channels" , NUMBER_OF_MIDI_CHANNELS);
1853+ set_fluid_int (result , " synth.midi-channels" , NUMBER_OF_MIDI_CHANNELS);
18531854 if (cores > 0 ) {
1854- set_fluid_int (settings , " synth.cpu-cores" , static_cast <int >(cores));
1855+ set_fluid_int (result , " synth.cpu-cores" , static_cast <int >(cores));
18551856 }
18561857#ifdef __linux__
1857- fluid_settings_setstr (&settings , " audio.driver" , " pulseaudio" );
1858+ fluid_settings_setstr (&result , " audio.driver" , " pulseaudio" );
18581859#endif
1859- return settings ;
1860+ return result ;
18601861 }();
18611862 fluid_event_t &event = get_reference(new_fluid_event());
18621863 fluid_sequencer_t &sequencer = get_reference(new_fluid_sequencer2(0 ));
@@ -2350,7 +2351,7 @@ parse_clipboard(QWidget &parent,
23502351
23512352 const auto &copied_text = mime_data.data (mime_type).toStdString ();
23522353 auto *document_pointer = xmlReadMemory (
2353- copied_text.c_str (), copied_text.size (), nullptr , nullptr , 0 );
2354+ copied_text.c_str (), static_cast < int >( copied_text.size () ), nullptr , nullptr , 0 );
23542355 if (document_pointer == nullptr ) {
23552356 QMessageBox::warning (&parent, QObject::tr (" Paste error" ),
23562357 QObject::tr (" Invalid XML" ));
@@ -2369,8 +2370,8 @@ parse_clipboard(QWidget &parent,
23692370
23702371 auto &root = get_root (document);
23712372 QList<SubRow> new_rows;
2372- int left_column = 0 ;
2373- int right_column = 0 ;
2373+ auto left_column = 0 ;
2374+ auto right_column = 0 ;
23742375
23752376 auto *field_pointer = xmlFirstElementChild (&root);
23762377 while (field_pointer != nullptr ) {
@@ -2381,7 +2382,7 @@ parse_clipboard(QWidget &parent,
23812382 } else if (name == " right_column" ) {
23822383 right_column = to_xml_int (field_node);
23832384 } else if (name == " rows" ) {
2384- int counter = 1 ;
2385+ auto counter = 1 ;
23852386 auto *xml_row_pointer = xmlFirstElementChild (&field_node);
23862387 while (xml_row_pointer != nullptr && counter <= max_rows) {
23872388 SubRow child_row;
@@ -2873,10 +2874,10 @@ struct SpinBoxes : public QWidget {
28732874 QFormLayout &spin_boxes_form = *(new QFormLayout(this ));
28742875
28752876 explicit SpinBoxes (Song &song, fluid_synth_t &synth, QUndoStack &undo_stack) {
2876- auto &gain_editor = this ->gain_editor ;
2877- auto &starting_key_editor = this ->starting_key_editor ;
2878- auto &starting_velocity_editor = this ->starting_velocity_editor ;
2879- auto &starting_tempo_editor = this ->starting_tempo_editor ;
2877+ auto &gain_editor_ref = this ->gain_editor ;
2878+ auto &starting_key_editor_ref = this ->starting_key_editor ;
2879+ auto &starting_velocity_editor_ref = this ->starting_velocity_editor ;
2880+ auto &starting_tempo_editor_ref = this ->starting_tempo_editor ;
28802881
28812882 add_control (spin_boxes_form, SpinBoxes::tr (" &Gain:" ), gain_editor, 0 ,
28822883 MAX_GAIN, SpinBoxes::tr (" /10" ), GAIN_STEP, 1 );
@@ -2892,28 +2893,28 @@ struct SpinBoxes : public QWidget {
28922893
28932894 QObject::connect (
28942895 &gain_editor, &QDoubleSpinBox::valueChanged, this ,
2895- [&undo_stack, &song, &synth, &gain_editor ](double new_value) {
2896- add_set_double (undo_stack, song, synth, gain_editor , gain_id,
2896+ [&undo_stack, &song, &synth, &gain_editor_ref ](double new_value) {
2897+ add_set_double (undo_stack, song, synth, gain_editor_ref , gain_id,
28972898 fluid_synth_get_gain (&synth), new_value);
28982899 });
28992900 QObject::connect (
29002901 &starting_key_editor, &QDoubleSpinBox::valueChanged, this ,
2901- [&undo_stack, &song, &synth, &starting_key_editor ](double new_value) {
2902- add_set_double (undo_stack, song, synth, starting_key_editor ,
2902+ [&undo_stack, &song, &synth, &starting_key_editor_ref ](double new_value) {
2903+ add_set_double (undo_stack, song, synth, starting_key_editor_ref ,
29032904 starting_key_id, song.starting_key , new_value);
29042905 });
29052906 QObject::connect (
29062907 &starting_velocity_editor, &QDoubleSpinBox::valueChanged, this ,
29072908 [&undo_stack, &song, &synth,
2908- &starting_velocity_editor ](double new_value) {
2909- add_set_double (undo_stack, song, synth, starting_velocity_editor ,
2909+ &starting_velocity_editor_ref ](double new_value) {
2910+ add_set_double (undo_stack, song, synth, starting_velocity_editor_ref ,
29102911 starting_velocity_id, song.starting_velocity ,
29112912 new_value);
29122913 });
29132914 QObject::connect (
29142915 &starting_tempo_editor, &QDoubleSpinBox::valueChanged, this ,
2915- [&undo_stack, &song, &synth, &starting_tempo_editor ](double new_value) {
2916- add_set_double (undo_stack, song, synth, starting_tempo_editor ,
2916+ [&undo_stack, &song, &synth, &starting_tempo_editor_ref ](double new_value) {
2917+ add_set_double (undo_stack, song, synth, starting_tempo_editor_ref ,
29172918 starting_tempo_id, song.starting_tempo , new_value);
29182919 });
29192920
@@ -3026,19 +3027,19 @@ struct IntervalRow : public QWidget {
30263027 row_layout.addWidget (&text);
30273028 row_layout.addWidget (&plus_button);
30283029
3029- auto &switch_column = this ->switch_column ;
3030- auto &undo_stack = this ->undo_stack ;
3031- const auto &interval = this ->interval ;
3030+ auto &switch_column_ref = this ->switch_column ;
3031+ auto &undo_stack_ref = this ->undo_stack ;
3032+ const auto &interval_ref = this ->interval ;
30323033
30333034 QObject::connect (&minus_button, &QPushButton::released, this ,
3034- [&undo_stack , &switch_column , &interval ]() {
3035- update_interval (undo_stack, switch_column ,
3036- Interval () / interval );
3035+ [&undo_stack_ref , &switch_column_ref , &interval_ref ]() {
3036+ update_interval (undo_stack_ref, switch_column_ref ,
3037+ Interval () / interval_ref );
30373038 });
30383039
30393040 QObject::connect (&plus_button, &QPushButton::released, this ,
3040- [&undo_stack , &switch_column , &interval ]() {
3041- update_interval (undo_stack, switch_column, interval );
3041+ [&undo_stack_ref , &switch_column_ref , &interval_ref ]() {
3042+ update_interval (undo_stack_ref, switch_column_ref, interval_ref );
30423043 });
30433044 }
30443045};
@@ -3337,7 +3338,6 @@ static void add_delete_cells(SongWidget &song_widget) {
33373338void save_as_file (SongWidget &song_widget, const QString &filename) {
33383339 Q_ASSERT (filename.isValidUtf16 ());
33393340 const auto &song = song_widget.song ;
3340- std::ofstream file_io (filename.toStdString ().c_str ());
33413341
33423342 auto &document = make_tree ();
33433343 auto &song_node = make_root (document, " song" );
@@ -3847,12 +3847,12 @@ void import_musicxml(SongWidget &song_widget, const QString &filename) {
38473847 auto *pitch_field_pointer = xmlFirstElementChild (¬e_field);
38483848 while (pitch_field_pointer != nullptr ) {
38493849 auto &pitch_field = get_reference (pitch_field_pointer);
3850- const auto &name = get_xml_name (pitch_field);
3851- if (name == " step" ) {
3850+ const auto &pitch_field_name = get_xml_name (pitch_field);
3851+ if (pitch_field_name == " step" ) {
38523852 midi_degree = note_to_midi[get_content (pitch_field)];
3853- } else if (name == " octave" ) {
3853+ } else if (pitch_field_name == " octave" ) {
38543854 octave_number = to_xml_int (pitch_field);
3855- } else if (name == " alter" ) {
3855+ } else if (pitch_field_name == " alter" ) {
38563856 alter = to_xml_int (pitch_field);
38573857 }
38583858 pitch_field_pointer =
@@ -4017,7 +4017,7 @@ struct FileMenu : public QMenu {
40174017 QAction export_action = QAction(FileMenu::tr(" &Export recording" ));
40184018
40194019 explicit FileMenu (SongWidget &song_widget) : QMenu(FileMenu::tr(" &File" )) {
4020- auto &save_action = this ->save_action ;
4020+ auto &save_action_ref = this ->save_action ;
40214021 add_menu_action (*this , open_action, QKeySequence::Open);
40224022 add_menu_action (*this , import_action, QKeySequence::StandardKey (), true );
40234023 addSeparator ();
@@ -4026,8 +4026,8 @@ struct FileMenu : public QMenu {
40264026 add_menu_action (*this , export_action);
40274027
40284028 QObject::connect (&song_widget.undo_stack , &QUndoStack::cleanChanged, this ,
4029- [&save_action , &song_widget]() {
4030- save_action .setEnabled (
4029+ [&save_action_ref , &song_widget]() {
4030+ save_action_ref .setEnabled (
40314031 !song_widget.undo_stack .isClean () &&
40324032 !song_widget.current_file .isEmpty ());
40334033 });
@@ -4562,8 +4562,8 @@ static void connect_selection_model(SongMenuBar &song_menu_bar,
45624562SongEditor::SongEditor ()
45634563 : song_widget(*(new SongWidget)),
45644564 song_menu_bar(*(new SongMenuBar(song_widget))) {
4565- auto &song_menu_bar = this ->song_menu_bar ;
4566- auto &song_widget = this ->song_widget ;
4565+ auto &song_menu_bar_ref = this ->song_menu_bar ;
4566+ auto &song_widget_ref = this ->song_widget ;
45674567
45684568 auto &switch_column = song_widget.switch_column ;
45694569 auto &undo_stack = song_widget.undo_stack ;
@@ -4587,36 +4587,36 @@ SongEditor::SongEditor()
45874587 switch_column.unpitched_notes_table );
45884588
45894589 QObject::connect (&song_menu_bar.view_menu .back_to_chords_action ,
4590- &QAction::triggered, this , [&song_menu_bar , &song_widget ]() {
4591- add_replace_table (song_menu_bar, song_widget , chord_type,
4590+ &QAction::triggered, this , [&song_menu_bar_ref , &song_widget_ref ]() {
4591+ add_replace_table (song_menu_bar_ref, song_widget_ref , chord_type,
45924592 -1 );
45934593 });
45944594
45954595 QObject::connect (
45964596 &switch_column.chords_table , &QAbstractItemView::doubleClicked, this ,
4597- [&song_menu_bar , &song_widget ](const QModelIndex &index) {
4597+ [&song_menu_bar_ref , &song_widget_ref ](const QModelIndex &index) {
45984598 const auto column = index.column ();
45994599 const auto is_pitched = column == chord_pitched_notes_column;
46004600 if (is_pitched || (column == chord_unpitched_notes_column)) {
46014601 add_replace_table (
4602- song_menu_bar, song_widget ,
4602+ song_menu_bar_ref, song_widget_ref ,
46034603 (is_pitched ? pitched_note_type : unpitched_note_type),
46044604 index.row ());
46054605 }
46064606 });
46074607
46084608 QObject::connect (&song_menu_bar.view_menu .previous_chord_action ,
4609- &QAction::triggered, this , [&song_menu_bar , &song_widget ]() {
4610- const auto &switch_column = song_widget .switch_column ;
4611- add_replace_table (song_menu_bar, song_widget ,
4609+ &QAction::triggered, this , [&song_menu_bar_ref , &song_widget_ref ]() {
4610+ const auto &switch_column = song_widget_ref .switch_column ;
4611+ add_replace_table (song_menu_bar_ref, song_widget_ref ,
46124612 switch_column.current_row_type ,
46134613 get_parent_chord_number (switch_column) -
46144614 1 );
46154615 });
46164616 QObject::connect (&song_menu_bar.view_menu .next_chord_action ,
4617- &QAction::triggered, this , [&song_menu_bar , &song_widget ]() {
4618- const auto &switch_column = song_widget .switch_column ;
4619- add_replace_table (song_menu_bar, song_widget ,
4617+ &QAction::triggered, this , [&song_menu_bar_ref , &song_widget_ref ]() {
4618+ const auto &switch_column = song_widget_ref .switch_column ;
4619+ add_replace_table (song_menu_bar_ref, song_widget_ref ,
46204620 switch_column.current_row_type ,
46214621 get_parent_chord_number (switch_column) +
46224622 1 );
0 commit comments