################################################################# --- ptkdb.pm 2003/07/23 17:05:20 1.1 +++ ptkdb.pm 2003/07/23 17:51:09 @@ -1105,8 +1105,21 @@ # Main Window - +eval { $self->{main_window} = MainWindow->new() ; +}; +if ($@) { + my $err = $@; + my $r = eval { Apache->request }; # check if running under mod_perl + undef $@; + if ($r && $err =~ m/Xlib: connection .*? refused|Xlib: Client is not authorized|couldn't connect to display/) { + $DB::connection_refused = 1; + $self->{main_window} = undef; + warn($err); # log the problem + return; + } + die $err; +} $self->{main_window}->geometry($ENV{'PTKDB_GEOMETRY'} || "800x600") ; $self->setup_options() ; # must be done after MainWindow and before other frames are setup @@ -1237,8 +1250,9 @@ $DB::window->{'event'} = 'run' ; $self->{current_file} = "" ; # force a file reset - $self->{'main_window'}->destroy ; + $self->{'main_window'}->destroy if $self->{'main_window'}; $self->{'main_window'} = undef ; + $DB::connection_refused = undef; # allow another try } sub setup_menu_bar { @@ -4048,7 +4062,12 @@ $^W = $saveW ; unless( $DB::ptkdb::isInitialized ) { - return if( $filename ne $0 ) ; # not in our target file + if ( $filename ne $0 ) { # not in our target file + # check if running under mod_perl + my $r = eval { Apache->request }; + undef $@; + return unless $r; + } &DB::Initialize($filename) ; } @@ -4063,6 +4082,11 @@ return ; } + if ( $DB::connection_refused ) { # X to remote host failed + $@ = $DB::save_err ; + return ; + } + $DB::window->setup_main_window() unless $DB::window->{'main_window'} ; $DB::window->EnterActions() ; #################################################################