The allocated GSource should be released.
Calling g_source_unref() is needed.
Change-Id: Icee8d138ee8b165b9cef5c5b1203d8e7b2228c07
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
}
// LCOV_EXCL_STOP
- if (!g_source_is_destroyed(handle_))
- g_source_destroy(handle_);
+ if (!g_source_is_destroyed(handle_)) g_source_destroy(handle_);
+ if (!attached_) g_source_unref(handle_);
source_manager.Erase(handle_);
}
attached_ = true;
}
+void Source::SetAttached(bool attached) { attached_ = attached; }
+
bool Source::IsAttached() const { return attached_; }
GSource* Source::GetHandle() const { return handle_; }
void AddPoll(std::shared_ptr<PollFd> poll_fd) override;
void RemovePoll(const std::shared_ptr<PollFd>& poll_fd) override;
void Attach(const std::shared_ptr<Context>& context) override;
+ void SetAttached(bool attached);
bool IsAttached() const;
GSource* GetHandle() const;
void RefSelf() override;
return TIZEN_CORE_ERROR_INVALID_PARAMETER;
}
- auto* handle = static_cast<tizen_base::tizen_core::Source*>(source);
+ auto* handle = static_cast<SourceExt*>(source);
handle->UnrefSelf();
return TIZEN_CORE_ERROR_NONE;
}
auto handle = std::make_shared<tizen_base::tizen_core::PollFd>();
if (handle == nullptr) {
- _E("Out of memory"); // LCOV_EXCL_LINE
+ _E("Out of memory"); // LCOV_EXCL_LINE
return TIZEN_CORE_ERROR_OUT_OF_MEMORY; // LCOV_EXCL_LINE
}
auto source = std::make_shared<ChannelSource<T>>(
shared_from_this(), std::move(receiver), std::move(cb));
AddSource(source);
+ source->SetAttached(true);
return source;
}
auto source =
std::make_shared<EventSource<T>>(shared_from_this(), std::move(broker));
AddSource(source);
+ source->SetAttached(true);
AddEventSource(source);
return source;
}