diff options
author | Robin Gareus <robin@gareus.org> | 2015-03-23 18:31:55 +0100 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2015-03-23 18:31:55 +0100 |
commit | 53ac99a26ad5e16406dd203445d578ded913f6a9 (patch) | |
tree | dee97a659f55b2fec4f875d2144781ea752ef313 | |
parent | a09e942eeca9c0b2be808ee9492808fe7b377577 (diff) |
rework check for old configuration files
check early on (before announcement-check, bundle-
env and ARDOUR_UI ctor have a chance to create the
new config dir)
-rw-r--r-- | gtk2_ardour/ardour_ui.cc | 2 | ||||
-rw-r--r-- | gtk2_ardour/bundle_env_linux.cc | 1 | ||||
-rw-r--r-- | gtk2_ardour/main.cc | 2 | ||||
-rw-r--r-- | libs/ardour/ardour/ardour.h | 3 | ||||
-rw-r--r-- | libs/ardour/globals.cc | 37 |
5 files changed, 33 insertions, 12 deletions
diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc index 0c73609f3c..443bba7057 100644 --- a/gtk2_ardour/ardour_ui.cc +++ b/gtk2_ardour/ardour_ui.cc @@ -238,7 +238,7 @@ ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[], const char* localedir) { Gtkmm2ext::init(localedir); - if (ARDOUR::check_for_old_configuration_files (boost::bind (ask_about_configuration_copy, _1, _2, _3))) { + if (ARDOUR::handle_old_configuration_files (boost::bind (ask_about_configuration_copy, _1, _2, _3))) { MessageDialog msg (string_compose (_("Your configuration files were copied. You can now restart %1."), PROGRAM_NAME), true); msg.run (); /* configuration was modified, exit immediately */ diff --git a/gtk2_ardour/bundle_env_linux.cc b/gtk2_ardour/bundle_env_linux.cc index a7027506fe..54404b14fb 100644 --- a/gtk2_ardour/bundle_env_linux.cc +++ b/gtk2_ardour/bundle_env_linux.cc @@ -60,7 +60,6 @@ fixup_bundle_environment (int /*argc*/, char* argv[], const char** localedir) std::string path; std::string dir_path = Glib::path_get_dirname (Glib::path_get_dirname (argv[0])); - std::string userconfigdir = user_config_directory(); #ifdef ENABLE_NLS if (!ARDOUR::translations_are_enabled ()) { diff --git a/gtk2_ardour/main.cc b/gtk2_ardour/main.cc index 998337ed09..42f94522c2 100644 --- a/gtk2_ardour/main.cc +++ b/gtk2_ardour/main.cc @@ -251,6 +251,8 @@ int ardour_main (int argc, char *argv[]) int main (int argc, char *argv[]) #endif { + ARDOUR::check_for_old_configuration_files(); + fixup_bundle_environment (argc, argv, &localedir); load_custom_fonts(); /* needs to happen before any gtk and pango init calls */ diff --git a/libs/ardour/ardour/ardour.h b/libs/ardour/ardour/ardour.h index 3865ce6ece..8be99a4aba 100644 --- a/libs/ardour/ardour/ardour.h +++ b/libs/ardour/ardour/ardour.h @@ -88,7 +88,8 @@ namespace ARDOUR { * action, and return true or false depending on whether or not the * copy should take place. */ - LIBARDOUR_API int check_for_old_configuration_files (boost::function<bool (std::string const&, std::string const&, int)> ui_handler); + LIBARDOUR_API void check_for_old_configuration_files (); + LIBARDOUR_API int handle_old_configuration_files (boost::function<bool (std::string const&, std::string const&, int)> ui_handler); } #endif /* __ardour_ardour_h__ */ diff --git a/libs/ardour/globals.cc b/libs/ardour/globals.cc index f097ce84f5..6e16d5480f 100644 --- a/libs/ardour/globals.cc +++ b/libs/ardour/globals.cc @@ -138,6 +138,8 @@ PBD::Signal1<void,int> ARDOUR::PluginScanTimeout; PBD::Signal0<void> ARDOUR::GUIIdle; PBD::Signal3<bool,std::string,std::string,int> ARDOUR::CopyConfigurationFiles; +static bool have_old_configuration_files = false; + namespace ARDOUR { extern void setup_enum_writer (); } @@ -263,6 +265,11 @@ copy_configuration_files (string const & old_dir, string const & new_dir, int ol copy_file (old_name, new_name); + old_name = Glib::build_filename (old_dir, X_("sfdb")); + new_name = Glib::build_filename (new_dir, X_("sfdb")); + + copy_file (old_name, new_name); + /* can only copy ardour.rc - UI config is not compatible */ old_name = Glib::build_filename (old_dir, X_("ardour.rc")); @@ -314,31 +321,43 @@ copy_configuration_files (string const & old_dir, string const & new_dir, int ol return 0; } -int -ARDOUR::check_for_old_configuration_files (boost::function<bool (std::string const&, std::string const&, int)> ui_handler) +void +ARDOUR::check_for_old_configuration_files () { int current_version = atoi (X_(PROGRAM_VERSION)); if (current_version <= 1) { - return 0; + return; } int old_version = current_version - 1; string old_config_dir = user_config_directory (old_version); /* pass in the current version explicitly to avoid creation */ - string current_config_dir = user_config_directory (current_version); + string current_config_dir = user_config_directory (current_version); if (!Glib::file_test (current_config_dir, Glib::FILE_TEST_IS_DIR)) { if (Glib::file_test (old_config_dir, Glib::FILE_TEST_IS_DIR)) { - - if (ui_handler (old_config_dir, current_config_dir, old_version)) { - copy_configuration_files (old_config_dir, current_config_dir, old_version); - return 1; - } + have_old_configuration_files = true; } } +} +int +ARDOUR::handle_old_configuration_files (boost::function<bool (std::string const&, std::string const&, int)> ui_handler) +{ + if (have_old_configuration_files) { + int current_version = atoi (X_(PROGRAM_VERSION)); + assert (current_version > 1); // established in check_for_old_configuration_files () + int old_version = current_version - 1; + string old_config_dir = user_config_directory (old_version); + string current_config_dir = user_config_directory (current_version); + + if (ui_handler (old_config_dir, current_config_dir, old_version)) { + copy_configuration_files (old_config_dir, current_config_dir, old_version); + return 1; + } + } return 0; } |