Create the callbacks hash on first use.
authorTilman Sauerbeck <tilman@code-monkey.de>
Tue, 22 Mar 2005 17:42:04 +0000 (17:42 +0000)
committerTilman Sauerbeck <tilman@code-monkey.de>
Tue, 22 Mar 2005 17:42:04 +0000 (17:42 +0000)
src/ecore_evas/rb_ecore_evas.c

index 9b2ad29a2bd77a657f19c8c1a6b75dff4aaac389..3ded59d92230d678f149cb601179cbf53755c00b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: rb_ecore_evas.c 110 2004-09-02 17:06:54Z tilman $
+ * $Id: rb_ecore_evas.c 303 2005-03-22 17:42:04Z tilman $
  *
  * Copyright (C) 2004 ruby-ecore team (see AUTHORS)
  *
@@ -51,6 +51,9 @@
 \
                if (!rb_block_given_p ()) \
                        return Qnil; \
+\
+               if (NIL_P (ee->callbacks)) \
+                       ee->callbacks = rb_hash_new (); \
 \
                rb_hash_aset (ee->callbacks, rb_str_new2 (#name), \
                              rb_block_proc ()); \
@@ -67,7 +70,8 @@ void c_ecore_evas_mark (RbEcoreEvas *ee)
        if (!NIL_P (ee->evas))
                rb_gc_mark (ee->evas);
 
-       rb_gc_mark (ee->callbacks);
+       if (!NIL_P (ee->callbacks))
+               rb_gc_mark (ee->callbacks);
 }
 
 void c_ecore_evas_free (RbEcoreEvas *ee, bool free_mem)
@@ -88,7 +92,7 @@ static VALUE c_init (int argc, VALUE *argv, VALUE self)
        GET_OBJ (self, RbEcoreEvas, ee);
 
        ee->evas = Qnil;
-       ee->callbacks = rb_hash_new ();
+       ee->callbacks = Qnil;
 
        ecore_evas_data_set (ee->real, RUBY_ECORE_EVAS_KEY, (void *) self);