take popup option names by const reference, not by pointer

POPUP_OPTION copies the name it is given -- `this->name = *newName` into a
std::wstring member -- but its constructor took a std::wstring*, so 64 call
sites spelled the argument `&std::wstring( pStr )`. Taking the address of a
temporary is ill-formed, and clang refuses it outright:

    error: taking the address of a temporary object of type 'std::wstring'

It happens to work under MSVC because the temporary outlives the call, dying
at the end of the full expression rather than before the copy. Nothing was
corrupt; the code was just spelling "pass me a string" in a way the language
does not allow.

A const reference says what these functions actually want, so the call sites
lose the &, and the two places that allocated a string purely to have an
address to pass -- POPUP_SUB_POPUP_OPTION's default constructor, which carried
a "TODO: possible memmory leak!" saying as much, and a "Dummy generator"
option -- stop leaking one.

Converted: POPUP_OPTION's constructor and setName, POPUP::addOption and
addSubMenuOption, and both POPUP_SUB_POPUP_OPTION constructors. The popupDef
family in popup_definition.* keeps its std::wstring* because it owns what it
is handed and stores the pointer; that is a different design and a different
change. The three calls it makes into the converted API now dereference.

Verification:
    grep -rn '&std::wstring' --include=*.cpp --include=*.h .   # nothing
    ninja -C build parse             # no popup_* or SkillMenu sites remain
    ninja -C build -k 0              # Release, four applications, green
    ninja -C build-debug -k 0        # Debug, four applications, green

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Marco Antonio J. Costa
2026-07-23 19:29:55 -03:00
committed by majcosta
co-authored by Claude Opus 4.8
parent 83b637aa73
commit 5e2982c509
7 changed files with 96 additions and 96 deletions
@@ -5563,7 +5563,7 @@ void CreateMapInventoryFilterMenu( )
swprintf( pStr, gzMapInventoryFilterOptions[ 0 ] );
// Add option: "SHOW ALL"
uiFlags = IC_MAPFILTER_ALL;
pOption = new POPUP_OPTION(&std::wstring( pStr ), new popupCallbackFunction<void,UINT32>( &MapInventoryFilterMenuPopup_FilterSet, uiFlags ) );
pOption = new POPUP_OPTION(std::wstring( pStr ), new popupCallbackFunction<void,UINT32>( &MapInventoryFilterMenuPopup_FilterSet, uiFlags ) );
if (guiMapInventoryFilter == IC_MAPFILTER_ALL)
{
// Set this option off.
@@ -5583,7 +5583,7 @@ void CreateMapInventoryFilterMenu( )
swprintf( pStr, gzMapInventoryFilterOptions[ 1 ] );
}
uiFlags = IC_MAPFILTER_GUN;
pOption = new POPUP_OPTION(&std::wstring( pStr ), new popupCallbackFunction<void,UINT32>( &MapInventoryFilterMenuPopup_FilterToggle, uiFlags ) );
pOption = new POPUP_OPTION(std::wstring( pStr ), new popupCallbackFunction<void,UINT32>( &MapInventoryFilterMenuPopup_FilterToggle, uiFlags ) );
gMapInventoryFilterPopup->addOption( *pOption );
if (guiMapInventoryFilter & IC_MAPFILTER_AMMO)
@@ -5597,7 +5597,7 @@ void CreateMapInventoryFilterMenu( )
swprintf( pStr, gzMapInventoryFilterOptions[ 2 ] );
}
uiFlags = IC_MAPFILTER_AMMO;
pOption = new POPUP_OPTION(&std::wstring( pStr ), new popupCallbackFunction<void,UINT32>( &MapInventoryFilterMenuPopup_FilterToggle, uiFlags ) );
pOption = new POPUP_OPTION(std::wstring( pStr ), new popupCallbackFunction<void,UINT32>( &MapInventoryFilterMenuPopup_FilterToggle, uiFlags ) );
gMapInventoryFilterPopup->addOption( *pOption );
if (guiMapInventoryFilter & IC_MAPFILTER_EXPLOSV)
@@ -5611,7 +5611,7 @@ void CreateMapInventoryFilterMenu( )
swprintf( pStr, gzMapInventoryFilterOptions[ 3 ] );
}
uiFlags = IC_MAPFILTER_EXPLOSV;
pOption = new POPUP_OPTION(&std::wstring( pStr ), new popupCallbackFunction<void,UINT32>( &MapInventoryFilterMenuPopup_FilterToggle, uiFlags ) );
pOption = new POPUP_OPTION(std::wstring( pStr ), new popupCallbackFunction<void,UINT32>( &MapInventoryFilterMenuPopup_FilterToggle, uiFlags ) );
gMapInventoryFilterPopup->addOption( *pOption );
if (guiMapInventoryFilter & IC_MAPFILTER_MELEE)
@@ -5625,7 +5625,7 @@ void CreateMapInventoryFilterMenu( )
swprintf( pStr, gzMapInventoryFilterOptions[ 4 ] );
}
uiFlags = IC_MAPFILTER_MELEE;
pOption = new POPUP_OPTION(&std::wstring( pStr ), new popupCallbackFunction<void,UINT32>( &MapInventoryFilterMenuPopup_FilterToggle, uiFlags ) );
pOption = new POPUP_OPTION(std::wstring( pStr ), new popupCallbackFunction<void,UINT32>( &MapInventoryFilterMenuPopup_FilterToggle, uiFlags ) );
gMapInventoryFilterPopup->addOption( *pOption );
if (guiMapInventoryFilter & IC_MAPFILTER_ARMOR)
@@ -5639,7 +5639,7 @@ void CreateMapInventoryFilterMenu( )
swprintf( pStr, gzMapInventoryFilterOptions[ 5 ] );
}
uiFlags = IC_MAPFILTER_ARMOR;
pOption = new POPUP_OPTION(&std::wstring( pStr ), new popupCallbackFunction<void,UINT32>( &MapInventoryFilterMenuPopup_FilterToggle, uiFlags ) );
pOption = new POPUP_OPTION(std::wstring( pStr ), new popupCallbackFunction<void,UINT32>( &MapInventoryFilterMenuPopup_FilterToggle, uiFlags ) );
gMapInventoryFilterPopup->addOption( *pOption );
if (guiMapInventoryFilter & IC_MAPFILTER_LBE)
@@ -5653,7 +5653,7 @@ void CreateMapInventoryFilterMenu( )
swprintf( pStr, gzMapInventoryFilterOptions[ 6 ] );
}
uiFlags = IC_MAPFILTER_LBE;
pOption = new POPUP_OPTION(&std::wstring( pStr ), new popupCallbackFunction<void,UINT32>( &MapInventoryFilterMenuPopup_FilterToggle, uiFlags ) );
pOption = new POPUP_OPTION(std::wstring( pStr ), new popupCallbackFunction<void,UINT32>( &MapInventoryFilterMenuPopup_FilterToggle, uiFlags ) );
gMapInventoryFilterPopup->addOption( *pOption );
if (guiMapInventoryFilter & IC_MAPFILTER_KIT)
@@ -5667,7 +5667,7 @@ void CreateMapInventoryFilterMenu( )
swprintf( pStr, gzMapInventoryFilterOptions[ 7 ] );
}
uiFlags = IC_MAPFILTER_KIT;
pOption = new POPUP_OPTION(&std::wstring( pStr ), new popupCallbackFunction<void,UINT32>( &MapInventoryFilterMenuPopup_FilterToggle, uiFlags ) );
pOption = new POPUP_OPTION(std::wstring( pStr ), new popupCallbackFunction<void,UINT32>( &MapInventoryFilterMenuPopup_FilterToggle, uiFlags ) );
gMapInventoryFilterPopup->addOption( *pOption );
if (guiMapInventoryFilter & IC_MAPFILTER_MISC)
@@ -5681,13 +5681,13 @@ void CreateMapInventoryFilterMenu( )
swprintf( pStr, gzMapInventoryFilterOptions[ 8 ] );
}
uiFlags = IC_MAPFILTER_MISC;
pOption = new POPUP_OPTION(&std::wstring( pStr ), new popupCallbackFunction<void,UINT32>( &MapInventoryFilterMenuPopup_FilterToggle, uiFlags ) );
pOption = new POPUP_OPTION(std::wstring( pStr ), new popupCallbackFunction<void,UINT32>( &MapInventoryFilterMenuPopup_FilterToggle, uiFlags ) );
gMapInventoryFilterPopup->addOption( *pOption );
swprintf( pStr, gzMapInventoryFilterOptions[ 9 ] );
// Add option: "HIDE ALL"
uiFlags = 0;
pOption = new POPUP_OPTION(&std::wstring( pStr ), new popupCallbackFunction<void,UINT32>( &MapInventoryFilterMenuPopup_FilterSet, uiFlags ) );
pOption = new POPUP_OPTION(std::wstring( pStr ), new popupCallbackFunction<void,UINT32>( &MapInventoryFilterMenuPopup_FilterSet, uiFlags ) );
if (guiMapInventoryFilter == 0)
{
// Set this option off.