Skip to content
This repository was archived by the owner on Nov 19, 2025. It is now read-only.

Commit 68d1714

Browse files
committed
Merge pull request #742 from kayhide/bugfix/parent-screen-weakref
Fix parent_screen weak ref bug.
2 parents 8314ed6 + d10e17b commit 68d1714

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

lib/ProMotion/screen/screen_module.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ module ScreenModule
77
include ProMotion::Tabs
88
include ProMotion::SplitScreen if UIDevice.currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad || (UIDevice.currentDevice.systemVersion.to_i >= 8 )
99

10-
attr_accessor :parent_screen, :first_screen, :modal, :split_screen
10+
attr_reader :parent_screen
11+
attr_accessor :first_screen, :modal, :split_screen
1112

1213
def screen_init(args = {})
1314
@screen_options = args
@@ -154,7 +155,7 @@ def frame
154155
def add_child_screen(screen)
155156
screen = screen.new if screen.respond_to?(:new)
156157
addChildViewController(screen)
157-
screen.parent_screen = WeakRef.new(self)
158+
screen.parent_screen = self
158159
screen.didMoveToParentViewController(self) # Required
159160
screen
160161
end

spec/unit/screen_spec.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,9 @@
449449
end
450450

451451
it "#add_child_screen" do
452-
@screen.add_child_screen @child
452+
autorelease_pool do
453+
@screen.add_child_screen @child
454+
end
453455
@screen.childViewControllers.should.include(@child)
454456
@screen.childViewControllers.length.should == 1
455457
@child.parent_screen.should == @screen

0 commit comments

Comments
 (0)