From 4334d55767b2d6c407049c18575e18d337198dae Mon Sep 17 00:00:00 2001 From: Ari Lazier Date: Fri, 13 May 2016 14:55:36 -0700 Subject: [PATCH] fix for android - create notifier after opening realm --- src/impl/realm_coordinator.cpp | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/impl/realm_coordinator.cpp b/src/impl/realm_coordinator.cpp index f9c1c38a..d9b89e0b 100644 --- a/src/impl/realm_coordinator.cpp +++ b/src/impl/realm_coordinator.cpp @@ -65,18 +65,8 @@ std::shared_ptr RealmCoordinator::get_realm(Realm::Config config) { std::lock_guard lock(m_realm_mutex); - auto realm = std::make_shared(std::move(config)); - if ((!m_config.read_only && !m_notifier) || (m_config.read_only && m_weak_realm_notifiers.empty())) { m_config = config; - if (!config.read_only && !m_notifier && config.automatic_change_notifications) { - try { - m_notifier = std::make_unique(*this); - } - catch (std::system_error const& ex) { - throw RealmFileException(RealmFileException::Kind::AccessError, config.path, ex.code().message()); - } - } } else { if (m_config.read_only != config.read_only) { @@ -113,8 +103,19 @@ std::shared_ptr RealmCoordinator::get_realm(Realm::Config config) } } } - + + auto realm = std::make_shared(std::move(config)); realm->init(shared_from_this()); + + if (!config.read_only && !m_notifier && config.automatic_change_notifications) { + try { + m_notifier = std::make_unique(*this); + } + catch (std::system_error const& ex) { + throw RealmFileException(RealmFileException::Kind::AccessError, config.path, ex.code().message()); + } + } + m_weak_realm_notifiers.emplace_back(realm, m_config.cache); return realm; }