mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-05-07 05:53:06 +00:00
Fix memory leaks in IMDN handler.
This commit is contained in:
parent
ae0bbc7ef8
commit
4223dbbc5a
6 changed files with 24 additions and 2 deletions
|
|
@ -88,6 +88,7 @@ static void cleanup_dead_vtable_refs(LinphoneCore *lc){
|
|||
lc->vtable_notify_recursion--;
|
||||
|
||||
void linphone_core_notify_global_state_changed(LinphoneCore *lc, LinphoneGlobalState gstate, const char *message) {
|
||||
L_GET_PRIVATE_FROM_C_OBJECT(lc)->notifyGlobalStateChanged(gstate);
|
||||
NOTIFY_IF_EXIST(global_state_changed,lc,gstate,message);
|
||||
cleanup_dead_vtable_refs(lc);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -92,6 +92,16 @@ void Imdn::onImdnMessageDelivered (const std::shared_ptr<ImdnMessage> &message)
|
|||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void Imdn::onGlobalStateChanged (LinphoneGlobalState state) {
|
||||
if (state == LinphoneGlobalShutdown) {
|
||||
auto ref = chatRoom->getSharedFromThis();
|
||||
deliveredMessages.clear();
|
||||
displayedMessages.clear();
|
||||
nonDeliveredMessages.clear();
|
||||
sentImdnMessages.clear();
|
||||
}
|
||||
}
|
||||
|
||||
void Imdn::onNetworkReachable (bool sipNetworkReachable, bool mediaNetworkReachable) {
|
||||
if (sipNetworkReachable) {
|
||||
// When the SIP network gets up, retry sending every IMDN message that has not
|
||||
|
|
|
|||
|
|
@ -62,6 +62,7 @@ public:
|
|||
void onImdnMessageDelivered (const std::shared_ptr<ImdnMessage> &message);
|
||||
|
||||
// CoreListener
|
||||
void onGlobalStateChanged (LinphoneGlobalState state) override;
|
||||
void onNetworkReachable (bool sipNetworkReachable, bool mediaNetworkReachable) override;
|
||||
|
||||
static std::string createXml (const std::string &id, time_t time, Imdn::Type imdnType, LinphoneReason reason);
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ class CoreListener {
|
|||
public:
|
||||
virtual ~CoreListener () = default;
|
||||
|
||||
virtual void onGlobalStateChanged (LinphoneGlobalState state) {}
|
||||
virtual void onNetworkReachable (bool sipNetworkReachable, bool mediaNetworkReachable) {}
|
||||
virtual void onRegistrationStateChanged (LinphoneProxyConfig *cfg, LinphoneRegistrationState state, const std::string &message) {}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ public:
|
|||
void unregisterListener (CoreListener *listener);
|
||||
void uninit ();
|
||||
|
||||
void notifyGlobalStateChanged (LinphoneGlobalState state);
|
||||
void notifyNetworkReachable (bool sipNetworkReachable, bool mediaNetworkReachable);
|
||||
void notifyRegistrationStateChanged (LinphoneProxyConfig *cfg, LinphoneRegistrationState state, const std::string &message);
|
||||
|
||||
|
|
|
|||
|
|
@ -86,13 +86,21 @@ void CorePrivate::uninit () {
|
|||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void CorePrivate::notifyGlobalStateChanged (LinphoneGlobalState state) {
|
||||
auto listenersCopy = listeners; // Allow removable of a listener in its own call
|
||||
for (const auto &listener : listenersCopy)
|
||||
listener->onGlobalStateChanged(state);
|
||||
}
|
||||
|
||||
void CorePrivate::notifyNetworkReachable (bool sipNetworkReachable, bool mediaNetworkReachable) {
|
||||
for (const auto &listener : listeners)
|
||||
auto listenersCopy = listeners; // Allow removable of a listener in its own call
|
||||
for (const auto &listener : listenersCopy)
|
||||
listener->onNetworkReachable(sipNetworkReachable, mediaNetworkReachable);
|
||||
}
|
||||
|
||||
void CorePrivate::notifyRegistrationStateChanged (LinphoneProxyConfig *cfg, LinphoneRegistrationState state, const string &message) {
|
||||
for (const auto &listener : listeners)
|
||||
auto listenersCopy = listeners; // Allow removable of a listener in its own call
|
||||
for (const auto &listener : listenersCopy)
|
||||
listener->onRegistrationStateChanged(cfg, state, message);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue