summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2015-03-23 18:31:55 +0100
committerRobin Gareus <robin@gareus.org>2015-03-23 18:31:55 +0100
commit53ac99a26ad5e16406dd203445d578ded913f6a9 (patch)
treedee97a659f55b2fec4f875d2144781ea752ef313 /libs
parenta09e942eeca9c0b2be808ee9492808fe7b377577 (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)
Diffstat (limited to 'libs')
-rw-r--r--libs/ardour/ardour/ardour.h3
-rw-r--r--libs/ardour/globals.cc37
2 files changed, 30 insertions, 10 deletions
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;
}