From 2ff1e633e9e157e824e9a5aa0e069fe15e1cef77 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 30 Jan 2018 23:01:39 +0100 Subject: [PATCH] Use KDE 4 and 5 directories in Unix wxMimeTypesManager too KDE 3 is throughly outdated, but keep support for it too because it doesn't cost much. Closes #16704. --- src/unix/mimetype.cpp | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/unix/mimetype.cpp b/src/unix/mimetype.cpp index 50a555f45e..d09a814873 100644 --- a/src/unix/mimetype.cpp +++ b/src/unix/mimetype.cpp @@ -520,10 +520,13 @@ void wxMimeTypesManagerImpl::InitIfNeeded() } -static void AppendToPathIfExists(wxString& pathvar, const wxString& dir) +static bool AppendToPathIfExists(wxString& pathvar, const wxString& dir) { - if ( wxFileName::DirExists(dir) ) - pathvar << ":" << dir; + if ( !wxFileName::DirExists(dir) ) + return false; + + pathvar << ":" << dir; + return true; } // read system and user mailcaps and other files @@ -560,8 +563,17 @@ void wxMimeTypesManagerImpl::Initialize(int mailcapStyles, if ( mailcapStyles & wxMAILCAP_KDE ) { - AppendToPathIfExists(xdgDataDirs, "/usr/share/kde3"); - AppendToPathIfExists(xdgDataDirs, "/opt/kde3/share"); + for ( int kdeVer = 5; kdeVer >= 3; kdeVer-- ) + { + const wxString& kdeDir = wxString::Format("kde%d", kdeVer); + if ( AppendToPathIfExists(xdgDataDirs, "/usr/share/" + kdeDir) + || AppendToPathIfExists(xdgDataDirs, "/opt/" + kdeDir + "/share") ) + { + // We don't need to use earlier versions if we found a + // later one. + break; + } + } } } if ( !sExtraDir.empty() )