Don't emit InterfacesRemoved unless requested

Don't invoke  sd_bus_emit_object_removed unless sd_bus_emit_object_added
was invoked at object creation time.

Fixes openbmc/openbmc#971

Change-Id: Ib3b92af3a2c03b86008f0b4f36906a367786af45
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
diff --git a/sdbusplus/server/object.hpp b/sdbusplus/server/object.hpp
index 7da6f35..ddc7e17 100644
--- a/sdbusplus/server/object.hpp
+++ b/sdbusplus/server/object.hpp
@@ -101,8 +101,11 @@
 
     ~object()
     {
-        sd_bus_emit_object_removed(__sdbusplus_server_object_bus.get(),
-                                   __sdbusplus_server_object_path.c_str());
+        if (__sdbusplus_server_object_emitremoved)
+        {
+            sd_bus_emit_object_removed(__sdbusplus_server_object_bus.get(),
+                                       __sdbusplus_server_object_path.c_str());
+        }
     }
 
     /** Emit the 'object-added' signal, if not already sent. */