Changeset 9762
- Timestamp:
- 12/17/09 20:11:36 (9 months ago)
- Location:
- trunk/Padre
- Files:
-
- 7 modified
-
Changes (modified) (1 diff)
-
lib/Padre/Document/Perl.pm (modified) (1 diff)
-
lib/Padre/Lock.pm (modified) (2 diffs)
-
lib/Padre/Locker.pm (modified) (3 diffs)
-
lib/Padre/Wx/Directory/SearchCtrl.pm (modified) (1 diff)
-
lib/Padre/Wx/Directory/TreeCtrl.pm (modified) (1 diff)
-
lib/Padre/Wx/Main.pm (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Padre/Changes
r9749 r9762 16 16 - Fixed missing mime type guessing that caused new Padre documents to 17 17 default always to Scintilla (AZAWAWI) 18 - Landed first phase of new multi-resource locking subsystem (ADAMK) 18 19 19 20 0.52 2009.12.14 -
trunk/Padre/lib/Padre/Document/Perl.pm
r9685 r9762 1518 1518 $dialog->Destroy; 1519 1519 return unless defined $replacement; 1520 my $lock = $editor->main->lock('BUSY'); 1520 1521 $doc->lexical_variable_replacement($replacement); 1521 1522 }, -
trunk/Padre/lib/Padre/Lock.pm
r9685 r9762 9 9 sub new { 10 10 my $class = shift; 11 my $self = bless {@_}, $class;11 my $self = bless { @_ }, $class; 12 12 13 13 # Enable the locks 14 if ( $self->{ update} ) {14 if ( $self->{UPDATE} ) { 15 15 $self->{locker}->update_enable; 16 16 } 17 if ( $self->{ busy} ) {17 if ( $self->{BUSY} ) { 18 18 $self->{locker}->busy_enable; 19 19 } … … 22 22 } 23 23 24 # Disable locking on destruction 24 25 sub DESTROY { 25 26 # Disable the locks 27 if ( $_[0]->{update} ) { 26 if ( $_[0]->{UPDATE} ) { 28 27 $_[0]->{locker}->update_disable; 29 28 } 30 if ( $_[0]->{ busy} ) {29 if ( $_[0]->{BUSY} ) { 31 30 $_[0]->{locker}->busy_disable; 32 31 } -
trunk/Padre/lib/Padre/Locker.pm
r9685 r9762 1 1 package Padre::Locker; 2 3 =pod 4 5 =head1 NAME 6 7 Padre::Locker - The Padre Multi-Resource Lock Manager 8 9 =cut 2 10 3 11 use 5.008; … … 32 40 sub lock { 33 41 my $self = shift; 34 return Padre::Lock->new( map { $_ => 1 } @_ ); 42 return Padre::Lock->new( 43 locker => $self, 44 map { $_ => 1 } @_ 45 ); 35 46 } 36 47 … … 67 78 68 79 # Locking for the first time 69 $self->{busy_locker} = Wx:: WindowDisabler->new;80 $self->{busy_locker} = Wx::BusyCursor->new; 70 81 } 71 82 return; -
trunk/Padre/lib/Padre/Wx/Directory/SearchCtrl.pm
r9685 r9762 518 518 # Lock the gui here to make the updates look slicker 519 519 # The locker holds the gui freeze until the update is done. 520 my $lock er = $self->current->main->freezer;520 my $lock = $self->current->main->lock('UPDATE'); 521 521 522 522 # Cleans the Directory Browser window to show the result -
trunk/Padre/lib/Padre/Wx/Directory/TreeCtrl.pm
r9685 r9762 149 149 # Lock the gui here to make the updates look slicker 150 150 # The locker holds the gui freeze until the update is done. 151 my $lock er = $self->main->freezer;151 my $lock = $self->main->lock('UPDATE'); 152 152 153 153 # If the project have changed or the project root folder updates or -
trunk/Padre/lib/Padre/Wx/Main.pm
r9749 r9762 128 128 $self->{config} = $config; 129 129 130 # Create the lock manager before any gui operations, 131 # so that we can do locking operations during startup. 132 $self->{locker} = Padre::Locker->new($self); 133 130 134 # Determine the window title (needs ide & config) 131 135 $self->set_title; 132 136 137 # Remember where the editor started from, 138 # this could be handy later. 139 $self->{cwd} = Cwd::cwd(); 140 141 # There is a directory locking problem on Win32. 142 # If we open Padre from a directory and leave the Cwd cursor 143 # in that directory, then it can NEVER be deleted. 133 144 # Having recorded the "current working directory" move 134 # the OS directory cursor away from this directory, so 135 # that Padre won't hold a lock on the current directory. 136 # If changing the directory fails, ignore errors (for now) 137 $self->{cwd} = Cwd::cwd(); 138 if (Padre::Constant::WIN32) { 139 140 # Directory locking problem only exists on Win 145 # the OS directory cursor away from this starting directory, 146 # so that Padre won't hold an implicit OS lock on it. 147 # NOTE: If changing the directory fails, ignore errors for now, 148 # since that means we have WAY bigger problems. 149 if ( Padre::Constant::WIN32 ) { 141 150 chdir( File::HomeDir->my_home ); 142 151 } 152 153 # Bootstrap locale support before we start fiddling with the GUI. 154 $self->{locale} = Padre::Locale::object(); 143 155 144 156 # A large complex application looks, frankly, utterly stupid 145 157 # if it gets very small, or even mildly small. 146 158 $self->SetMinSize( Wx::Size->new( 500, 400 ) ); 147 148 # Set the locale149 $self->{locale} = Padre::Locale::object();150 159 151 160 # Drag and drop support … … 330 339 331 340 # GUI Elements 341 ide => 'ide', 342 config => 'config', 332 343 title => 'title', 333 config => 'config',334 ide => 'ide',335 344 aui => 'aui', 336 345 menu => 'menu', … … 347 356 348 357 # Operating Data 358 locker => 'locker', 349 359 cwd => 'cwd', 350 360 search => 'search', … … 619 629 =pod 620 630 621 =head2 C<freezer> 622 623 my $locker = $main->freezer; 624 625 Create and return an automatic C<freeze> object that will C<thaw> on destruction. 626 627 =cut 628 629 sub freezer { 630 Wx::WindowUpdateLocker->new( $_[0] ); 631 =head2 C<lock> 632 633 my $lock = $main->lock('UPDATE', 'BUSY', 'refresh_menu'); 634 635 Create and return a guard object that holds resource locks of various types. 636 637 The method takes a parameter list of the locks you wish to exist for the 638 current scope. Special types of locks are provided in capitals, 639 refresh/method locks are provided in lowercase. 640 641 The C<UPDATE> lock creates a Wx repaint lock using the built in 642 L<Wx::WindowUpdateLocker> class. 643 644 You should use an update lock during GUI construction/modification to 645 prevent screen flicker. As a side effect of not updating, the GUI changes 646 happen B<significantly> faster as well. Update locks should only be held for 647 short periods of time, as the operating system will begin to treat your\ 648 application as "hung" if an update lock persists for more than a few 649 seconds. In this situation, you may begin to see GUI corruption. 650 651 The C<BUSY> lock creates a Wx "busy" lock using the built in 652 L<Wx::WindowDisabler> class. 653 654 You should use a busy lock during times when Padre has to do a long and/or 655 complex operation in the foreground, or when you wish to disable use of any 656 user interface elements until a background thread is finished. 657 658 Busy locks can be held for long periods of time, however your users may 659 start to suspect trouble if you do not provide any periodic feedback to them. 660 661 Lowercase lock names are used to delay the firing of methods that will 662 themselves generate GUI events you may want to delay until you are sure 663 you want to rebuild the GUI. 664 665 For example, opening a file will require a Padre::Wx::Main refresh call, 666 which will itself generate more refresh calls on the directory browser, the 667 function list, output window, menus, and so on. 668 669 But if you open more than one file at a time, you don't want to refresh the 670 menu for the first file, only to do it again on the second, third and 671 fourth files. 672 673 By creating refresh locks in the top level operation, you allow the lower 674 level operation to make requests for parts of the GUI to be refreshed, but 675 have the actual refresh actions delayed until the lock expires. 676 677 This should make operations with a high GUI intensity both simpler and 678 faster. 679 680 The name of the lowercase MUST be the name of a Padre::Wx::Main method, 681 which will be fired (with no params) when the method lock expires. 682 683 =cut 684 685 sub lock { 686 shift->locker->lock( @_ ); 631 687 } 632 688 … … 903 959 904 960 # Freeze during the refresh 905 my $ guard = $self->freezer;961 my $lock = $self->lock('UPDATE'); 906 962 my $current = $self->current; 907 963 … … 1208 1264 1209 1265 # Do everything inside a freeze 1210 my $ guard = $self->freezer;1266 my $lock = $self->lock('UPDATE'); 1211 1267 1212 1268 # The biggest potential change is that the user may have a … … 2828 2884 # Lock both Perl and Wx-level updates 2829 2885 local $self->{_no_refresh} = 1; 2830 my $ guard = $self->freezer;2886 my $lock = $self->lock('UPDATE'); 2831 2887 2832 2888 # If and only if there is only one current file, … … 3333 3389 3334 3390 sub reload_all { 3335 my $self = shift;3336 my $skip = shift;3337 my $ guard = $self->freezer;3391 my $self = shift; 3392 my $skip = shift; 3393 my $lock = $self->lock('UPDATE'); 3338 3394 3339 3395 my @pages = $self->pageids; … … 3839 3895 3840 3896 sub close_all { 3841 my $self = shift;3842 my $skip = shift;3843 my $ guard = $self->freezer;3897 my $self = shift; 3898 my $skip = shift; 3899 my $lock = $self->lock('UPDATE'); 3844 3900 3845 3901 my $manager = $self->{ide}->plugin_manager; … … 3899 3955 my $where = shift; 3900 3956 my $notebook = $self->notebook; 3901 my $ guard = $self->freezer;3957 my $lock = $self->lock('UPDATE'); 3902 3958 foreach my $id ( reverse $self->pageids ) { 3903 3959 if ( $where->( $notebook->GetPage($id)->{Document} ) ) {
