Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash when displaying InfoDialog on iOS #2039

Closed
Casimir1965 opened this issue Jul 19, 2023 · 1 comment · Fixed by #2041
Closed

Crash when displaying InfoDialog on iOS #2039

Casimir1965 opened this issue Jul 19, 2023 · 1 comment · Fixed by #2041
Labels
bug A crash or error in behavior. good first issue Is this your first time contributing? This could be a good place to start! iOS The issue relates to Apple iOS mobile support.

Comments

@Casimir1965
Copy link

Casimir1965 commented Jul 19, 2023

Describe the bug

InfoDialog could not be called from a Button on iOS

Steps to reproduce

  1. Run the dialogs example
  2. Click on any of the buttons that display a dialog
  3. See error:
Traceback (most recent call last):
  File "/Users/carstenschmidt/Library/Developer/CoreSimulator/Devices/DDAB8D40-4B82-42E8-840A-DAC5BA41273C/data/Containers/Bundle/Application/4EBA5383-22B3-4BF3-B5A9-4E0DB9B3F918/ToolBox.app/app_packages/rubicon/objc/api.py", line 334, in __call__
    result = self.py_method(py_self, *args)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/carstenschmidt/Library/Developer/CoreSimulator/Devices/DDAB8D40-4B82-42E8-840A-DAC5BA41273C/data/Containers/Bundle/Application/4EBA5383-22B3-4BF3-B5A9-4E0DB9B3F918/ToolBox.app/app_packages/toga_iOS/widgets/button.py", line 22, in onPress_
    self.interface.on_press(None)
  File "/Users/carstenschmidt/Library/Developer/CoreSimulator/Devices/DDAB8D40-4B82-42E8-840A-DAC5BA41273C/data/Containers/Bundle/Application/4EBA5383-22B3-4BF3-B5A9-4E0DB9B3F918/ToolBox.app/app_packages/toga/handlers.py", line 65, in _handler
    result = handler(interface, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/carstenschmidt/Library/Developer/CoreSimulator/Devices/DDAB8D40-4B82-42E8-840A-DAC5BA41273C/data/Containers/Bundle/Application/4EBA5383-22B3-4BF3-B5A9-4E0DB9B3F918/ToolBox.app/app/toolbox/app.py", line 624, in show_not_function
    self.main_window.info_dialog(
  File "/Users/carstenschmidt/Library/Developer/CoreSimulator/Devices/DDAB8D40-4B82-42E8-840A-DAC5BA41273C/data/Containers/Bundle/Application/4EBA5383-22B3-4BF3-B5A9-4E0DB9B3F918/ToolBox.app/app_packages/toga/window.py", line 287, in info_dialog
    self.factory.dialogs.InfoDialog(
  File "/Users/carstenschmidt/Library/Developer/CoreSimulator/Devices/DDAB8D40-4B82-42E8-840A-DAC5BA41273C/data/Containers/Bundle/Application/4EBA5383-22B3-4BF3-B5A9-4E0DB9B3F918/ToolBox.app/app_packages/toga_iOS/dialogs.py", line 83, in __init__
    super().__init__(interface, title, message, on_result=on_result)
  File "/Users/carstenschmidt/Library/Developer/CoreSimulator/Devices/DDAB8D40-4B82-42E8-840A-DAC5BA41273C/data/Containers/Bundle/Application/4EBA5383-22B3-4BF3-B5A9-4E0DB9B3F918/ToolBox.app/app_packages/toga_iOS/dialogs.py", line 31, in __init__
    interface.window._impl.controller.presentViewController(
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'MainWindow' object has no attribute 'controller'

Expected behavior

InfoDialog should be displayed.

Screenshots

I believe this is not needed

Environment

  • Operating System: iOS
  • Python version: any
  • Software versions:
    • Briefcase: 0.3.15
    • Toga: 5d9a077 (0.3.1+)
    • ...

Logs


Additional context

This problem was introduced by #1969. The fix is relatively simple:

diff --git a/iOS/src/toga_iOS/dialogs.py b/iOS/src/toga_iOS/dialogs.py
index a0a8bce38..1448bf8fa 100644
--- a/iOS/src/toga_iOS/dialogs.py
+++ b/iOS/src/toga_iOS/dialogs.py
@@ -28,7 +28,7 @@ class AlertDialog(BaseDialog):
 
         self.populate_dialog()
 
-        interface.window._impl.controller.presentViewController(
+        interface.window._impl.native.rootViewController.presentViewController(
             self.native,
             animated=False,
             completion=None,
@Casimir1965 Casimir1965 added the bug A crash or error in behavior. label Jul 19, 2023
@freakboy3742 freakboy3742 added iOS The issue relates to Apple iOS mobile support. good first issue Is this your first time contributing? This could be a good place to start! labels Jul 19, 2023
@freakboy3742 freakboy3742 changed the title [iOS] - After pressing a generated button no InfoDialog can be properly shown. Function is working on dev, MacOS and Android properly. Crash when displaying InfoDialog on iOS Jul 19, 2023
@Cheukting
Copy link
Contributor

I will have a look at this :-)

Cheukting added a commit to Cheukting/toga that referenced this issue Jul 22, 2023
freakboy3742 added a commit that referenced this issue Jul 22, 2023
Fixing dialog clashing on iOS bug (#2039)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A crash or error in behavior. good first issue Is this your first time contributing? This could be a good place to start! iOS The issue relates to Apple iOS mobile support.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants