Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-122996

Delegate definition should be in front of QGuiApplication but doing so sometimes makes reflection delegate unusable

    XMLWordPrintable

Details

    • macOS
    • d8371ebbd (dev), cbdd82039 (6.7), e7f00c064 (6.6), 92b32225c (tqtc/lts-6.5)

    Description

      Reproducer attached. Replace MACOSX_BUNDLE_INFO_PLIST with correct path before building. Use Xcode as generator.

      In main function, reflection delegate is set as:

          NSApplication * macOSApp = [NSApplication sharedApplication];
          AppDelegate * delegate = [[AppDelegate alloc] init];
          [macOSApp setDelegate: delegate];
      

      and it is after QGuiApplication being created. But somehow reflection delegate methods are working correctly. Application output:

      2024-03-05 18:31:53.264 OpenFile[3624:1277868] [MacOSOSProjectStructure]: main(int, char* []) | Thread.current = <_NSMainThread: 0x600002664080>{number = 1, name = main}
      2024-03-05 18:31:53.342 OpenFile[3624:1277868] [MacOSOSProjectStructure]: About to enter Qt's event loop..
      2024-03-05 18:31:53.343 OpenFile[3624:1277868] [MacOSOSProjectStructure]: applicationWillFinishLaunching(_:) | Thread.current = <_NSMainThread: 0x600002664080>{number = 1, name = main}
      2024-03-05 18:31:53.350 OpenFile[3624:1277868] [MacOSOSProjectStructure]: applicationDidFinishLaunching(_:) | Thread.current = <_NSMainThread: 0x600002664080>{number = 1, name = main}
      2024-03-05 18:31:53.350 OpenFile[3624:1277868] [MacOSOSProjectStructure]: TWFunc | Thread.current = <_NSMainThread: 0x600002664080>{number = 1, name = main}
      2024-03-05 18:31:54.995 OpenFile[3624:1277868] [MacOSOSProjectStructure]: applicationWillBecomeActive(_:) | Thread.current = <_NSMainThread: 0x600002664080>{number = 1, name = main}
      2024-03-05 18:31:54.996 OpenFile[3624:1277868] [MacOSOSProjectStructure]: applicationDidBecomeActive(_:) | Thread.current = <_NSMainThread: 0x600002664080>{number = 1, name = main}
      2024-03-05 18:31:58.333 OpenFile[3624:1277868] [MacOSOSProjectStructure]: applicationWillTerminate(_:) | Thread.current = <_NSMainThread: 0x600002664080>{number = 1, name = main}
      

      But if reflection delegate setup is moved to the beginning of main function, somehow some delegate methods are not invoked:

      2024-03-05 18:33:28.600 OpenFile[3742:1279543] [MacOSOSProjectStructure]: main(int, char* []) | Thread.current = <_NSMainThread: 0x6000033ac680>{number = 1, name = main}
      2024-03-05 18:33:28.633 OpenFile[3742:1279543] [MacOSOSProjectStructure]: About to enter Qt's event loop..
      2024-03-05 18:33:28.640 OpenFile[3742:1279543] [MacOSOSProjectStructure]: TWFunc | Thread.current = <_NSMainThread: 0x6000033ac680>{number = 1, name = main}
      2024-03-05 18:33:30.701 OpenFile[3742:1279543] [MacOSOSProjectStructure]: applicationWillBecomeActive(_:) | Thread.current = <_NSMainThread: 0x6000033ac680>{number = 1, name = main}
      2024-03-05 18:33:30.702 OpenFile[3742:1279543] [MacOSOSProjectStructure]: applicationDidBecomeActive(_:) | Thread.current = <_NSMainThread: 0x6000033ac680>{number = 1, name = main}
      2024-03-05 18:33:34.176 OpenFile[3742:1279543] [MacOSProjectStructure]: Exited from Qt's event loop with returnValue = 0 | Thread.current = <_NSMainThread: 0x6000033ac680>{number = 1, name = main}
      

      Particularly, applicationWillFinishLaunching, applicationDidFinishLaunching and applicationWillTerminate are missing.

      Environment is macOS14 + Xcode15. Strictly speaking, it is too new to be supported. Not sure of it is the problem.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            vestbo Tor Arne Vestbø
            luqiaochen Luqiao Chen
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: