From d0532e6c480f0bd09a55180e0e26deb5b6b85244 Mon Sep 17 00:00:00 2001 From: Guillaume Cottenceau Date: Wed, 22 Jan 2003 20:46:55 +0000 Subject: fix crashing when managing to call Remove or Edit with nothing selected (#970) --- edit-urpm-sources.pl | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'edit-urpm-sources.pl') diff --git a/edit-urpm-sources.pl b/edit-urpm-sources.pl index 587017c9..d05a582c 100755 --- a/edit-urpm-sources.pl +++ b/edit-urpm-sources.pl @@ -150,6 +150,7 @@ really want to replace it?"), yesno => 1) or return 0; sub selrow { my ($model, $iter) = $list_tv->get_selection->get_selected; + $model && $iter or return -1; my $path = $model->get_path($iter); my $row = $path->to_string; $path->free; @@ -158,8 +159,10 @@ sub selrow { } sub remove_callback { + my $row = selrow(); + $row == -1 and return; my $wait = wait_msg(N("Please wait, removing medium...")); - my $name = $urpm->{media}[selrow()]{name}; + my $name = $urpm->{media}[$row]{name}; standalone::explanations("Removing medium $name"); $urpm->select_media($name); $urpm->remove_selected_media; @@ -168,7 +171,9 @@ sub remove_callback { } sub edit_callback { - my $medium = $urpm->{media}[selrow()]; + my $row = selrow(); + $row == -1 and return; + my $medium = $urpm->{media}[$row]; my $w = ugtk2->new(N("Edit a source"), grab => 1, center => 1, transient => $mainw->{rwindow}); my ($url_entry, $hdlist_entry, $url, $with_hdlist); gtkadd($w->{window}, -- cgit v1.2.1