Project

General

Profile

Bug #1868 » 0038-gtk4-Fix-sentried-unit-crash-on-right-click-on-city-.patch

S3_3, S3_2 - Marko Lindqvist, 01/05/2026 09:21 PM

View differences:

client/control.c
}
}
/**********************************************************************//**
Try to set unit to focus directly. Won't set unit to focus if
unit can't currently be at focus.
**************************************************************************/
void unit_focus_try(struct unit *punit)
{
if (punit->activity == ACTIVITY_IDLE) {
/* Only idle units can be at focus. */
unit_focus_set(punit);
}
}
/**********************************************************************//**
Sets the focus unit directly. The unit given will be given the
focus; if NULL the focus will be cleared.
client/control.h
void unit_focus_add(struct unit *punit);
void unit_focus_remove(struct unit *punit);
void unit_focus_urgent(struct unit *punit);
void unit_focus_try(struct unit *punit);
void unit_focus_advance(bool accept_current);
void unit_focus_update(void);
client/gui-gtk-4.0/citydlg.c
&& NULL != (pcity = tile_city(unit_tile(punit)))
&& NULL != (pdialog = get_city_dialog(pcity))
&& can_client_issue_orders()) {
unit_focus_set(punit);
unit_focus_try(punit);
close_city_dialog(pdialog);
}
......
&& NULL != (pcity = game_city_by_number(punit->homecity))
&& NULL != (pdialog = get_city_dialog(pcity))
&& can_client_issue_orders()) {
unit_focus_set(punit);
unit_focus_try(punit);
close_city_dialog(pdialog);
}
......
if (NULL != punit
&& can_client_issue_orders()) {
unit_focus_set(punit);
unit_focus_try(punit);
}
return TRUE;
......
player_unit_by_number(client_player(), GPOINTER_TO_INT(data));
if (NULL != punit) {
unit_focus_set(punit);
/* FIXME: If unit is not idle to begin with, we can only request
* idling, and as we have no server reply yet,
* the unit_focus_try() below will fail. */
request_new_unit_activity(punit, ACTIVITY_IDLE);
unit_focus_try(punit);
}
close_citydlg_unit_popover(g_object_get_data(G_OBJECT(action), "dlg"));
......
struct city *pcity =
player_city_by_number(client_player(), punit->homecity);
unit_focus_set(punit);
/* FIXME: If unit is not idle to begin with, we can only request
* idling, and as we have no server reply yet,
* the unit_focus_try() below will fail. */
request_new_unit_activity(punit, ACTIVITY_IDLE);
unit_focus_try(punit);
if (NULL != pcity) {
struct city_dialog *pdialog = get_city_dialog(pcity);
......
if (NULL != punit) {
struct city *pcity = tile_city(unit_tile(punit));
unit_focus_set(punit);
/* FIXME: If unit is not idle to begin with, we can only request
* idling, and as we have no server reply yet,
* the unit_focus_try() below will fail. */
request_new_unit_activity(punit, ACTIVITY_IDLE);
unit_focus_try(punit);
if (NULL != pcity) {
struct city_dialog *pdialog = get_city_dialog(pcity);
client/gui-gtk-4.0/unitselect.c
punit = player_unit_by_number(client_player(), uid);
if (punit && unit_owner(punit) == client_player()) {
unit_focus_set(punit);
/* FIXME: If unit is not idle to begin with, we can only request
* idling, and as we have no server reply yet,
* the unit_focus_try() below will fail. */
request_new_unit_activity(punit, ACTIVITY_IDLE);
unit_focus_try(punit);
usdlg_destroy();
}
}
(2-2/2)