Subject: | singleton objects are destroyed, leading to |
i just updated moose to 0.90, and moosex::singleton to 0.21
and now in games::pandemic, i get some errors. i managed to trace it to
the fact that singleton object changes over the program life.
to observe it, apply the following patch to games-pandemic:
diff --git a/lib/Games/Pandemic/Controller.pm
b/lib/Games/Pandemic/Controller.pm
index 6a59cff..fd799f8 100644
--- a/lib/Games/Pandemic/Controller.pm
+++ b/lib/Games/Pandemic/Controller.pm
@@ -236,6 +236,7 @@ Create a new game: (re-)initialize the map, and
various internal states.
event new_game => sub {
my $game = Games::Pandemic->instance;
+ say "*** new_game: $game";
$game->has_started;
# create the map
diff --git a/lib/Games/Pandemic/Tk/Main.pm b/lib/Games/Pandemic/Tk/Main.pm
index 2b0861f..4b2d778 100644
--- a/lib/Games/Pandemic/Tk/Main.pm
+++ b/lib/Games/Pandemic/Tk/Main.pm
@@ -1297,7 +1297,7 @@ sub _build_status_bar {
my $s = $self->_session;
my $tip = $self->_w('tooltip');
my $tipmsg;
-
+say "*** build_status_bar: $game";
# the status bar itself is a frame
my $sb = $mw->Frame->pack(@RIGHT, @FILLX,
-before=>$self->_w('canvas'));
$self->_set_w( infobar => $sb );
then run pandemic:
$ ./bin/pandemic
and start a new game with ctrl+n
*** run: Games::Pandemic=HASH(0x2c6ca50)
*** new_game: Games::Pandemic=HASH(0x2b534b0)
==> the singleton has changed
even better, add a DEMOLISH sub in lib/Games/Pandemic.pm
diff --git a/lib/Games/Pandemic.pm b/lib/Games/Pandemic.pm
index 0ef0bde..a52ecee 100644
--- a/lib/Games/Pandemic.pm
+++ b/lib/Games/Pandemic.pm
@@ -21,6 +21,7 @@ use Games::Pandemic::Config;
use Games::Pandemic::Controller;
use Games::Pandemic::Tk::Main;
+sub DEMOLISH { say "******* lost singleton"; }
# -- accessors
==> rerun the prog, start a new game:
*** run: Games::Pandemic=HASH(0x2c6ca50)
******* lost singleton
******* lost singleton
*** new_game: Games::Pandemic=HASH(0x2b534b0)
******* lost singleton