diff options
author | Kjell Ahlstedt <kjellahlstedt@gmail.com> | 2020-08-02 15:43:07 +0200 |
---|---|---|
committer | Kjell Ahlstedt <kjellahlstedt@gmail.com> | 2020-08-02 15:43:07 +0200 |
commit | bb806ba91b7c8ae08b721826996d877b748200b2 (patch) | |
tree | c00cea1e22b11a31d054097e6f8e0ced7daf695f /gio | |
parent | 477fcd63ab7a836be8916e44f7d3145f650da55c (diff) | |
download | glibmm-bb806ba91b7c8ae08b721826996d877b748200b2.tar.gz |
Gio::Tls[Client,Server]ConnectionImpl: Improve the wrap*() functions
Make Glib::wrap_tls_[client,server]_connection_impl() do like other
wrap() functions for ref-counted objects when they are given a nullptr:
return an empty RefPtr.
Diffstat (limited to 'gio')
-rw-r--r-- | gio/giomm/tlsclientconnectionimpl.cc | 15 | ||||
-rw-r--r-- | gio/giomm/tlsserverconnectionimpl.cc | 15 |
2 files changed, 18 insertions, 12 deletions
diff --git a/gio/giomm/tlsclientconnectionimpl.cc b/gio/giomm/tlsclientconnectionimpl.cc index 9207924a..003993c5 100644 --- a/gio/giomm/tlsclientconnectionimpl.cc +++ b/gio/giomm/tlsclientconnectionimpl.cc @@ -31,14 +31,17 @@ Glib::RefPtr<Gio::TlsClientConnectionImpl> wrap_tls_client_connection_impl( { using IfaceImpl = Gio::TlsClientConnectionImpl; - ObjectBase* pCppObject = ObjectBase::_get_current_wrapper((GObject*)object); + ObjectBase* pCppObject = nullptr; + if (object) + { + pCppObject = ObjectBase::_get_current_wrapper((GObject*)object); - if (!pCppObject) - pCppObject = new IfaceImpl(object); - - if (take_copy) - pCppObject->reference(); + if (!pCppObject) + pCppObject = new IfaceImpl(object); + if (take_copy) + pCppObject->reference(); + } return Glib::make_refptr_for_instance<IfaceImpl>(dynamic_cast<IfaceImpl*>(pCppObject)); } diff --git a/gio/giomm/tlsserverconnectionimpl.cc b/gio/giomm/tlsserverconnectionimpl.cc index 4a4779e0..42bac7f3 100644 --- a/gio/giomm/tlsserverconnectionimpl.cc +++ b/gio/giomm/tlsserverconnectionimpl.cc @@ -31,14 +31,17 @@ Glib::RefPtr<Gio::TlsServerConnectionImpl> wrap_tls_server_connection_impl( { using IfaceImpl = Gio::TlsServerConnectionImpl; - ObjectBase* pCppObject = ObjectBase::_get_current_wrapper((GObject*)object); + ObjectBase* pCppObject = nullptr; + if (object) + { + pCppObject = ObjectBase::_get_current_wrapper((GObject*)object); - if (!pCppObject) - pCppObject = new IfaceImpl(object); - - if (take_copy) - pCppObject->reference(); + if (!pCppObject) + pCppObject = new IfaceImpl(object); + if (take_copy) + pCppObject->reference(); + } return Glib::make_refptr_for_instance<IfaceImpl>(dynamic_cast<IfaceImpl*>(pCppObject)); } |