From 6e3f8e61a92beb6cea2243f609ac1448578aee67 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 10 Apr 2010 18:13:34 +0000 Subject: [PATCH] Don't crash if wxMimeTypesManager is used before wxApp creation. This is arguably not a supported use case but this apparently used to work before and so it's probably not a good idea to break it now. Closes #11927. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63935 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/unix/mimetype.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/unix/mimetype.cpp b/src/unix/mimetype.cpp index 05426d667a..caa9459875 100644 --- a/src/unix/mimetype.cpp +++ b/src/unix/mimetype.cpp @@ -507,14 +507,19 @@ void wxMimeTypesManagerImpl::InitIfNeeded() // set the flag first to prevent recursion m_initialized = true; - wxString wm = wxTheApp->GetTraits()->GetDesktopEnvironment(); + int mailcapStyles = wxMAILCAP_ALL; + if ( wxAppTraits * const traits = wxApp::GetTraitsIfExists() ) + { + wxString wm = traits->GetDesktopEnvironment(); - if (wm == wxT("KDE")) - Initialize( wxMAILCAP_KDE ); - else if (wm == wxT("GNOME")) - Initialize( wxMAILCAP_GNOME ); - else - Initialize(); + if ( wm == "KDE" ) + mailcapStyles = wxMAILCAP_KDE; + else if ( wm == "GNOME" ) + mailcapStyles = wxMAILCAP_GNOME; + //else: unknown, use the default + } + + Initialize(mailcapStyles); } } -- 2.45.2