don't use wxFileConfig to parse kdeglobals, it's not meant for such use. Fixes bug 939195

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@26899 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík
2004-04-21 13:33:31 +00:00
parent 1d1c3a9fda
commit 320c341a10

View File

@@ -75,7 +75,6 @@
#include "wx/tokenzr.h" #include "wx/tokenzr.h"
#include "wx/iconloc.h" #include "wx/iconloc.h"
#include "wx/filename.h" #include "wx/filename.h"
#include "wx/fileconf.h"
#include "wx/unix/mimetype.h" #include "wx/unix/mimetype.h"
@@ -1172,6 +1171,19 @@ void wxMimeTypesManagerImpl::GetKDEMimeInfo(const wxString& sExtraDir)
wxArrayString dirs; wxArrayString dirs;
wxArrayString icondirs; wxArrayString icondirs;
// FIXME: This code is heavily broken. There are three bugs in it:
// 1) it uses only KDEDIR, which is deprecated, instead of using
// list of paths from KDEDIRS and using KDEDIR only if KDEDIRS
// is not set
// 2) it doesn't look into ~/.kde/share/config/kdeglobals where
// user's settings are stored and thus *ignores* user's settings
// instead of respecting them
// 3) it "tries to guess KDEDIR" and "tries a few likely theme
// names", both of which is completely arbitrary; instead, the
// code should give up if KDEDIR(S) is not set and/or the icon
// theme cannot be determined, because it means that the user is
// not using KDE (and thus is not interested in KDE icons anyway)
// the variable $KDEDIR is set when KDE is running // the variable $KDEDIR is set when KDE is running
wxString kdedir = wxGetenv( wxT("KDEDIR") ); wxString kdedir = wxGetenv( wxT("KDEDIR") );
@@ -1184,21 +1196,23 @@ void wxMimeTypesManagerImpl::GetKDEMimeInfo(const wxString& sExtraDir)
configFile.AppendDir( wxT("config") ); configFile.AppendDir( wxT("config") );
configFile.SetName( wxT("kdeglobals") ); configFile.SetName( wxT("kdeglobals") );
if (configFile.FileExists()) wxTextFile config;
if (configFile.FileExists() && config.Open(configFile.GetFullPath()))
{ {
wxFileConfig config( wxEmptyString, wxEmptyString, configFile.GetFullPath() );
// $(KDEDIR)/share/config -> $(KDEDIR)/share // $(KDEDIR)/share/config -> $(KDEDIR)/share
configFile.RemoveDir( configFile.GetDirCount()-1 ); configFile.RemoveDir( configFile.GetDirCount()-1 );
// $(KDEDIR)/share/ -> $(KDEDIR)/share/icons // $(KDEDIR)/share/ -> $(KDEDIR)/share/icons
configFile.AppendDir( wxT("icons") ); configFile.AppendDir( wxT("icons") );
// Check for entry // Check for entry
config.SetPath( wxT("Icons") ); wxString theme(wxT("default.kde"));
wxString theme; size_t cnt = config.GetLineCount();
if (config.Read( wxT("Theme"), &theme )) for (size_t i = 0; i < cnt; i++)
configFile.AppendDir( theme ); {
else if (config[i].StartsWith(wxT("Theme="), &theme/*rest*/))
configFile.AppendDir( wxT("default.kde") ); break;
}
configFile.AppendDir(theme);
} }
else else
{ {