From 4efcfdcdbae7950ddd81bc8800062e46ccae223d Mon Sep 17 00:00:00 2001 From: Shugo Maeda Date: Fri, 4 Sep 2026 11:17:20 +0900 Subject: [PATCH] rabbit: don't reuse the destroyed Gtk::Application Fix GH-195 Rabbit.application memoizes the Gtk::Application but Rabbit::Command::Rabbit#run unrefs it after running. So running rabbit twice in one process (e.g. "rake pdf" in a theme directory, which generates the en and ja PDFs) failed on the second run with "TypeError: destroyed GLib::Object". Co-Authored-By: Claude Fable 5.1 --- lib/rabbit/command/rabbit.rb | 3 +-- lib/rabbit/rabbit.rb | 7 +++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/rabbit/command/rabbit.rb b/lib/rabbit/command/rabbit.rb index b7ae59b3..aa290dbe 100644 --- a/lib/rabbit/command/rabbit.rb +++ b/lib/rabbit/command/rabbit.rb @@ -63,8 +63,7 @@ def run(arguments) end end exit_code = application.run - application.windows.each(&:destroy) - application.unref + ::Rabbit.destroy_application exit_code.zero? end diff --git a/lib/rabbit/rabbit.rb b/lib/rabbit/rabbit.rb index d216dba6..fa0edc9c 100644 --- a/lib/rabbit/rabbit.rb +++ b/lib/rabbit/rabbit.rb @@ -37,6 +37,13 @@ def application [:non_unique, :handles_command_line]) end + def destroy_application + return if @@application.nil? + @@application.windows.each(&:destroy) + @@application.unref + @@application = nil + end + def logger @@logger ||= Logger.default end