mirror of
https://github.com/zhigang1992/ProMotion.git
synced 2026-04-23 20:00:52 +08:00
Fix issue #368 where opening a screen twice from the same parent would cause a crash.
This commit is contained in:
9
Rakefile
9
Rakefile
@@ -10,3 +10,12 @@ Motion::Project::App.setup do |app|
|
||||
app.device_family = [ :ipad ] # so we can test split screen capability
|
||||
app.detect_dependencies = true
|
||||
end
|
||||
|
||||
namespace :spec do
|
||||
task :unit do
|
||||
App.config.spec_mode = true
|
||||
spec_files = App.config.spec_files - Dir.glob('./spec/functional/**/*.rb')
|
||||
App.config.instance_variable_set("@spec_files", spec_files)
|
||||
Rake::Task["simulator"].invoke
|
||||
end
|
||||
end
|
||||
|
||||
@@ -70,6 +70,7 @@ module ProMotion
|
||||
PM.logger.error "You need a nav_bar if you are going to push #{vc.to_s} onto it."
|
||||
end
|
||||
nav_controller ||= self.navigationController
|
||||
return if nav_controller.topViewController == vc
|
||||
vc.first_screen = false if vc.respond_to?(:first_screen=)
|
||||
nav_controller.pushViewController(vc, animated: animated)
|
||||
end
|
||||
|
||||
@@ -212,6 +212,20 @@ describe "screen helpers" do
|
||||
screen.should == new_screen
|
||||
end
|
||||
|
||||
it "should not double-open a view controller if it's already been opened" do
|
||||
parent_screen = HomeScreen.new(nav_bar: true)
|
||||
new_screen = BasicScreen.new
|
||||
@pushed = 0
|
||||
parent_screen.navigationController.mock!("pushViewController:animated:") do |vc, animated|
|
||||
@pushed += 1
|
||||
parent_screen.navigationController.stub!("topViewController", return: vc)
|
||||
end
|
||||
parent_screen.open new_screen
|
||||
@pushed.should == 1
|
||||
parent_screen.open new_screen
|
||||
@pushed.should == 1
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user