Author Topic: Standard conforms config- and userdata-paths - Patch(es) to test  (Read 10402 times)

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Standard conforms config- and userdata-paths - Patch(es) to test
« Reply #15 on: February 01, 2015, 06:43:18 pm »
Why do you think this will make a difference and make it less risky and error prone?  ;D
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Standard conforms config- and userdata-paths - Patch(es) to test
« Reply #16 on: February 01, 2015, 06:44:34 pm »
Isn't a hand-rolled implementation as simple as:

Code
wxString XDGUserData()
{
    wxString data_home;
    if (wxGetEnv(wxT("XDG_DATA_HOME"), data_home))
        return wxFileName(data_home, wxT("codeblocks")).GetFullPath();
    else
        return wxFileName(wxFileName::GetHomeDir(),wxT(".local/share/codeblocks")).GetFullPath();
}

wxString XDGUserConfig()
{
    wxString config_home;
    if (wxGetEnv(wxT("XDG_CONFIG_HOME"), config_home))
        return wxFileName(config_home, wxT("codeblocks")).GetFullPath();
    else
        return wxFileName(wxFileName::GetHomeDir(),wxT(".config/codeblocks")).GetFullPath();
}

Also, why in line 1475 of the unpatched code are we setting home_folder to the config dir?

Code
void ConfigManager::InitPaths()
{
    ConfigManager::config_folder = ConfigManager::GetUserDataFolder();
    ConfigManager::home_folder = wxStandardPathsBase::Get().GetUserConfigDir();

What is home_folder supposed to mean? I guess it's not used anywhere but still...

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Standard conforms config- and userdata-paths - Patch(es) to test
« Reply #17 on: February 01, 2015, 08:14:01 pm »
Also, why in line 1475 of the unpatched code are we setting home_folder to the config dir?

Code
void ConfigManager::InitPaths()
{
    ConfigManager::config_folder = ConfigManager::GetUserDataFolder();
    ConfigManager::home_folder = wxStandardPathsBase::Get().GetUserConfigDir();

What is home_folder supposed to mean? I guess it's not used anywhere but still...
It's only used on windows in crashhandler.cpp in CrashHandlerSaveEditorFiles().
wxGTK already depends on glib, so it is not really a new dependency.
From the point of view of C::B it is abstracted away. If you want to go with the glib dependency, you'll have to change the spec file and probably the debian files.
Yes , I forgot these files. Even if it works, because glib2-devel is in the dependency-chain of wxGTK-devel (at least on Fedora), but this is , of course, not guaranteed.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Standard conforms config- and userdata-paths - Patch(es) to test
« Reply #18 on: February 02, 2015, 01:12:23 am »
Just tried it on my home dev machine, where I have symlinks in the .codeblocks folder.
It seems that it copies them as is, thus if there are relative symlinks then they are invalid after the copy, absolute symlinks work are not broken.
So everything works as expected.
I have no hard links so I don't know what happens with them.  8)

The way to fix old version compatibility is to create two symlinks:
Code
ln -s ~/.config/codeblocks ~/.codeblocks
mkdir ~/.codeblocks/share
ln -s ~/.local/share/codeblocks ~/.codeblocks/share/codeblocks

p.s. probably the dialog message should be changed to something more formal and to remove the 'I' from it:)
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Standard conforms config- and userdata-paths - Patch(es) to test
« Reply #19 on: February 02, 2015, 02:57:57 pm »
Hard links work (as far as I know they use the same inode and so they are neither relative or absolute), relative softlinks do not work.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Standard conforms config- and userdata-paths - Patch(es) to test
« Reply #20 on: February 02, 2015, 05:56:25 pm »
Please test and give feedback, especially tests on Mac would be fine, because the the portable stuff has slightly changed: if the main config-file is found besides the executable, the user-data folder should always be there and not in the global-data-folder.
OK, so I've ran it some days now (Jens: The all-in-one-patch worked flawlessly) and so far I see no issues on Windows. Even better: The not portable files like dragscroll and the spellchecker stuff are now truly portable and work.

For the glib dependency: It was said already that wxGTK depends on it anyways... but besides to give my 2 cents: I thinks its not a big deal in this case because glib is not a "special" lib a user needs to install, its just there. At least that what I know from my (limited) Linux experience. If you take me as Linux "DAU" it works about of the box for the distros I use, so I am fine with it.

I see no issues applying it to trunk, therefore... for Windows... for Linux I let the hardcore Linuxer decide. But please think pragmatic... ;-)
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Standard conforms config- and userdata-paths - Patch(es) to test
« Reply #21 on: February 08, 2015, 02:00:51 am »
I just committed the changes with a slightly modified dialog-text.
I committed it with the glib2-depenency as glib2 is a dependency of wxWidgets and gtk2/3 itself and is installed on each linux-system, that runs C::B anyway.

"Reinventing the wheel" might sometimes make sense for time-critical functions (in fact it does not in many/most cases), but not here.
And using libraries should be in general less error-prone and easier to maintain, then to add new (linux only) functions to our sources.