Merge pull request #39 from WebFreak001/fix-ctors

Fix destructors on uninitialized structs
This commit is contained in:
Jan Jurzitza 2018-08-18 20:56:07 +02:00 committed by GitHub
commit c4de569809
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -717,6 +717,7 @@ struct Message {
dbus_message_unref(msg); dbus_message_unref(msg);
} }
/// Creates a new iterator and puts in the arguments for calling a method.
void build(TS...)(TS args) void build(TS...)(TS args)
if (allCanDBus!TS) { if (allCanDBus!TS) {
DBusMessageIter iter; DBusMessageIter iter;
@ -793,6 +794,7 @@ struct Message {
} }
} }
///
unittest { unittest {
import dunit.toolkit; import dunit.toolkit;
@ -811,12 +813,17 @@ struct Connection {
} }
~this() { ~this() {
if (conn) {
dbus_connection_unref(conn); dbus_connection_unref(conn);
conn = null;
}
} }
void close() { void close() {
if (conn) {
dbus_connection_close(conn); dbus_connection_close(conn);
} }
}
void send(Message msg) { void send(Message msg) {
dbus_connection_send(conn, msg.msg, null); dbus_connection_send(conn, msg.msg, null);