]> git.notmuchmail.org Git - notmuch/blobdiff - bindings/ruby/threads.c
ruby: Don't barf if an object is destroyed more than once
[notmuch] / bindings / ruby / threads.c
index 09906975f1e84091ead20878a06b96b60e55d0b1..abd51212664c0a10c5b58b34475e049419fba288 100644 (file)
@@ -33,11 +33,11 @@ notmuch_rb_threads_destroy(VALUE self)
     Data_Get_Struct(self, notmuch_threads_t, threads);
 
     notmuch_threads_destroy(threads);
+    DATA_PTR(self) = NULL;
 
     return Qnil;
 }
 
-
 /* call-seq: THREADS.each {|item| block } => THREADS
  *
  * Calls +block+ once for each thread in +self+, passing that element as a
@@ -49,9 +49,7 @@ notmuch_rb_threads_each(VALUE self)
     notmuch_thread_t *thread;
     notmuch_threads_t *threads;
 
-    Data_Get_Struct(self, notmuch_threads_t, threads);
-    if (!threads)
-        return self;
+    Data_Get_Notmuch_Threads(self, threads);
 
     for (; notmuch_threads_valid(threads); notmuch_threads_move_to_next(threads)) {
         thread = notmuch_threads_get(threads);