handle XOpenDisplay() failure in GetSM(); reformatted the code
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@42733 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -293,46 +293,52 @@ wxPortId wxGUIAppTraits::GetToolkitVersion(int *verMaj, int *verMin) const
|
|||||||
#if wxUSE_DETECT_SM
|
#if wxUSE_DETECT_SM
|
||||||
static wxString GetSM()
|
static wxString GetSM()
|
||||||
{
|
{
|
||||||
Display *dpy;
|
class Dpy
|
||||||
SmcConn smc_conn;
|
|
||||||
char *vendor;
|
|
||||||
char *client_id_ret;
|
|
||||||
dpy = XOpenDisplay(NULL);
|
|
||||||
|
|
||||||
smc_conn = SmcOpenConnection(NULL, NULL,
|
|
||||||
999, 999,
|
|
||||||
0 /* mask */, NULL /* callbacks */,
|
|
||||||
NULL, &client_id_ret, 0, NULL);
|
|
||||||
|
|
||||||
if (smc_conn)
|
|
||||||
{
|
{
|
||||||
vendor = SmcVendor(smc_conn);
|
public:
|
||||||
wxString ret = wxString::FromAscii( vendor );
|
Dpy() { m_dpy = XOpenDisplay(NULL); }
|
||||||
free(vendor);
|
~Dpy() { if ( m_dpy ) XCloseDisplay(m_dpy); }
|
||||||
|
|
||||||
SmcCloseConnection(smc_conn, 0, NULL);
|
operator Display *() const { return m_dpy; }
|
||||||
free(client_id_ret);
|
private:
|
||||||
|
Display *m_dpy;
|
||||||
|
} dpy;
|
||||||
|
|
||||||
XCloseDisplay(dpy);
|
if ( !dpy )
|
||||||
|
return wxEmptyString;
|
||||||
return ret;
|
|
||||||
}
|
char *client_id;
|
||||||
|
SmcConn smc_conn = SmcOpenConnection(NULL, NULL,
|
||||||
return wxEmptyString;
|
999, 999,
|
||||||
|
0 /* mask */, NULL /* callbacks */,
|
||||||
|
NULL, &client_id,
|
||||||
|
0, NULL);
|
||||||
|
|
||||||
|
if ( !smc_conn )
|
||||||
|
return wxEmptyString;
|
||||||
|
|
||||||
|
char *vendor = SmcVendor(smc_conn);
|
||||||
|
wxString ret = wxString::FromAscii( vendor );
|
||||||
|
free(vendor);
|
||||||
|
|
||||||
|
SmcCloseConnection(smc_conn, 0, NULL);
|
||||||
|
free(client_id);
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
#endif
|
#endif // wxUSE_DETECT_SM
|
||||||
|
|
||||||
wxString wxGUIAppTraits::GetDesktopEnvironment() const
|
wxString wxGUIAppTraits::GetDesktopEnvironment() const
|
||||||
{
|
{
|
||||||
#if wxUSE_DETECT_SM
|
#if wxUSE_DETECT_SM
|
||||||
wxString SM = GetSM();
|
const wxString SM = GetSM();
|
||||||
|
|
||||||
if (SM == wxT("GnomeSM"))
|
if (SM == wxT("GnomeSM"))
|
||||||
return wxT("GNOME");
|
return wxT("GNOME");
|
||||||
|
|
||||||
if (SM == wxT("KDE"))
|
if (SM == wxT("KDE"))
|
||||||
return wxT("KDE");
|
return wxT("KDE");
|
||||||
#endif
|
#endif // wxUSE_DETECT_SM
|
||||||
|
|
||||||
return wxEmptyString;
|
return wxEmptyString;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user