Просмотр исходного кода

Revert "Fix #192: DEMOLISH slightly earlier, before losing references"

okay asked on #moose about about why this might happen and it is pretty
straightforward to reproduce:

    our $d = Selenium::Remote::Driver->new;
    die 'without explicitly forcing $d out of scope';

in that case the DEMOLISH sub for $d only gets called during global
destruction, at which time we have no guarantee that our objects are
still around. making a new $ua during global destruction is not a good
idea, either.

I think in the case where the $driver object is forced to hang around
until GD, there's nothing we can do any more to close the browser,
unfortunately. Moving things to a before DEMOLISH doesn't work either
because the before still fires during GD, so it's still sad times all
around.

We can suppress the warning by checking if we're getting DEMOLISHed
during GD, but I think we just recommend users to explicitly call quit
and to throw our hands up about the leftover browser :(
Daniel Gempesaw 10 лет назад
Родитель
Сommit
04779e0f4c
1 измененных файлов с 2 добавлено и 4 удалено
  1. 2 4
      lib/Selenium/Remote/Driver.pm

+ 2 - 4
lib/Selenium/Remote/Driver.pm

@@ -486,13 +486,11 @@ sub new_from_caps {
     return $self->new(%args);
 }
 
-before 'DEMOLISH' => sub {
+sub DEMOLISH {
     my ($self) = @_;
     return if $$ != $self->pid;
     $self->quit() if ( $self->auto_close && defined $self->session_id );
-};
-
-sub DEMOLISH {}
+}
 
 # This is an internal method used the Driver & is not supposed to be used by
 # end user. This method is used by Driver to set up all the parameters