Unverified Commit 57a496a1 authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

Journey: Do not weaken hafas reference in stop items

The Stop constructor is called lazily and must have access to a hafas
reference for its add_message function and strptime_obj key. If the hafas
object goes out of scope before Journey->route is called, those may have
been garbage-collected already.

Apart from that, the weaken call was useless, since a Stop object does not
store the hafas reference provided in its constructor. So, as soon as
Journey->route is called, the hafas references in @{$journey->{route}} go out
of scope anyways.
parent 8af2aecb
Loading
Loading
Loading
Loading
+1 −4
Original line number Diff line number Diff line
@@ -9,7 +9,6 @@ use 5.014;
use parent 'Class::Accessor';
use DateTime::Format::Strptime;
use List::Util qw(any);
use Scalar::Util qw(weaken);
use Travel::Status::DE::HAFAS::Stop;

our $VERSION = '5.01';
@@ -120,8 +119,6 @@ sub new {
			datetime_ref => $datetime_ref,
		};

		weaken( $stopref->{hafas} );

		push( @stops, $stopref );

		$route_end = $loc->name;