If the context is default, tizen-core increases reference count of
default main context.
Change-Id: I3bfce046063dc6e013b1308f45526ff59c0d1b3d
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
Context::Context(std::string name, bool use_thread)
: name_(std::move(name)),
- handle_(use_thread ? g_main_context_new() : nullptr) {}
+ handle_(use_thread ? g_main_context_new() : nullptr) {
+ if (handle_ == nullptr)
+ handle_ = g_main_context_ref(g_main_context_default());
+}
Context::~Context() {
if (handle_ != nullptr)
std::shared_ptr<Context> ContextManager::FindFromThisThread() {
auto handle = g_main_context_get_thread_default();
+ if (handle == nullptr) {
+ _W("Use default context");
+ handle = g_main_context_default();
+ }
+
std::lock_guard<std::recursive_mutex> lock(mutex_);
for (const auto& iter : contexts_) {
auto& context = iter.second;