infinitered/rmq

Infinite loop when getting rmq.view_controller from a tab bar screen using the more tab.

Opened this issue · 0 comments

See demo repository here: https://github.com/markrickert/rmq.view_controller

Steps to reproduce:

  1. bundle
  2. rake
  3. Type into the REPL: rmq.view_controller.
  4. Switch to a new tab and try again.
  5. Switch to the "more" tab and try again. Notice it returns a UIMoreListController.
  6. Tap into a view controller in the more tab and try again.
  7. Crash.

Crashlog produces what looks like an infinite loop. Possible offending code here:

def current_view_controller(root_view_controller = nil)
if root_view_controller || ((window = RMQ.app.window) && (root_view_controller = window.rootViewController))
case root_view_controller
when UINavigationController
current_view_controller(root_view_controller.visibleViewController)
when UITabBarController
current_view_controller(root_view_controller.selectedViewController)
else
if root_view_controller.respond_to?(:visibleViewController)
current_view_controller(root_view_controller.visibleViewController)
elsif root_view_controller.respond_to?(:topViewController)
current_view_controller(root_view_controller.topViewController)
elsif root_view_controller.respond_to?(:frontViewController)
current_view_controller(root_view_controller.frontViewController)
elsif root_view_controller.respond_to?(:center) && (center = root_view_controller.center) && center.is_a?(UIViewController)
current_view_controller(root_view_controller.center)
elsif root_view_controller.respond_to?(:childViewControllers) && root_view_controller.childViewControllers.count > 0
current_view_controller(root_view_controller.childViewControllers.first)
else
root_view_controller
end
end
end
end

Note that it also crashes when you just type rmq into the REPL so it may be a more overarching problem.