diff options
Diffstat (limited to 'migration')
-rw-r--r-- | migration/20180428_00-module-names.cpp | 64 | ||||
-rw-r--r-- | migration/CMakeLists.txt | 3 | ||||
-rw-r--r-- | migration/migration.cpp | 21 | ||||
-rw-r--r-- | migration/migration.hpp | 14 |
4 files changed, 55 insertions, 47 deletions
diff --git a/migration/20180428_00-module-names.cpp b/migration/20180428_00-module-names.cpp index 174ca7ee..0c59add9 100644 --- a/migration/20180428_00-module-names.cpp +++ b/migration/20180428_00-module-names.cpp @@ -12,6 +12,21 @@ struct module_names : migration using dylib_ptr = Modules::dylib_ptr; using dylib_list = Modules::dylib_list; + struct module_type { + QString name, def; + dylib_list const& list; + }; + + Modules m { OPENTRACK_BASE_PATH + OPENTRACK_LIBRARY_PATH }; + + module_type types[3] { + { "tracker-dll", "pt", m.trackers() }, + { "protocol-dll", "freetrack", m.protocols() }, + { "filter-dll", "accela", m.filters() }, + }; + + bundle b { make_bundle("modules") }; + QString unique_date() const override { return "20180428_00"; @@ -24,46 +39,39 @@ struct module_names : migration bool should_run() const override { - return true; - } - - void run() override - { - struct module_type { - QString name, def; - dylib_list const& list; - }; + for (const module_type& type : types) + { + if (!b->contains(type.name)) + continue; - Modules m { OPENTRACK_BASE_PATH + OPENTRACK_LIBRARY_PATH }; + const QString value = b->get_variant(type.name).value<QString>(); - module_type types[3] { - { "tracker-dll", "pt", m.trackers() }, - { "protocol-dll", "freetrack", m.protocols() }, - { "filter-dll", "accela", m.filters() }, - }; + for (const dylib_ptr& lib : type.list) + { + if (value == lib->name && value != lib->module_name) + return true; + } + } - bundle b = make_bundle("modules"); + return false; + } + void run() override + { for (module_type& type : types) { - QByteArray n = type.name.toUtf8(); - if (!b->contains(type.name)) - { - qDebug() << n.constData() << "=>" << "EMPTY"; - b->store_kv(type.name, type.def); continue; - } - QString value = b->get_variant(type.name).value<QString>(); + const QString value = b->get_variant(type.name).value<QString>(); bool found = false; - for (dylib_ptr lib : type.list) + for (const dylib_ptr& lib : type.list) { - if (value == lib->name) + if (value == lib->name && value != lib->module_name) { - qDebug() << n.constData() << "=>" << lib->module_name; + qDebug() << type.name << value << "=>" << lib->module_name; b->store_kv(type.name, lib->module_name); found = true; break; @@ -72,8 +80,8 @@ struct module_names : migration if (!found) { - qDebug() << n.constData() << "=>" << "not found" << value; - b->store_kv(type.name, type.def); + qDebug() << type.name << value << "not found"; + b->store_kv(type.name, QVariant()); } } diff --git a/migration/CMakeLists.txt b/migration/CMakeLists.txt index 9a7f7dc9..b2dfac6d 100644 --- a/migration/CMakeLists.txt +++ b/migration/CMakeLists.txt @@ -1,2 +1,5 @@ otr_module(migration BIN) target_link_libraries(opentrack-migration opentrack-logic opentrack-spline) +if(CMAKE_COMPILER_IS_CLANGXX) + target_compile_options(${self} PRIVATE -Wno-weak-vtables) +endif() diff --git a/migration/migration.cpp b/migration/migration.cpp index 45965bee..d4ec6493 100644 --- a/migration/migration.cpp +++ b/migration/migration.cpp @@ -24,9 +24,7 @@ using namespace options::globals; // individual migrations are run in the UI thread. they can be interactive if necessary. -namespace migrations { - -namespace detail { +namespace migrations::detail { static std::vector<mptr> migration_list; static std::vector<mfun> migration_thunks; @@ -174,29 +172,34 @@ std::vector<QString> migrator::run() done.push_back(m->name()); } } - mark_config_as_not_needing_migration(); + mark_profile_as_not_needing_migration(); }); return done; } -} +} // ns migrations::detail + +namespace migrations { + +migration::migration() = default; +migration::~migration() = default; -} // ns +} // ns migrations std::vector<QString> run_migrations() { return migrations::detail::migrator::run(); } -void mark_config_as_not_needing_migration() +void mark_profile_as_not_needing_migration() { using m = migrations::detail::migrator; - m::mark_config_as_not_needing_migration(); + m::mark_profile_as_not_needing_migration(); } -void migrations::detail::migrator::mark_config_as_not_needing_migration() +void migrations::detail::migrator::mark_profile_as_not_needing_migration() { set_last_migration_time(time_after_migrations()); } diff --git a/migration/migration.hpp b/migration/migration.hpp index 42c8bead..2c1fee5b 100644 --- a/migration/migration.hpp +++ b/migration/migration.hpp @@ -28,7 +28,7 @@ namespace detail { { static std::vector<QString> run(); static void add_migration_thunk(std::function<mptr()>& thunk); - static void mark_config_as_not_needing_migration(); + static void mark_profile_as_not_needing_migration(); private: static void sort_migrations(); @@ -71,26 +71,20 @@ namespace detail { #define OPENTRACK_MIGRATION(type) \ MIGRATE_EXPANDED1(type, MIGRATE_EXPAND1(__COUNTER__)) -#ifdef Q_CREATOR_RUN -# pragma clang diagnostic ignored "-Wweak-vtables" -#endif - struct migration { - migration() = default; + migration(); migration(const migration&) = delete; migration& operator=(const migration&) = delete; - inline virtual ~migration(); + virtual ~migration(); virtual QString unique_date() const = 0; virtual QString name() const = 0; virtual bool should_run() const = 0; virtual void run() = 0; }; -inline migration::~migration() {} - } // ns migrations OTR_MIGRATION_EXPORT std::vector<QString> run_migrations(); -OTR_MIGRATION_EXPORT void mark_config_as_not_needing_migration(); +OTR_MIGRATION_EXPORT void mark_profile_as_not_needing_migration(); |