aboutsummaryrefslogtreecommitdiffstats
path: root/edit-urpm-sources.pl
diff options
context:
space:
mode:
authorGuillaume Cottenceau <gc@mandriva.com>2003-01-22 20:46:55 +0000
committerGuillaume Cottenceau <gc@mandriva.com>2003-01-22 20:46:55 +0000
commitd0532e6c480f0bd09a55180e0e26deb5b6b85244 (patch)
tree7aa2c8a149622e7fa74914a39f357e9765b496b9 /edit-urpm-sources.pl
parentff1337faad66dfbf06ef34b51f24bbeb631a07bf (diff)
downloadrpmdrake-d0532e6c480f0bd09a55180e0e26deb5b6b85244.tar
rpmdrake-d0532e6c480f0bd09a55180e0e26deb5b6b85244.tar.gz
rpmdrake-d0532e6c480f0bd09a55180e0e26deb5b6b85244.tar.bz2
rpmdrake-d0532e6c480f0bd09a55180e0e26deb5b6b85244.tar.xz
rpmdrake-d0532e6c480f0bd09a55180e0e26deb5b6b85244.zip
fix crashing when managing to call Remove or Edit with nothing
selected (#970)
Diffstat (limited to 'edit-urpm-sources.pl')
-rwxr-xr-xedit-urpm-sources.pl9
1 files changed, 7 insertions, 2 deletions
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},