Imported Upstream version 2.52.0 upstream/2.52.0
authorDongHun Kwak <dh0128.kwak@samsung.com>
Mon, 7 Sep 2020 07:19:28 +0000 (00:19 -0700)
committerDongHun Kwak <dh0128.kwak@samsung.com>
Mon, 7 Sep 2020 07:19:28 +0000 (00:19 -0700)
NEWS
configure.ac
gio/src/actionmap.hg
gio/src/dbusproxy.ccg
gio/src/dbusproxy.hg
gio/src/gio_docs_override.xml
gio/src/unixsocketaddress.hg
glib/glibmm/refptr.h
glib/src/variant.ccg
glib/src/variant.hg

diff --git a/NEWS b/NEWS
index 107d7b9..3f7c7fb 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,18 @@
+2.52.0 (stable):
+
+Gio:
+* UnixSocketAddress::create(): Remove the default value for the type
+  parameter to avoid ambiguity.
+  (Kjell Ahlstedt) Bug #782592
+
+Gio::DBus
+* Proxy: Wrap call() and call_sync() methods.
+  (Vyacheslav Yurkov) Bug #781818
+
+Documentation:
+* RefPtr: Clarify comment about undefined behaviour.
+  (Daniel Boles)
+
 2.51.7 (unstable):
 
 Glib:
index f6963c7..7006b82 100644 (file)
@@ -15,7 +15,7 @@
 ## You should have received a copy of the GNU Lesser General Public License
 ## along with this library.  If not, see <http://www.gnu.org/licenses/>.
 
