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
wxOSX Cocoa: A problem with starting the application when using UIElement. #23893
Comments
Sorry, I have no idea what is Also, under Mac |
UIElement's full name is More detailed description from Apple As for the second part of your answer, I will deal with it now. |
It would make sense if the applications with |
Just got to the computer, it seems that the problem is in the |
I found out that after the I tried to use another parameter Although if you execute |
I am seeing the same issue on macOS 12.6.6 Monterey and wxWidgets 3.1.4. As @DiCode77 says, the app never returns from [NSApp run] and OnInit is not called. My workaround currently is to overwrite wxApp::CallOnInit() and activate the app before calling the base implementation:
I have tested this also in Sonoma and it seems to resolve the issue. |
@csomor Does your "like" above mean that this workaround should be applied? |
;-) I have to read a little bit more before I can give the OK, but I appreciate the effort |
@DiCode77 @kamenkitanov thanks for your efforts, I've tried to move this into a minimal change PR #24003, could you please test whether this solves the problem for you as well ? Thanks |
@csomor Hi, thanks for the fix, ran some tests, with normal launch and auto launch, the app opens properly, it seems to have fixed the problem! |
Thank you all for quickly applying the fix and for testing/reporting the issue. The fix works for me too, with the caveat I am not on the latest wxWidgets version yet. |
Platform and version information
I would like to note in advance that this error does not exist on macOS Ventura or older systems, the problem appears starting with macOS Sonoma.
Description of the problem
The problem is that when I use (UIElement == true), the app only starts on the second try (the UI is rendered).
That is, after the first attempt, only a process is created in the system, but the program does not show signs that it has started.
After the second attempt to start the program, the same process starts working, the program interface appears.
I want to emphasize that it is not important how you try to launch the program, either with the cursor, or by adding it to the autorun in the system.
With UIElement disabled, the application starts on the first try.
Trying to identify the problem.
I will note right away that if the application is debugged or only launched through the IDE (Xcode), then the problem does not manifest itself, that is, the launch occurs on the first try.
By the method of research, I understood that the problem is that the
virtual bool OnInit()
method is not called.That is, for example, the
MyApp()
constructor works in this class, but theOnInit
method does not.That is, we can conclude that when we pass the
MyApp
class to the macro, after creating the object, theOnInit()
method is not called in wxWidgets itself, and this is the problem.Workaround method
The first option is to call the
OnInit()
method in theMyApp()
constructor, you just need to change the OnInit name, otherwise two application interfaces can be created at once.The second option, this is the classic method, run via
int main()
, manually create an object of the MyApp class, then call theOnRun
function, in this case the program will also start the first time.Therefore, it is necessary to fix a bug where the OnInit() method is not called by the wxIMPLEMENT_APP macro, if (UIElement == true) is used.
The text was updated successfully, but these errors were encountered: