From 407c43f174d0ea123af9d5a032abfbd0b156a2c4 Mon Sep 17 00:00:00 2001 From: Angelo Naselli Date: Fri, 28 Nov 2014 14:37:45 +0100 Subject: fixed slow_func (ncurses crash) --- lib/AdminPanel/Rpmdragora/gui.pm | 8 ++++---- lib/AdminPanel/rpmdragora.pm | 25 ++++++++++++++++++++++--- modules/rpmdragora/rpmdragora | 6 +++--- 3 files changed, 29 insertions(+), 10 deletions(-) diff --git a/lib/AdminPanel/Rpmdragora/gui.pm b/lib/AdminPanel/Rpmdragora/gui.pm index e9f39b6c..8bb50d9a 100644 --- a/lib/AdminPanel/Rpmdragora/gui.pm +++ b/lib/AdminPanel/Rpmdragora/gui.pm @@ -231,7 +231,7 @@ sub get_details { sub get_new_deps { my ($urpm, $upkg) = @_; - my $deps = slow_func(undef, sub { + my $deps = slow_func(sub { my $state = {}; my $db = open_rpm_db(); my @requested = $urpm->resolve_requested__no_suggests_( @@ -1433,7 +1433,7 @@ sub toggle_nodes { if (member($old_state, qw(to_remove installed))) { # remove pacckages if ($new_state) { my @remove; - slow_func($widget, sub { @remove = closure_removal(@nodes) }); + slow_func(sub { @remove = closure_removal(@nodes) }); @nodes_with_deps = grep { !$pkgs->{$_}{selected} && !/^basesystem/ } @remove; $warn_about_additional_packages_to_remove->( $loc->N("Because of their dependencies, the following package(s) also need to be removed:")); @@ -1650,7 +1650,7 @@ sub _build_tree { $tree->startMultipleChanges(); # my $selected_group = $tree->selectedItem()-> - $tree->deleteAllItems(); + $tree->deleteAllItems() if $tree->hasItems(); # TODO fixing geti icon api to get a better hash from the module my %icons = (); @@ -1780,7 +1780,7 @@ sub get_info { #- the package information hasn't been loaded. Instead of rescanning the media, just give up. exists $pkgs->{$key} or return [ [ $loc->N("Description not available for this package\n") ] ]; #- get the description if needed: - exists $pkgs->{$key}{description} or slow_func("", sub { extract_header($pkgs->{$key}, $urpm, 'info', find_installed_version($pkgs->{$key}{pkg})) }); + exists $pkgs->{$key}{description} or slow_func(sub { extract_header($pkgs->{$key}, $urpm, 'info', find_installed_version($pkgs->{$key}{pkg})) }); _format_pkg_simplifiedinfo($pkgs, $key, $urpm, $descriptions, $options); } diff --git a/lib/AdminPanel/rpmdragora.pm b/lib/AdminPanel/rpmdragora.pm index 5cdf7514..f79b4997 100644 --- a/lib/AdminPanel/rpmdragora.pm +++ b/lib/AdminPanel/rpmdragora.pm @@ -410,14 +410,33 @@ sub remove_wait_msg { sub but { " $_[0] " } sub but_ { " $_[0] " } -sub slow_func ($&) { - my ($param, $func) = @_; +#============================================================= + +=head2 slow_func + +=head3 INPUT + + $func: function to be executed with a busy cursor or waiting + dialog + $msg: message to be shown in ncurses waiting dialog (if any) + +=head3 DESCRIPTION + + This function executes a given function with a busy cursor set + in graphical environment, or with a waiting dialog if in ncurses + text mode + +=cut + +#============================================================= +sub slow_func (&) { + my ($func, $msg) = @_; my $retval = 1; # NOTE busy cursor is not implemented in yui-ncurses # but we can avoid a waiting dialog in Gtk and QT if (yui::YUI::app()->isTextMode()) { - my $w = wait_msg($param); + my $w = wait_msg($msg); $retval = $func->(); remove_wait_msg($w) } diff --git a/modules/rpmdragora/rpmdragora b/modules/rpmdragora/rpmdragora index 711b6f18..80d0aa92 100755 --- a/modules/rpmdragora/rpmdragora +++ b/modules/rpmdragora/rpmdragora @@ -116,7 +116,7 @@ sub filterbox_callback { if ($filter->[0] ne $val) { $filter->[0] = $val; reset_search(); - slow_func($::main_window, sub { switch_pkg_list_mode($default_list_mode) }); + slow_func(sub { switch_pkg_list_mode($default_list_mode) }); $options->{rebuild_tree}->(); } @@ -776,7 +776,7 @@ sub run_treeview_dialog { # ); my $reload_db_and_clear_all = sub { - slow_func($::main_window, sub { + slow_func(sub { $force_rebuild = 1; AdminPanel::Rpmdragora::gui::pkgs_provider($options->{tree_mode}, skip_updating_mu => 1); AdminPanel::Rpmdragora::gui::reset_search(); @@ -1077,7 +1077,7 @@ sub run_treeview_dialog { #gtkflush(); #OLD slow_func($::main_window->window, sub { pkgs_provider($default_list_mode) }); # default mode - slow_func($::main_window, sub { pkgs_provider($default_list_mode) }); # default mode + slow_func(sub { pkgs_provider($default_list_mode) }); # default mode if (@initial_selection) { print "\n== Initial selection: @initial_selection\n"; $options->{initial_selection} = \@initial_selection; -- cgit v1.2.1