[wxMac] Is it ok that my project works fine?

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
Post Reply
In need of some credit
In need of some credit
Posts: 1
Joined: Wed Feb 03, 2021 7:36 pm

[wxMac] Is it ok that my project works fine?

Post by nimoy » Wed Feb 03, 2021 8:14 pm

Hi, everyone.

I'm using wxwidgets in my project, which is plugin under Adobe application, i.e. my wxApp is defined with IMPLEMENT_APP_NO_MAIN.

I've already finished Windows version, which has been working for months without any problem and now I'm porting it to macOS.

First of all, I reinspected my code and find out only one vital Windows specific method — 'wxSetInstance()'. So I googled how could I replace it on macOS and came across 'wxApp::sm_isEmbedded = true' property. I don't know if it 100% relevant replacement, but being placed before 'wxInitialize()' it did it — plugin was compiled and worked at runtime as expected. Though I've got an error at '~wxMacAutoreleasePool()' when plugin was calling 'wxUninitialize()' on my attempt to close main Adobe application.

vmplayer_2021-02-04_03-38-58.png (44.08 KiB) Viewed 4955 times

Looking at [NSAutoreleasePool release] I saw this message about double release.

vmplayer_2021-02-04_03-52-27.png (30.97 KiB) Viewed 4955 times

My suggestion was that somehow (though I don't understand why), my wxApp was already cleaned up at the moment of 'wxUninitialize()' call. So I commented out that call and now it seems like all is operating just fine — Adobe application exits with 0 status code.

My questions are

1. Is 'wxApp::sm_isEmbedded = true' suffice to tell wxApp that it's operating under other non-wx application on macOS? Should I expect any problem?

2. Is it even acceptable to skip 'wxUnitialize()' if 'wxInitialize()' has been called previously? Common sense and docs are saying no, 'wxUninitialize()' must be called for each successful call to 'wxInitialize()'. But why then I don't get any errors and how, in the first place, wxApp gets released before 'wxUninitialize()'?

p.s. I'm developing macOS version under Virtual Machine if it matters.

macOs Catalina 10.15, wxWidgets 3.1.3 were configured with

../configure --with-osx_cocoa --disable-shared --enable-debug --enable-unicode --with-macosx-sdk=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk --with-macosx-version-min=10.11 CXX=clang++

Post Reply