[PATCH 11/15] Have Object subclasses NOT throw exceptions in destructors.
From: qolyester@green-communications.fr
This commit is contained in:
parent
d14c15246b
commit
2a1e2dbe51
4 changed files with 20 additions and 12 deletions
|
@ -140,7 +140,7 @@ public:
|
||||||
* \param rule Textual form of match rule.
|
* \param rule Textual form of match rule.
|
||||||
* \throw Error
|
* \throw Error
|
||||||
*/
|
*/
|
||||||
void remove_match( const char* rule );
|
void remove_match( const char* rule, bool throw_on_error );
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Adds a message filter.
|
* \brief Adds a message filter.
|
||||||
|
|
|
@ -60,7 +60,7 @@ private:
|
||||||
|
|
||||||
DXXAPILOCAL virtual bool handle_message(const Message &) = 0;
|
DXXAPILOCAL virtual bool handle_message(const Message &) = 0;
|
||||||
DXXAPILOCAL virtual void register_obj() = 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:
|
private:
|
||||||
|
|
||||||
|
@ -168,7 +168,7 @@ private:
|
||||||
bool handle_message(const Message &);
|
bool handle_message(const Message &);
|
||||||
|
|
||||||
void register_obj();
|
void register_obj();
|
||||||
void unregister_obj();
|
void unregister_obj(bool throw_on_error = true);
|
||||||
|
|
||||||
typedef std::map<const Tag *, Continuation *> ContinuationMap;
|
typedef std::map<const Tag *, Continuation *> ContinuationMap;
|
||||||
ContinuationMap _continuations;
|
ContinuationMap _continuations;
|
||||||
|
@ -217,7 +217,7 @@ private:
|
||||||
bool handle_message(const Message &);
|
bool handle_message(const Message &);
|
||||||
|
|
||||||
void register_obj();
|
void register_obj();
|
||||||
void unregister_obj();
|
void unregister_obj(bool throw_on_error = true);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
|
@ -329,7 +329,8 @@ void Connection::add_match(const char *rule)
|
||||||
if (e) throw Error(e);
|
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;
|
InternalError e;
|
||||||
|
|
||||||
|
@ -337,7 +338,14 @@ void Connection::remove_match(const char *rule)
|
||||||
|
|
||||||
debug_log("%s: removed match rule %s", unique_name(), 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)
|
bool Connection::add_filter(MessageSlot &s)
|
||||||
|
|
|
@ -164,7 +164,7 @@ ObjectAdaptor::ObjectAdaptor(Connection &conn, const Path &path)
|
||||||
|
|
||||||
ObjectAdaptor::~ObjectAdaptor()
|
ObjectAdaptor::~ObjectAdaptor()
|
||||||
{
|
{
|
||||||
unregister_obj();
|
unregister_obj(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectAdaptor::register_obj()
|
void ObjectAdaptor::register_obj()
|
||||||
|
@ -179,7 +179,7 @@ void ObjectAdaptor::register_obj()
|
||||||
_adaptor_table[path()] = this;
|
_adaptor_table[path()] = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectAdaptor::unregister_obj()
|
void ObjectAdaptor::unregister_obj(bool)
|
||||||
{
|
{
|
||||||
_adaptor_table.erase(path());
|
_adaptor_table.erase(path());
|
||||||
|
|
||||||
|
@ -295,7 +295,7 @@ ObjectProxy::ObjectProxy(Connection &conn, const Path &path, const char *service
|
||||||
|
|
||||||
ObjectProxy::~ObjectProxy()
|
ObjectProxy::~ObjectProxy()
|
||||||
{
|
{
|
||||||
unregister_obj();
|
unregister_obj(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectProxy::register_obj()
|
void ObjectProxy::register_obj()
|
||||||
|
@ -315,7 +315,7 @@ 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());
|
debug_log("unregistering remote object %s", path().c_str());
|
||||||
|
|
||||||
|
@ -323,7 +323,7 @@ void ObjectProxy::unregister_obj()
|
||||||
while (ii != _interfaces.end())
|
while (ii != _interfaces.end())
|
||||||
{
|
{
|
||||||
std::string im = "type='signal',interface='"+ii->first+"',path='"+path()+"'";
|
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;
|
++ii;
|
||||||
}
|
}
|
||||||
conn().remove_filter(_filtered);
|
conn().remove_filter(_filtered);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue