From 2c040abe480e1a6da149deb8f6c59b639a7267ce Mon Sep 17 00:00:00 2001
From: Marko Lindqvist <cazfi74@gmail.com>
Date: Wed, 7 Jan 2026 01:18:45 +0200
Subject: [PATCH 56/56] Qt: Fix flagless unit crash on action selection dialog

Reported by John Robertson

See RM #1865

Signed-off-by: Marko Lindqvist <cazfi74@gmail.com>
---
 client/gui-qt/dialogs.cpp | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)

diff --git a/client/gui-qt/dialogs.cpp b/client/gui-qt/dialogs.cpp
index f583a92088..85f2a82962 100644
--- a/client/gui-qt/dialogs.cpp
+++ b/client/gui-qt/dialogs.cpp
@@ -2077,12 +2077,23 @@ void popup_action_selection(struct unit *actor_unit,
              unit_name_translation(actor_unit),
              city_name_get(target_city));
   } else if (target_unit != nullptr) {
-    astr_set(&text,
-             // TRANS: Your Spy is ready to act against Roman Freight.
-             _("Your %s is ready to act against %s %s."),
-             unit_name_translation(actor_unit),
-             nation_adjective_for_player(unit_owner(target_unit)),
-             unit_name_translation(target_unit));
+    struct player *owner = unit_owner(target_unit);
+
+    if (owner != nullptr) {
+      astr_set(&text,
+               // TRANS: Your Spy is ready to act against Roman Freight.
+               _("Your %s is ready to act against %s %s."),
+               unit_name_translation(actor_unit),
+               nation_adjective_for_player(owner),
+               unit_name_translation(target_unit));
+    } else {
+      // Flagless target
+      astr_set(&text,
+               // TRANS: Your Spy is ready to act against Freight.
+               _("Your %s is ready to act against %s."),
+               unit_name_translation(actor_unit),
+               unit_name_translation(target_unit));
+    }
   } else {
     fc_assert_msg(target_unit != nullptr
                   || target_city != nullptr
-- 
2.51.0

