From 5c9e385591b66fa20cbb186393c48c52831a23b7 Mon Sep 17 00:00:00 2001 From: Ali Polatel Date: Wed, 26 May 2010 20:56:07 +0300 Subject: ruby: Don't barf if an object is destroyed more than once Raise RuntimeError instead. Also revise Notmuch::Database a bit. Add Notmuch::Database.open singleton method. --- bindings/ruby/messages.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'bindings/ruby/messages.c') diff --git a/bindings/ruby/messages.c b/bindings/ruby/messages.c index 94b0b0da..35b5d146 100644 --- a/bindings/ruby/messages.c +++ b/bindings/ruby/messages.c @@ -28,11 +28,12 @@ VALUE notmuch_rb_messages_destroy(VALUE self) { - notmuch_messages_t *fnames; + notmuch_messages_t *messages; - Data_Get_Struct(self, notmuch_messages_t, fnames); + Data_Get_Notmuch_Messages(self, messages); - notmuch_messages_destroy(fnames); + notmuch_messages_destroy(messages); + DATA_PTR(self) = NULL; return Qnil; } @@ -48,9 +49,7 @@ notmuch_rb_messages_each(VALUE self) notmuch_message_t *message; notmuch_messages_t *messages; - Data_Get_Struct(self, notmuch_messages_t, messages); - if (!messages) - return self; + Data_Get_Notmuch_Messages(self, messages); for (; notmuch_messages_valid(messages); notmuch_messages_move_to_next(messages)) { message = notmuch_messages_get(messages); @@ -71,7 +70,7 @@ notmuch_rb_messages_collect_tags(VALUE self) notmuch_tags_t *tags; notmuch_messages_t *messages; - Data_Get_Struct(self, notmuch_messages_t, messages); + Data_Get_Notmuch_Messages(self, messages); tags = notmuch_messages_collect_tags(messages); if (!tags) -- cgit v1.2.3