1
0
mirror of https://github.com/clementine-player/Clementine synced 2024-12-15 18:58:55 +01:00

Check the playlist context menu index is valid before getting data from it. Fixes issue #109

This commit is contained in:
David Sansome 2010-03-24 16:13:05 +00:00
parent 70b6ba8c39
commit ad30bad33c

View File

@ -585,18 +585,22 @@ void MainWindow::PlaylistRightClick(const QPoint& global_pos, const QModelIndex&
ui_.action_renumber_tracks->setEnabled(editable); ui_.action_renumber_tracks->setEnabled(editable);
ui_.action_selection_set_value->setEnabled(editable >= 2); ui_.action_selection_set_value->setEnabled(editable >= 2);
Playlist::Column column = (Playlist::Column)playlist_menu_index_.column(); if (!index.isValid()) {
ui_.action_selection_set_value->setVisible( ui_.action_selection_set_value->setVisible(false);
column <= Playlist::Column_Genre && } else {
column != Playlist::Column_Length); Playlist::Column column = (Playlist::Column)index.column();
ui_.action_selection_set_value->setVisible(
column <= Playlist::Column_Genre &&
column != Playlist::Column_Length);
QString column_name = Playlist::column_name(column); QString column_name = Playlist::column_name(column);
QString column_value = playlist_->data(playlist_menu_index_).toString(); QString column_value = playlist_->data(index).toString();
if (column_value.length() > 25) if (column_value.length() > 25)
column_value = column_value.left(25) + "..."; column_value = column_value.left(25) + "...";
ui_.action_selection_set_value->setText(tr("Set %1 to \"%2\"...") ui_.action_selection_set_value->setText(tr("Set %1 to \"%2\"...")
.arg(column_name.toLower()).arg(column_value)); .arg(column_name.toLower()).arg(column_value));
}
playlist_menu_->popup(global_pos); playlist_menu_->popup(global_pos);
} }