-AC_INIT([glibmm], [2.51.7],
+AC_INIT([glibmm], [2.52.0],
         [http://bugzilla.gnome.org/enter_bug.cgi?product=glibmm],
         [glibmm], [http://www.gtkmm.org/])
 AC_PREREQ([2.59])
index 4194cdb..f7e097b 100644 (file)
@@ -74,7 +74,7 @@ public:
    * For instance,
    * void on_slot_activated();
    */
-  using ActivateSlot = sigc::slot<void()>;
+  using ActivateSlot = sigc::slot<void>;
 
   /** A convenience method for creating a SimpleAction instance
    * and adding it to the ActionMap.
@@ -93,7 +93,7 @@ public:
    * For instance,
    * void on_slot_activated(const Glib::VariantBase& parameter);
    */
-  using ActivateWithParameterSlot = sigc::slot<void(const Glib::VariantBase&)>;
+  using ActivateWithParameterSlot = sigc::slot<void, const Glib::VariantBase&>;
 
 _DEPRECATE_IFDEF_START
   /** A convenience method for creating a SimpleAction instance
index b13f92f..0855f88 100644 (file)
@@ -202,101 +202,6 @@ Proxy::get_cached_property(Glib::VariantBase& property, const Glib::ustring& pro
   property.init(g_variant, false /* no extra reference needed */);
 }
 
-void
-Proxy::call(const Glib::ustring& method_name, const SlotAsyncReady& slot,
-  const Glib::RefPtr<Cancellable>& cancellable, const Glib::VariantContainerBase& parameters,
-  int timeout_msec, CallFlags flags)
-{
-  // Create a copy of the slot.
-  // A pointer to it will be passed through the callback's data parameter
-  // and deleted in the callback.
-  auto slot_copy = new SlotAsyncReady(slot);
-
-  g_dbus_proxy_call(gobj(), method_name.c_str(), const_cast<GVariant*>(parameters.gobj()),
-    static_cast<GDBusCallFlags>(flags), timeout_msec, Glib::unwrap(cancellable),
-    &SignalProxy_async_callback, slot_copy);
-}
-
-void
-Proxy::call(const Glib::ustring& method_name, const SlotAsyncReady& slot,
-  const Glib::VariantContainerBase& parameters, int timeout_msec, CallFlags flags)
-{
-  // Create a copy of the slot.
-  // A pointer to it will be passed through the callback's data parameter
-  // and deleted in the callback.
-  auto slot_copy = new SlotAsyncReady(slot);
-
-  g_dbus_proxy_call(gobj(), method_name.c_str(), const_cast<GVariant*>(parameters.gobj()),
-    static_cast<GDBusCallFlags>(flags), timeout_msec, nullptr, &SignalProxy_async_callback,
-    slot_copy);
-}
-
-Glib::VariantContainerBase
-Proxy::call_sync(const Glib::ustring& method_name, const Glib::RefPtr<Cancellable>& cancellable,
-  const Glib::VariantContainerBase& parameters, int timeout_msec, CallFlags flags)
-{
-  GError* g_error = nullptr;
-
-  GVariant* const gvariant =
-    g_dbus_proxy_call_sync(gobj(), method_name.c_str(), const_cast<GVariant*>(parameters.gobj()),
-      static_cast<GDBusCallFlags>(flags), timeout_msec, Glib::unwrap(cancellable), &g_error);
-
-  if (g_error)
-    ::Glib::Error::throw_exception(g_error);
-
-  return Glib::VariantContainerBase(gvariant, false); // Dont' take an extra reference.
-}
-
-Glib::VariantContainerBase
-Proxy::call_sync(const Glib::ustring& method_name, const Glib::VariantContainerBase& parameters,
-  int timeout_msec, CallFlags flags)
-{
-  GError* g_error = nullptr;
-
-  GVariant* const gvariant =
-    g_dbus_proxy_call_sync(gobj(), method_name.c_str(), const_cast<GVariant*>(parameters.gobj()),
-      static_cast<GDBusCallFlags>(flags), timeout_msec, nullptr, &g_error);
-
-  if (g_error)
-    ::Glib::Error::throw_exception(g_error);
-
-  return Glib::VariantContainerBase(gvariant, false); // Dont' take an extra reference.
-}
-
-#ifdef G_OS_UNIX
-// With a UnixFDList.
-void
-Proxy::call(const Glib::ustring& method_name, const Glib::VariantContainerBase& parameters,
-  const SlotAsyncReady& slot, const Glib::RefPtr<Cancellable>& cancellable,
-  const Glib::RefPtr<UnixFDList>& fd_list, int timeout_msec, CallFlags flags)
-{
-  // Create a copy of the slot.
-  // A pointer to it will be passed through the callback's data parameter
-  // and deleted in the callback.
-  auto slot_copy = new SlotAsyncReady(slot);
-
-  g_dbus_proxy_call_with_unix_fd_list(gobj(), method_name.c_str(),
-    const_cast<GVariant*>(parameters.gobj()), static_cast<GDBusCallFlags>(flags), timeout_msec,
-    Glib::unwrap(fd_list), Glib::unwrap(cancellable), &SignalProxy_async_callback, slot_copy);
-}
-
-// Non-cancellable version (with a UnixFDList).
-void
-Proxy::call(const Glib::ustring& method_name, const Glib::VariantContainerBase& parameters,
-  const SlotAsyncReady& slot, const Glib::RefPtr<UnixFDList>& fd_list, int timeout_msec,
-  CallFlags flags)
-{
-  // Create a copy of the slot.
-  // A pointer to it will be passed through the callback's data parameter
-  // and deleted in the callback.
-  auto slot_copy = new SlotAsyncReady(slot);
-
-  g_dbus_proxy_call_with_unix_fd_list(gobj(), method_name.c_str(),
-    const_cast<GVariant*>(parameters.gobj()), static_cast<GDBusCallFlags>(flags), timeout_msec,
-    Glib::unwrap(fd_list), nullptr, &SignalProxy_async_callback, slot_copy);
-}
-#endif // G_OS_UNIX
-
 } // namespace DBus
 
 } // namespace Gio
index a6e7419..1b79db3 100644 (file)
@@ -260,24 +260,17 @@ public:
   _WRAP_METHOD(Glib::RefPtr<InterfaceInfo> get_interface_info(), g_dbus_proxy_get_interface_info)
   _WRAP_METHOD(Glib::RefPtr<const InterfaceInfo> get_interface_info() const, g_dbus_proxy_get_interface_info, constversion)
 
-  _WRAP_METHOD_DOCS_ONLY(g_dbus_proxy_call)
-  void call(
-    const Glib::ustring& method_name,
-    const SlotAsyncReady& slot,
-    const Glib::RefPtr<Cancellable>& cancellable,
-    const Glib::VariantContainerBase& parameters = Glib::VariantContainerBase(),
-    int timeout_msec = -1,
-    CallFlags flags = Gio::DBus::CALL_FLAGS_NONE
-  );
-
-  /// A non-cancellable version of call().
-  void call(
-    const Glib::ustring& method_name,
-    const SlotAsyncReady& slot,
-    const Glib::VariantContainerBase& parameters = Glib::VariantContainerBase(),
-    int timeout_msec = -1,
-    CallFlags flags = Gio::DBus::CALL_FLAGS_NONE
-  );
+  _WRAP_METHOD(
+    void call(
+      const Glib::ustring&               method_name{.},
+      const SlotAsyncReady&              slot{callback?},
+      const Glib::RefPtr<Cancellable>&   cancellable{.?},
+      const Glib::VariantContainerBase&  parameters{.} = Glib::VariantContainerBase(),
+      int                                timeout_msec{.} = -1,
+      CallFlags                          flags{.} = Gio::DBus::CALL_FLAGS_NONE
+    ),
+    g_dbus_proxy_call, slot_name slot, slot_callback SignalProxy_async_callback
+  )
 
   /** Finishes an operation started with call().
    *
@@ -289,81 +282,30 @@ public:
    */
   _WRAP_METHOD(Glib::VariantContainerBase call_finish(const Glib::RefPtr<AsyncResult>& res), g_dbus_proxy_call_finish, errthrow)
 
