Don't crash if WXPREFIX env. variable is set

Change wxGetInstallPrefix() to return a string instead of const
wxChar*. The latter was incorrectly obtained from a temporary string if
WXPREFIX was set. While it's possible to fix in a backward compatible
manner without changing the function's signature, it's not worth the
effort for something pretty obscure and used mostly internally.
This commit is contained in:
Václav Slavík 2020-10-05 16:44:23 +02:00
parent 40e5152cfc
commit 2388f5d33f
3 changed files with 5 additions and 3 deletions

View File

@ -105,6 +105,8 @@ Changes in behaviour not resulting in compilation errors
- wxFileDialog::GetPath() and wxFileDialog::GetFilename() now assert and return
an empty string if called on dialogs with the wxFD_MULTIPLE style.
- wxGetInstallPrefix() now returns wxString.
Changes in behaviour which may result in build errors
-----------------------------------------------------

View File

@ -162,7 +162,7 @@ WXDLLIMPEXP_BASE wxLinuxDistributionInfo wxGetLinuxDistributionInfo();
WXDLLIMPEXP_BASE wxString wxNow();
// Return path where wxWidgets is installed (mostly useful in Unices)
WXDLLIMPEXP_BASE const wxChar *wxGetInstallPrefix();
WXDLLIMPEXP_BASE wxString wxGetInstallPrefix();
// Return path to wxWin data (/usr/share/wx/%{version}) (Unices)
WXDLLIMPEXP_BASE wxString wxGetDataDir();

View File

@ -182,12 +182,12 @@ void wxUsleep(unsigned long milliseconds)
}
#endif
const wxChar *wxGetInstallPrefix()
wxString wxGetInstallPrefix()
{
wxString prefix;
if ( wxGetEnv(wxT("WXPREFIX"), &prefix) )
return prefix.c_str();
return prefix;
#ifdef wxINSTALL_PREFIX
return wxT(wxINSTALL_PREFIX);