Changeset 10574

Show
Ignore:
Timestamp:
02/07/10 03:30:39 (7 months ago)
Author:
tsee
Message:

Split time of event initialization even further so that the events get initialized in the case that Tasks aren't even scheduled but just run.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/Padre/lib/Padre/Task.pm

    r10570 r10574  
    116116our $VERSION = '0.56'; 
    117117 
     118# set up the stdout/stderr printing events => initialized during run time 
     119our $STDOUT_EVENT : shared; 
     120our $STDERR_EVENT : shared; 
     121 
    118122# TO DO: Why are there require? 
    119123require Padre; 
     
    129133} 
    130134 
    131 use Class::XSAccessor { 
    132         constructor => 'new', 
    133 }; 
    134  
    135 # set up the stdout/stderr printing events => initialized during run time 
    136 our $STDOUT_EVENT : shared; 
    137 our $STDERR_EVENT : shared; 
    138  
    139135=pod 
    140136 
     
    145141hash reference. 
    146142 
     143=cut 
     144 
     145 
     146sub new { 
     147        my $class = shift; 
     148        my $self = bless {@_} => $class; 
     149        if ( not defined $STDOUT_EVENT ) { 
     150                $STDOUT_EVENT = Wx::NewEventType(); 
     151                $STDERR_EVENT = Wx::NewEventType(); 
     152        } 
     153        return $self; 
     154} 
    147155=head2 schedule 
    148156 
     
    155163=cut 
    156164 
    157 sub schedule { 
    158         my $self = shift; 
    159         if ( not defined $STDOUT_EVENT ) { 
    160                 $STDOUT_EVENT = Wx::NewEventType(); 
    161                 $STDERR_EVENT = Wx::NewEventType(); 
    162                 my $main = Padre->ide->wx->main; 
    163                 Wx::Event::EVT_COMMAND( 
    164                         $main, 
    165                         -1, 
    166                         $STDOUT_EVENT, 
    167                         \&_on_stdout, 
    168                 ); 
    169                 Wx::Event::EVT_COMMAND( 
    170                         $main, 
    171                         -1, 
    172                         $STDERR_EVENT, 
    173                         \&_on_stderr, 
    174                 ); 
    175         } 
    176         Padre->ide->task_manager->schedule($self); 
     165SCOPE: { 
     166        my $event_hooks_initialized = 0; 
     167        sub schedule { 
     168                my $self = shift; 
     169                if (not $event_hooks_initialized) { 
     170                        $event_hooks_initialized = 1; 
     171                        my $main = Padre->ide->wx->main; 
     172                        Wx::Event::EVT_COMMAND( 
     173                                $main, 
     174                                -1, 
     175                                $STDOUT_EVENT, 
     176                                \&_on_stdout, 
     177                        ); 
     178                        Wx::Event::EVT_COMMAND( 
     179                                $main, 
     180                                -1, 
     181                                $STDERR_EVENT, 
     182                                \&_on_stderr, 
     183                        ); 
     184                } 
     185                Padre->ide->task_manager->schedule($self); 
     186        } 
    177187} 
    178188