-//TODO: Use _WRAP_METHOD() for this?
-  /** Synchronously invokes the method_name method on proxy.
-   * See call(), the asynchronous version of this method for more information.
-   *
-   * @param method_name Name of method to invoke.
-   * @param timeout_msec The timeout in milliseconds or -1 to use the proxy
-   * default timeout.
-   * @param flags Flags from the CallFlags enumeration.
-   * @param parameters A Glib::VariantContainerBase tuple with parameters for the
-   * signal.
-   * @param cancellable A Cancellable.
-   * @result A Variant tuple with return values.
-   *
-   * @throw Glib::Error.
-   */
-  Glib::VariantContainerBase call_sync(
-    const Glib::ustring& method_name,
-    const Glib::RefPtr<Cancellable>& cancellable,
-    const Glib::VariantContainerBase& parameters = Glib::VariantContainerBase(),
-    int timeout_msec = -1,
-    CallFlags flags = Gio::DBus::CALL_FLAGS_NONE
-  );
-  _IGNORE(g_dbus_proxy_call_sync)
-
-  /// A non-cancellable version of call_sync().
-  Glib::VariantContainerBase call_sync(
-    const Glib::ustring& method_name,
-    const Glib::VariantContainerBase& parameters = Glib::VariantContainerBase(),
-    int timeout_msec = -1,
-    CallFlags flags = Gio::DBus::CALL_FLAGS_NONE
-  );
-
-
-#ifdef G_OS_UNIX
-//TODO: Use _WRAP_METHOD() for this?
-  /** Like call() but also takes a GUnixFDList object.
-   * This method is only available on UNIX.
-   *
-   * This is an asynchronous method. When the operation is finished, callback
-   * will be invoked in the thread-default main loop of the thread you are
-   * calling this method from. You can then call call_with_unix_fd_finish() to
-   * get the result of the operation. See call_sync() for the synchronous
-   * version of this function.
-   *
-   * @param method_name The name of the method to invoke.
-   * @param parameters A Glib::VariantContainerBase tuple with parameters for the
-   * method or <tt>0</tt> if not passing parameters.
-   * @param slot A SlotAsyncReady to call when the request is satisfied.
-   * @param cancellable A Cancellable.
-   * @param fd_list A UnixFDList.
-   * @param timeout_msec The timeout in milliseconds, -1 to use the default
-   * timeout or G_MAXINT for no timeout.
-   * @param flags Flags from the Gio::DBus::CallFlags enumeration.
-   * @newin{2,34}
-   */
-  void call(
-    const Glib::ustring&                method_name,
-    const Glib::VariantContainerBase&   parameters,
-    const SlotAsyncReady&               slot,
-    const Glib::RefPtr<Cancellable>&    cancellable,
-    const Glib::RefPtr<UnixFDList>&     fd_list,
-    int                                 timeout_msec = -1,
-    CallFlags                           flags = Gio::DBus::CALL_FLAGS_NONE);
-  _IGNORE(g_dbus_proxy_call_with_unix_fd_list)
-
-  /** A non-cancellable version of call() (with a UnixFDList).
-   * @newin{2,34}
-   */
-  void call(
-    const Glib::ustring&                method_name,
-    const Glib::VariantContainerBase&   parameters,
-    const SlotAsyncReady&               slot,
-    const Glib::RefPtr<UnixFDList>&     fd_list,
-    int                                 timeout_msec = -1,
-    CallFlags                           flags = Gio::DBus::CALL_FLAGS_NONE);
+  _WRAP_METHOD(
+    Glib::VariantContainerBase call_sync(
+      const Glib::ustring&               method_name{.},
+      const Glib::RefPtr<Cancellable>&   cancellable{.?},
+      const Glib::VariantContainerBase&  parameters{.} = Glib::VariantContainerBase(),
+      int                                timeout_msec{.} = -1,
+      CallFlags                          flags{.} = Gio::DBus::CALL_FLAGS_NONE
+    ),
+    g_dbus_proxy_call_sync, errthrow
+  )
+
+  _WRAP_METHOD(
+    void call(
+      const Glib::ustring&                method_name{.},
+      const Glib::VariantContainerBase&   parameters{.},
+      const SlotAsyncReady&               slot{callback?},
+      const Glib::RefPtr<Cancellable>&    cancellable{.?},
+      const Glib::RefPtr<UnixFDList>&     fd_list{.},
+      int                                 timeout_msec{.} = -1,
+      CallFlags                           flags{.} = Gio::DBus::CALL_FLAGS_NONE
+    ),
+    g_dbus_proxy_call_with_unix_fd_list, ifdef G_OS_UNIX,
+      slot_name slot, slot_callback SignalProxy_async_callback
+  )
 
   /** Finishes an operation started with call() (with a UnixFDList).
    * @param res A AsyncResult obtained from the SlotAsyncReady passed to
@@ -374,7 +316,6 @@ public:
    * @newin{2,34}
    */
   _WRAP_METHOD(Glib::VariantContainerBase call_finish(const Glib::RefPtr<AsyncResult>& res{.}, Glib::RefPtr<UnixFDList>& out_fd_list{.>>}), g_dbus_proxy_call_with_unix_fd_list_finish, errthrow, ifdef G_OS_UNIX)
