teacup 2.1.4 → 2.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.travis.yml +1 -0
- data/Gemfile.lock +1 -1
- data/README.md +3 -1
- data/app/controllers/memory_leak_controller.rb +28 -0
- data/lib/teacup.rb +28 -0
- data/lib/teacup/layout.rb +2 -2
- data/lib/teacup/version.rb +1 -1
- data/spec/ios/memory_leak_spec.rb +53 -0
- metadata +4 -1
data/.travis.yml
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -74,7 +74,9 @@ require 'teacup'
|
|
74
74
|
|
75
75
|
#### 10 second primer, OS X
|
76
76
|
|
77
|
-
Pretty much the same!
|
77
|
+
Pretty much the same! Note that on OS X, view coordinates are based on having
|
78
|
+
the origin in the bottom-left corner, not the upper-left like it is *on every
|
79
|
+
other GUI system ever*. :-|
|
78
80
|
|
79
81
|
**You should use the `TeacupWindowController` parent class instead of `NSWindowController`**
|
80
82
|
|
@@ -0,0 +1,28 @@
|
|
1
|
+
class MemoryLeakController < UIViewController
|
2
|
+
DidDeallocNotification = 'DidDeallocNotification'
|
3
|
+
|
4
|
+
stylesheet :memory_leak
|
5
|
+
|
6
|
+
layout do
|
7
|
+
puts("=============== memory_leak_controller.rb line #{__LINE__} ===============")
|
8
|
+
subview(UIView, :view) do
|
9
|
+
puts("=============== memory_leak_controller.rb line #{__LINE__} ===============")
|
10
|
+
subview(UIView)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def dealloc
|
15
|
+
NSNotificationCenter.defaultCenter.postNotificationName(DidDeallocNotification, object:self)
|
16
|
+
super
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
Teacup::Stylesheet.new :memory_leak do
|
23
|
+
|
24
|
+
style :view,
|
25
|
+
frame: [[10, 10], [100, 100]],
|
26
|
+
backgroundColor: UIColor.whiteColor
|
27
|
+
|
28
|
+
end
|
data/lib/teacup.rb
CHANGED
@@ -22,4 +22,32 @@ Motion::Project::App.setup do |app|
|
|
22
22
|
Dir.glob(File.join(teacup_lib, '**/*.rb')).reverse.each do |file|
|
23
23
|
app.files.insert(insert_point, file)
|
24
24
|
end
|
25
|
+
|
26
|
+
if platform == :ios
|
27
|
+
app.files_dependencies File.join(teacup_platform_lib, 'core_extensions/ui_view.rb') => [
|
28
|
+
File.join(teacup_lib, 'layout.rb'),
|
29
|
+
File.join(teacup_lib, 'teacup_view.rb'),
|
30
|
+
]
|
31
|
+
app.files_dependencies File.join(teacup_platform_lib, 'core_extensions/ui_view_controller.rb') => [
|
32
|
+
File.join(teacup_lib, 'layout.rb'),
|
33
|
+
File.join(teacup_lib, 'teacup_controller.rb'),
|
34
|
+
]
|
35
|
+
else
|
36
|
+
app.files_dependencies File.join(teacup_platform_lib, 'core_extensions/ns_view.rb') => [
|
37
|
+
File.join(teacup_lib, 'layout.rb'),
|
38
|
+
File.join(teacup_lib, 'teacup_view.rb'),
|
39
|
+
]
|
40
|
+
app.files_dependencies File.join(teacup_platform_lib, 'core_extensions/ns_window.rb') => [
|
41
|
+
File.join(teacup_lib, 'layout.rb'),
|
42
|
+
File.join(teacup_lib, 'teacup_view.rb'),
|
43
|
+
]
|
44
|
+
app.files_dependencies File.join(teacup_platform_lib, 'core_extensions/ns_view_controller.rb') => [
|
45
|
+
File.join(teacup_lib, 'layout.rb'),
|
46
|
+
File.join(teacup_lib, 'teacup_controller.rb'),
|
47
|
+
]
|
48
|
+
app.files_dependencies File.join(teacup_platform_lib, 'core_extensions/ns_window_controller.rb') => [
|
49
|
+
File.join(teacup_lib, 'layout.rb'),
|
50
|
+
File.join(teacup_lib, 'teacup_controller.rb'),
|
51
|
+
]
|
52
|
+
end
|
25
53
|
end
|
data/lib/teacup/layout.rb
CHANGED
@@ -164,8 +164,8 @@ module Teacup
|
|
164
164
|
# assign the 'teacup_next_responder', which is queried for a stylesheet if
|
165
165
|
# one is not explicitly assigned to the view
|
166
166
|
if view.is_a? Layout
|
167
|
-
|
168
|
-
view.teacup_next_responder = self
|
167
|
+
view.teacup_next_responder = WeakRef.new(self)
|
168
|
+
# view.teacup_next_responder = self
|
169
169
|
end
|
170
170
|
|
171
171
|
if block_given?
|
data/lib/teacup/version.rb
CHANGED
@@ -0,0 +1,53 @@
|
|
1
|
+
class LeakDetector
|
2
|
+
|
3
|
+
def initialize
|
4
|
+
@did_dealloc = false
|
5
|
+
end
|
6
|
+
|
7
|
+
def did_dealloc(notification)
|
8
|
+
@did_dealloc = true
|
9
|
+
end
|
10
|
+
|
11
|
+
def did_dealloc?
|
12
|
+
@did_dealloc
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "Memory leaks" do
|
18
|
+
tests MemoryLeakController
|
19
|
+
|
20
|
+
def controller
|
21
|
+
unless @controller
|
22
|
+
puts("=============== memory_leak_spec.rb line #{__LINE__} ===============")
|
23
|
+
root = UIViewController.new
|
24
|
+
@controller = UINavigationController.alloc.initWithRootViewController(root)
|
25
|
+
end
|
26
|
+
|
27
|
+
@controller
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should dealloc after being popped from UINavigationController" do
|
31
|
+
detector = LeakDetector.new
|
32
|
+
|
33
|
+
memory_leak = MemoryLeakController.new
|
34
|
+
p memory_leak.view
|
35
|
+
|
36
|
+
NSNotificationCenter.defaultCenter.addObserver(detector,
|
37
|
+
selector: :'did_dealloc:',
|
38
|
+
name: MemoryLeakController::DidDeallocNotification,
|
39
|
+
object: memory_leak)
|
40
|
+
|
41
|
+
self.controller.pushViewController(memory_leak, animated: false)
|
42
|
+
memory_leak = nil
|
43
|
+
|
44
|
+
wait 1 do
|
45
|
+
self.controller.popViewControllerAnimated(false)
|
46
|
+
|
47
|
+
wait 1 do
|
48
|
+
detector.did_dealloc?.should == true
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: teacup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -42,6 +42,7 @@ files:
|
|
42
42
|
- app/controllers/gradient_controller.rb
|
43
43
|
- app/controllers/landscape_only_controller.rb
|
44
44
|
- app/controllers/main_controller.rb
|
45
|
+
- app/controllers/memory_leak_controller.rb
|
45
46
|
- app/controllers/motion_layout_controller.rb
|
46
47
|
- app/controllers/present_modal_controller.rb
|
47
48
|
- app/controllers/table_view_controller.rb
|
@@ -140,6 +141,7 @@ files:
|
|
140
141
|
- spec/ios/layout_module_spec.rb
|
141
142
|
- spec/ios/layout_spec.rb
|
142
143
|
- spec/ios/main_spec.rb
|
144
|
+
- spec/ios/memory_leak_spec.rb
|
143
145
|
- spec/ios/motion_layout_spec.rb
|
144
146
|
- spec/ios/present_modal_spec.rb
|
145
147
|
- spec/ios/style_spec.rb
|
@@ -186,6 +188,7 @@ test_files:
|
|
186
188
|
- spec/ios/layout_module_spec.rb
|
187
189
|
- spec/ios/layout_spec.rb
|
188
190
|
- spec/ios/main_spec.rb
|
191
|
+
- spec/ios/memory_leak_spec.rb
|
189
192
|
- spec/ios/motion_layout_spec.rb
|
190
193
|
- spec/ios/present_modal_spec.rb
|
191
194
|
- spec/ios/style_spec.rb
|