simpler-tiles 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4d396d185484dd11611fc94b0e31b0422433e646
4
- data.tar.gz: 9a45900e7020a43f62f892bc4ef3cc4fb6e4ed79
3
+ metadata.gz: 2b61f77954101ab8a753016497e1add4289eda62
4
+ data.tar.gz: de284f7de5e1a8508003946f42d98e6df6a2ca8f
5
5
  SHA512:
6
- metadata.gz: 9a64071153dfda144f420cedc2f5ae4ca03742cac59b34c4f91c39195ff5485e7e2e1fbcc42286a3b3d1c29b18c34bcf9a7c52ed37717f1e214c612902efb98d
7
- data.tar.gz: 0438c79e24270dee7e046564d9b3b4281ce11be7cba7cf9d42bb897f4f565d15d03498c93f6d5af306c53d75d9e71b0de901c31bdacce6bed74f32d52a5e5d29
6
+ metadata.gz: e1cd8686e83a43ea74d0fd2de2167b99f646296fb63d15a932a389cff36c13c02fbfaa7cec581ed9747ebdd2f8620a0032fc27a9bcfef285e1ac02d61c2a52b8
7
+ data.tar.gz: 7dcdfec476b4ffbf3459c685f6b8afd9951491b7a13362268fe8abe1eed7eb935982c2582876dfd8e8b298b93683e287dea313a11a8e94e3a0dd753faf4e7abb
@@ -22,10 +22,7 @@ mark_layer(void *layer){
22
22
  static void
23
23
  layer_free(void *layer){
24
24
  simplet_layer_t *lyr = layer;
25
- // test if we have been linked in ruby land
26
- VALUE refs = (VALUE)simplet_layer_get_user_data(lyr);
27
- // if not it is safe to free this layer.
28
- if(!refs) simplet_layer_free(lyr);
25
+ simplet_layer_free(lyr);
29
26
  }
30
27
 
31
28
 
@@ -68,8 +65,9 @@ add_query(VALUE self, VALUE query){
68
65
  simplet_query_t *qry;
69
66
  Data_Get_Struct(query, simplet_query_t, qry);
70
67
  simplet_layer_add_query_directly(layer, qry);
71
- VALUE circ_ref = rb_ary_new3(2, self, query);
68
+ VALUE circ_ref = self;
72
69
  simplet_query_set_user_data(qry, (void *)circ_ref);
70
+ simplet_retain((simplet_retainable_t*) qry);
73
71
  return query;
74
72
  }
75
73
 
@@ -222,8 +222,9 @@ add_layer(VALUE self, VALUE layer){
222
222
  simplet_layer_t *lyr;
223
223
  Data_Get_Struct(layer, simplet_layer_t, lyr);
224
224
  simplet_map_add_layer_directly(map, lyr);
225
- VALUE circ_ref = rb_ary_new3(2, self, layer);
225
+ VALUE circ_ref = self;
226
226
  simplet_layer_set_user_data(lyr, (void *)circ_ref);
227
+ simplet_retain((simplet_retainable_t*) lyr);
227
228
  return layer;
228
229
  }
229
230
 
@@ -60,8 +60,9 @@ add_style(VALUE self, VALUE style){
60
60
  simplet_style_t *style_s;
61
61
  Data_Get_Struct(style, simplet_style_t, style_s);
62
62
  simplet_query_add_style_directly(query, style_s);
63
- VALUE circ_ref = rb_ary_new3(2, self, style);
63
+ VALUE circ_ref = self;
64
64
  simplet_style_set_user_data(style_s, (void *)circ_ref);
65
+ simplet_retain((simplet_retainable_t*) style_s);
65
66
  return style;
66
67
  }
67
68
 
@@ -21,10 +21,7 @@ mark_style(void *style){
21
21
  static void
22
22
  style_free(void *style){
23
23
  simplet_style_t *stl = style;
24
- // test if we have been linked in ruby land
25
- VALUE refs = (VALUE)simplet_style_get_user_data(stl);
26
- // if not it is safe to free this style.
27
- if(!refs) simplet_style_free(stl);
24
+ simplet_style_free(stl);
28
25
  }
29
26
 
30
27
  static VALUE
@@ -1,4 +1,4 @@
1
1
  module SimplerTiles
2
2
  # The version of the library
3
- VERSION = "0.1.1"
3
+ VERSION = "0.2.0"
4
4
  end
@@ -23,4 +23,36 @@ class TestSimplerTiles < Test::Unit::TestCase
23
23
  assert data.length
24
24
  end
25
25
  end
26
+
27
+
28
+ should "not crash with memory errors" do
29
+ GC.disable
30
+ t = 100.times.map do
31
+ Thread.new do
32
+ map = SimplerTiles::Map.new do |m|
33
+ m.slippy 3, 6, 4
34
+ m.layer "#{File.dirname(__FILE__)}/../data/tl_2010_us_state10.shp" do |l|
35
+ l.query "SELECT * from 'tl_2010_us_state10'" do |q|
36
+ q.styles 'fill' => "#061F3799",
37
+ 'line-join' => "round",
38
+ 'line-cap' => "square",
39
+ 'seamless' => "true"
40
+ end
41
+ end
42
+ end
43
+
44
+ assert map.valid?
45
+ map.to_png do |data|
46
+ assert data
47
+ File.open "#{File.dirname(__FILE__)}/out.png", "wb" do |f|
48
+ f.write data
49
+ end
50
+ assert data.length
51
+ end
52
+ end
53
+ end
54
+ t.map(&:join)
55
+ end
56
+ GC.enable
57
+ GC.start
26
58
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simpler-tiles
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Larson