-#endif // G_OS_UNIX
 
   _WRAP_METHOD(
     Glib::VariantContainerBase call_sync(
index 5ea862d..053ef09 100644 (file)
@@ -1714,4 +1714,86 @@ errors that can happen due to races when you execute the operation.
 </return>
 </function>
 
+<function name="g_dbus_proxy_call">
+<parameters>
+<parameter name="proxy">
+<parameter_description> A #GDBusProxy.
+</parameter_description>
+</parameter>
+<parameter name="method_name">
+<parameter_description> Name of method to invoke.
+</parameter_description>
+</parameter>
+<parameter name="parameters">
+<parameter_description> A #GVariant tuple with parameters for the signal or %NULL if not passing parameters.
+</parameter_description>
+</parameter>
+<parameter name="flags">
+<parameter_description> Flags from the #GDBusCallFlags enumeration.
+</parameter_description>
+</parameter>
+<parameter name="timeout_msec">
+<parameter_description> The timeout in milliseconds (with %G_MAXINT meaning
+&quot;infinite&quot;) or -1 to use the proxy default timeout.
+</parameter_description>
+</parameter>
+<parameter name="cancellable">
+<parameter_description> A #GCancellable or %NULL.
+</parameter_description>
+</parameter>
+<parameter name="callback">
+<parameter_description> A #GAsyncReadyCallback to call when the request is satisfied. Use another overload
+without this parameter if your don't care about the result of the method invocation.
+</parameter_description>
+</parameter>
+<parameter name="user_data">
+<parameter_description> The data to pass to @callback.
+</parameter_description>
+</parameter>
+</parameters>
+</function>
+
+<function name="g_dbus_proxy_call_with_unix_fd_list">
+<parameters>
+<parameter name="proxy">
+<parameter_description> A #GDBusProxy.
+</parameter_description>
+</parameter>
+<parameter name="method_name">
+<parameter_description> Name of method to invoke.
+</parameter_description>
+</parameter>
+<parameter name="parameters">
+<parameter_description> A #GVariant tuple with parameters for the signal or %NULL if not passing parameters.
+</parameter_description>
+</parameter>
+<parameter name="flags">
+<parameter_description> Flags from the #GDBusCallFlags enumeration.
+</parameter_description>
+</parameter>
+<parameter name="timeout_msec">
+<parameter_description> The timeout in milliseconds (with %G_MAXINT meaning
+&quot;infinite&quot;) or -1 to use the proxy default timeout.
+</parameter_description>
+</parameter>
+<parameter name="fd_list">
+<parameter_description> A #GUnixFDList or %NULL.
+</parameter_description>
+</parameter>
+<parameter name="cancellable">
+<parameter_description> A #GCancellable or %NULL.
+</parameter_description>
+</parameter>
+<parameter name="callback">
+<parameter_description> A #GAsyncReadyCallback to call when the request is satisfied. Use another overload
+without this parameter if your don't care about the result of the method invocation.
+</parameter_description>
+</parameter>
+<parameter name="user_data">
+<parameter_description> The data to pass to @callback.
+</parameter_description>
+</parameter>
+</parameters>
+</function>
+
 </root>
index e3e4170..e005d48 100644 (file)
@@ -70,8 +70,7 @@ public:
 
  _WRAP_METHOD_DOCS_ONLY(g_unix_socket_address_new_with_type)
  static Glib::RefPtr<UnixSocketAddress> create(const std::string& path,
-   UnixSocketAddressType type = Gio::UNIX_SOCKET_ADDRESS_ABSTRACT,
-   int path_len = -1);
+   UnixSocketAddressType type, int path_len = -1);
 
  // Deprecated.
  _IGNORE(g_unix_socket_address_get_is_abstract)
index 892b6a6..a597078 100644 (file)
@@ -88,7 +88,7 @@ private:
 public:
   /** Default constructor
    *
-   * Afterwards it will be null and use of -> will cause a segmentation fault.
+   * Afterwards it will be null and use of -> will invoke undefined behaviour.
    */
   inline RefPtr() noexcept;
 
index 9c47dea..ed88877 100644 (file)
@@ -184,7 +184,7 @@ VariantContainerBase::create_maybe(const VariantType& child_type, const VariantB
 void
 VariantContainerBase::get_child(VariantBase& child, gsize index) const
 {
-  if (index >= g_variant_n_children(gobject_))
+  if (index >= get_n_children())
     throw std::out_of_range("VariantContainerBase::get_child(): Index out of bounds.");
 
   GVariant* const gvariant = g_variant_get_child_value(gobject_, index);
@@ -466,7 +466,7 @@ Variant<type_vec_ustring>::create(const type_vec_ustring& data)
 Glib::ustring
 Variant<type_vec_ustring>::get_child(gsize index) const
 {
-  if (index >= g_variant_n_children(const_cast<GVariant*>(gobj())))
+  if (index >= get_n_children())
     throw std::out_of_range(
       "Variant< std::vector<Glib::ustring> >::get_child(): Index out of bounds.");
 
@@ -482,9 +482,7 @@ Variant<type_vec_ustring>::get() const
   // but the Variant can alternatively hold an array of object paths or DBus type signatures.
   type_vec_ustring result;
 
-  gsize n_children = g_variant_n_children(const_cast<GVariant*>(gobj()));
-
-  for (gsize i = 0; i < n_children; i++)
+  for (gsize i = 0, n_children = get_n_children(); i < n_children; ++i)
   {
     GVariant* gvariant = g_variant_get_child_value(const_cast<GVariant*>(gobj()), i);
     result.emplace_back(Glib::Variant<Glib::ustring>(gvariant).get());
@@ -564,7 +562,7 @@ Variant<type_vec_string>::create_from_object_paths(const type_vec_string& data)
 std::string
 Variant<type_vec_string>::get_child(gsize index) const
 {
-  if (index >= g_variant_n_children(const_cast<GVariant*>(gobj())))
+  if (index >= get_n_children())
     throw std::out_of_range(
       "Variant< std::vector<std::string> >::get_child(): Index out of bounds.");
 
@@ -581,9 +579,7 @@ Variant<type_vec_string>::get() const
   // signatures.
   type_vec_string result;
 
-  gsize n_children = g_variant_n_children(const_cast<GVariant*>(gobj()));
-
-  for (gsize i = 0; i < n_children; i++)
+  for (gsize i = 0, n_children = get_n_children(); i < n_children; ++i)
   {
     GVariant* gvariant = g_variant_get_child_value(const_cast<GVariant*>(gobj()), i);
     result.emplace_back(Glib::Variant<std::string>(gvariant).get());
index de10195..39c63f1 100644 (file)
@@ -1125,7 +1125,7 @@ Variant< std::vector<T> >::create(const std::vector<T>& data)
 template<class T>
 T Variant< std::vector<T> >::get_child(gsize index) const
 {
-  if(index >= g_variant_n_children(const_cast<GVariant*>(gobj())))
+  if (index >= get_n_children())
     throw std::out_of_range(
       "Variant< std::vector<T> >::get_child(): Index out of bounds.");
 
@@ -1143,9 +1143,7 @@ std::vector<T> Variant< std::vector<T> >::get() const
 {
   std::vector<T> result;
 
-  gsize n_children = g_variant_n_children(const_cast<GVariant*>(gobj()));
-
-  for(gsize i = 0; i < n_children; i++)
+  for (gsize i = 0, n_children = get_n_children(); i < n_children; ++i)
   {
     Glib::Variant<T> variant;