summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Volz <andreas@er00923n.fritz.box>2011-11-27 23:40:49 +0100
committerAndreas Volz <andreas@er00923n.fritz.box>2011-11-27 23:40:49 +0100
commit2a1e2dbe51ff477f6fa6499201ee819216199530 (patch)
treef8fc2b4c95455a6e1f6a47fecb0bf1fe8700f3a1
parentd14c15246bae52a98c4a9ffec987224e39b74ca9 (diff)
downloaddbus-c++-2a1e2dbe51ff477f6fa6499201ee819216199530.tar.gz
[PATCH 11/15] Have Object subclasses NOT throw exceptions in destructors.
From: qolyester@green-communications.fr
-rw-r--r--include/dbus-c++/connection.h2
-rw-r--r--include/dbus-c++/object.h6
-rw-r--r--src/connection.cpp12
-rw-r--r--src/object.cpp12
4 files changed, 20 insertions, 12 deletions
diff --git a/include/dbus-c++/connection.h b/include/dbus-c++/connection.h
index 3f8aaf6..eddf48c 100644
--- a/include/dbus-c++/connection.h
+++ b/include/dbus-c++/connection.h
@@ -140,7 +140,7 @@ public:
* \param rule Textual form of match rule.
* \throw Error
*/
- void remove_match( const char* rule );
+ void remove_match( const char* rule, bool throw_on_error );
/*!
* \brief Adds a message filter.
diff --git a/include/dbus-c++/object.h b/include/dbus-c++/object.h
index 494aa82..dd4bcb2 100644
--- a/include/dbus-c++/object.h
+++ b/include/dbus-c++/object.h
@@ -60,7 +60,7 @@ private:
DXXAPILOCAL virtual bool handle_message(const Message &) = 0;
DXXAPILOCAL virtual void register_obj() = 0;
- DXXAPILOCAL virtual void unregister_obj() = 0;
+ DXXAPILOCAL virtual void unregister_obj(bool throw_on_error = true) = 0;
private:
@@ -168,7 +168,7 @@ private:
bool handle_message(const Message &);
void register_obj();
- void unregister_obj();
+ void unregister_obj(bool throw_on_error = true);
typedef std::map<const Tag *, Continuation *> ContinuationMap;
ContinuationMap _continuations;
@@ -217,7 +217,7 @@ private:
bool handle_message(const Message &);
void register_obj();
- void unregister_obj();
+ void unregister_obj(bool throw_on_error = true);
private:
diff --git a/src/connection.cpp b/src/connection.cpp
index 73b3e6d..40c3166 100644
--- a/src/connection.cpp
+++ b/src/connection.cpp
@@ -329,7 +329,8 @@ void Connection::add_match(const char *rule)
if (e) throw Error(e);
}
-void Connection::remove_match(const char *rule)
+void Connection::remove_match(const char *rule,
+ bool throw_on_error)
{
InternalError e;
@@ -337,7 +338,14 @@ void Connection::remove_match(const char *rule)
debug_log("%s: removed match rule %s", unique_name(), rule);
- if (e) throw Error(e);
+ if (e) {
+ if (throw_on_error)
+ throw Error(e);
+ else
+ debug_log("DBus::Connection::remove_match: %s (%s).",
+ static_cast<DBusError*>(e)->message,
+ static_cast<DBusError*>(e)->name);
+ }
}
bool Connection::add_filter(MessageSlot &s)
diff --git a/src/object.cpp b/src/object.cpp
index 88c3bb0..0a1f718 100644
--- a/src/object.cpp
+++ b/src/object.cpp
@@ -164,7 +164,7 @@ ObjectAdaptor::ObjectAdaptor(Connection &conn, const Path &path)
ObjectAdaptor::~ObjectAdaptor()
{
- unregister_obj();
+ unregister_obj(false);
}
void ObjectAdaptor::register_obj()
@@ -179,7 +179,7 @@ void ObjectAdaptor::register_obj()
_adaptor_table[path()] = this;
}
-void ObjectAdaptor::unregister_obj()
+void ObjectAdaptor::unregister_obj(bool)
{
_adaptor_table.erase(path());
@@ -295,7 +295,7 @@ ObjectProxy::ObjectProxy(Connection &conn, const Path &path, const char *service
ObjectProxy::~ObjectProxy()
{
- unregister_obj();
+ unregister_obj(false);
}
void ObjectProxy::register_obj()
@@ -315,15 +315,15 @@ void ObjectProxy::register_obj()
}
}
-void ObjectProxy::unregister_obj()
+void ObjectProxy::unregister_obj(bool throw_on_error)
{
debug_log("unregistering remote object %s", path().c_str());
-
+
InterfaceProxyTable::const_iterator ii = _interfaces.begin();
while (ii != _interfaces.end())
{
std::string im = "type='signal',interface='"+ii->first+"',path='"+path()+"'";
- conn().remove_match(im.c_str());
+ conn().remove_match(im.c_str(), throw_on_error);
++ii;
}
conn().remove_filter(_filtered);