diff --git a/backends/ui/gtk/main_window.cpp b/backends/ui/gtk/main_window.cpp index 9084ed7..05956e2 100644 --- a/backends/ui/gtk/main_window.cpp +++ b/backends/ui/gtk/main_window.cpp @@ -41,6 +41,11 @@ void MainWindow::update_file(optional new_file) { seek_bar.set_value(0.0); } int i = 0; + for (auto row : stream_selection_box.get_children()) { + int *data = (int*)row->get_data(Glib::Quark("id")); + row->remove_data(Glib::Quark("id")); + delete data; + } stream_selection_box.remove_all(); for (auto &stream : playback->get_streams()) { int id = i++; @@ -58,14 +63,14 @@ void MainWindow::update_file(optional new_file) { Gtk::ListBoxRow listBoxRow; listBoxRow.set_child(parentBox); listBoxRow.set_hexpand(); - listBoxRow.set_data(Glib::Quark("id"), (void*)id); + listBoxRow.set_data(Glib::Quark("id"), new int(id)); stream_selection_box.append(listBoxRow); if (id == this->playback->get_current_stream()) { stream_selection_box.select_row(listBoxRow); } } stream_selection_box.signal_row_selected().connect([=,this](auto *row) { - this->playback->play_stream((int)row->get_data(Glib::Quark("id"))); + this->playback->play_stream(*(int*)row->get_data(Glib::Quark("id"))); }); std::optional title = playback->get_current_title(); song_name = title.value_or("");