From b57fea81208b84c7d339debf47f62f52fc868725 Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Fri, 29 May 2020 20:43:07 -0700 Subject: [PATCH] Factoids: fix export errors upon exit by correcting atexit registration order --- PBot/Factoids.pm | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/PBot/Factoids.pm b/PBot/Factoids.pm index c6957369..76190f02 100644 --- a/PBot/Factoids.pm +++ b/PBot/Factoids.pm @@ -70,9 +70,11 @@ our %factoid_metadata = ( sub initialize { my ($self, %conf) = @_; my $filename = $conf{filename}; - $self->{factoids} = PBot::DualIndexSQLiteObject->new(name => 'Factoids', filename => $filename, pbot => $self->{pbot}); - $self->{pbot} = $self->{pbot}; + $self->{pbot} = $self->{pbot}; + $self->{pbot}->{atexit}->register(sub { $self->save_factoids; return; }); + + $self->{factoids} = PBot::DualIndexSQLiteObject->new(name => 'Factoids', filename => $filename, pbot => $self->{pbot}); $self->{commands} = PBot::FactoidCommands->new(pbot => $self->{pbot}); $self->{pbot}->{registry}->add_default('text', 'factoids', 'default_rate_limit', 15); @@ -80,7 +82,6 @@ sub initialize { $self->{pbot}->{registry}->add_default('text', 'factoids', 'max_content_length', 1024 * 8); $self->{pbot}->{registry}->add_default('text', 'factoids', 'max_channel_length', 20); - $self->{pbot}->{atexit}->register(sub { $self->save_factoids; return; }); $self->load_factoids; }