SF.net SVN: mahogany:[7578] trunk/M/src/classes/MApplication.cpp
[email protected] Fri, 04 Dec 2009 02:18:54 +0000
| Newsgroups | gmane.mail.mahogany.cvs |
|---|---|
| Message-ID | <[email protected]> |
Revision: 7578
http://mahogany.svn.sourceforge.net/mahogany/?rev=7578&view=rev
Author: vadz
Date: 2009-12-04 02:18:52 +0000 (Fri, 04 Dec 2009)
Log Message:
-----------
Fix bug with determination of user data directory in Unicode build under MSW.
Not only all this code explicitly calling SHGetSpecialFolderPathA() was
useless but it was also buggy in Unicode build, just use wxStandardPaths
instead.
Modified Paths:
--------------
trunk/M/src/classes/MApplication.cpp
Modified: trunk/M/src/classes/MApplication.cpp
===================================================================
--- trunk/M/src/classes/MApplication.cpp 2009-12-01 17:07:26 UTC (rev 7577)
+++ trunk/M/src/classes/MApplication.cpp 2009-12-04 02:18:52 UTC (rev 7578)
@@ -58,6 +58,7 @@
#include <wx/mimetype.h> // wxMimeTypesManager
#include <wx/confbase.h> // for wxConfigBase
+#include <wx/stdpaths.h>
#include "wx/persctrl.h" // for wxPControls::SetSettingsPath
@@ -66,10 +67,6 @@
#endif // OS_MAC
#ifdef OS_WIN
- #include <shlobj.h>
- #include <wx/msw/winundef.h>
-
- #include <wx/dynlib.h>
#ifdef __WINE__
// it includes wrapwin.h which includes windows.h which defines SendMessage under Windows
#undef SendMessage
@@ -989,53 +986,15 @@
// if still not given, try to find a good default one ourselves
if ( m_localDir.empty() )
{
-#ifdef OS_WIN
- // normally we store the user files under APPDATA directory which is
- // something like "C:\Documents and Settings\username\Application Data"
+ // for historical reasons, we use Mahogany for the base directory name
+ // under Windows but M under Unix, hence we can't use GetUserDataDir()
+ // which would use the same one under both systems
+ m_localDir = wxStandardPaths::Get().GetUserConfigDir();
- // suppress errors if shell32.dll can't be loaded or if it doesn't have
- // SHGetSpecialFolderPath (as is the case on Windows 95)
- {
- wxLogNull noLog;
-
- wxDynamicLibrary dllShell32(_T("shell32.dll"));
- if ( dllShell32.IsLoaded() )
- {
- typedef BOOL
- (WINAPI *SHGetSpecialFolderPathA_t)(HWND, LPTSTR, int, BOOL);
-
- wxDYNLIB_FUNCTION(SHGetSpecialFolderPathA_t,
- SHGetSpecialFolderPathA,
- dllShell32);
-
- if ( pfnSHGetSpecialFolderPathA )
- {
- String pathAppData;
- if ( pfnSHGetSpecialFolderPathA
- (
- NULL, // owner hwnd
- wxStringBuffer(pathAppData, MAX_PATH), // [out] buffer
- CSIDL_APPDATA, // which to get
- FALSE // don't create
- ) )
- {
- m_localDir = pathAppData + _T("\\Mahogany");
- }
- }
- }
- }
-
- // but if we couldn't determine APPDATA directory...
- if ( m_localDir.empty() )
- {
- // ... store the files in the program directory itself and in this
- // case use the users name in the subdirectory part to still try to
- // make it possible for several users to use the same installation
- m_localDir = wxGetHomeDir() + _T('\\') + wxGetUserName();
- }
-
+#ifdef OS_WIN
+ m_localDir += "\\Mahogany";
#elif defined(OS_UNIX)
- m_localDir = wxGetHomeDir() + _T("/.M");
+ m_localDir += "/.M";
#else
#error "Don't know where to put per-user Mahogany files on this system"
#endif // OS_WIN
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
------------------------------------------------------------------------------
Join us December 9, 2009 for the Red Hat Virtual Experience,
a free event focused on virtualization and cloud computing.
Attend in-depth sessions from your desk. Your couch. Anywhere.
http://p.sf.net/sfu/redhat-sfdev2dev