Opened 7 years ago

Last modified 7 years ago

#15220 confirmed defect

wxFileConfig uses inappropriate path in console applications under OSX

Reported by: ___matthieu___ Owned by:
Priority: low Milestone:
Component: wxOSX Version: stable-latest
Keywords: wxFileConfig simple Cc:
Blocked By: Blocking:
Patch: no



If I print the preferences path in a CLI tool (subclass of wxAppConsole), I get $HOME/appname Preferences.

while using the function call :

std::cout << wxConfig::GetLocalFileName("hugin") << std::endl;

As this is a non-GUI application, then the path should be $HOME/.appname


The problem was found while discussing an issue about accessing the same preference file from a GUI application and a CLI tool.

Here is an adaptated sample :

#include <iostream>
#include <wx/wx.h>
#include <wx/config.h>

class CLI1 : public wxAppConsole
    int OnRun();

int CLI1::OnRun()
    std::cout << wxConfig::GetLocalFileName(GetAppName()) << std::endl;
    std::cout << wxConfig::GetLocalFileName(GetAppName(), wxCONFIG_USE_SUBDIR) << std::endl;



The problem is present on MacOSX 10.8, with a 10.6 and 10.8 SDK and DEPLOYMENT_TARGET set to 10.6, with version 2.9.3 and the 2.9-svn codebase.

On version 2.8.12 the $HOME/Library/Preferences/appname Preferences file is accessed in either case


If it is a non-GUI application, then the path should be $HOME/.appname

Attachments (1)

cli1.cpp download (351 bytes) - added by ___matthieu___ 7 years ago.
original sample

Download all attachments as: .zip

Change History (2)

Changed 7 years ago by ___matthieu___

original sample

comment:1 Changed 7 years ago by vadz

  • Keywords simple added
  • Priority changed from normal to low
  • Status changed from new to confirmed
  • Summary changed from the wxFileConfig path is not consistent wether wxApp and wxAppConsole is used to wxFileConfig uses inappropriate path in console applications under OSX

We need to do something about AddConfFileExtIfNeeded() in source:wxWidgets/trunk/src/common/fileconf.cpp#L265 which currently always adds " Preferences" suffix under OS X. As it must behave differently in base and GUI applications, we need to virtualize it somehow. The simplest would probably be to add a new method to wxStandardPaths, even if it doesn't totally belong there. Or maybe wxAppTraits. E.g. wxAppTraits::GetUserConfigFileName()?

Note: See TracTickets for help on using tickets.