Opened 7 years ago

Closed 3 years ago

Last modified 3 years ago

#15432 closed defect (fixed)

Remove -psn_* from argv also in src/gtk/app.cpp

Reported by: mojca Owned by: vadz
Priority: normal Milestone:
Component: wxGTK Version:
Keywords: Cc: mojca.miklavec.lists@…
Blocked By: Blocking:
Patch: no

Description

I'm working or repackaging of applications that depend on wxWidgets in MacPorts. Some applications don't work with 2.9, so I had to use wxGTK 2.8 to make them compile on a recent Mac OS X. However after bundling the applications, some of them failed to start:

LSOpenURLsWithRole() failed with error -10810 for the file /Applications/MacPorts/SomeApp.app

After inspecting in Console.app it turned out that the app refused to run because of

Unknown option 'psn_0_2372163'

Would it be possible to add the same code as in carbon and cocoa also to src/gtk/app.cpp?

    // Mac OS X passes a process serial number command line argument when
    // the application is launched from the Finder. This argument must be
    // removed from the command line arguments before being handled by the
    // application (otherwise applications would need to handle it)
    if ( argc > 1 )
    {
        static const wxChar *ARG_PSN = _T("-psn_");
        if ( wxStrncmp(argv[1], ARG_PSN, wxStrlen(ARG_PSN)) == 0 )
        {
            // remove this argument
            --argc;
            memmove(argv + 1, argv + 2, argc * sizeof(char *));
        }
    }

While this would make most sense in the 2.8 series which probably won't see another release, it might still make some sense to add it to GTK of 2.9/3.0 as well. I will patch wxWidgets locally to make the apps work in any case.

PS: I need to add that after this patch the app still didn't start 100% OK (it kept bouncing in the dock and I wasn't able to quit it by right-clicking the dock and choosing Quit, but the app itself worked flawlessly). I only tested with 2.8 so far, but I think that the same applies to both 2.8 and 2.9.

PPS: I don't know whether this would also apply to wxX11. I didn't test with that one.

Attachments (2)

wxosx-darwin.diff download (819 bytes) - added by mojca 7 years ago.
a patch to replace WXOSX with DARWIN
psn-cocoa.diff download (974 bytes) - added by mojca 7 years ago.
not very well tested patch to remove psn handling from cocoa now that it's in generic code

Download all attachments as: .zip

Change History (10)

comment:1 Changed 7 years ago by VZ

  • Resolution set to fixed
  • Status changed from new to closed

(In [74703]) Move code removing "-psn_xxx" command line arguments to common code.

We need to do this when using any port under OS X, not just wxOSX, e.g. the
-psn_xxx arguments passed by the Finder when launching the application, must
also be ignored when using wxGTK.

Closes #15432.

comment:2 Changed 7 years ago by mojca

Thank you.

Btw, there is the same chunk of code in src/cocoa/app.mm, not just in carbon.

(There is also a piece of code checking for wxT("-NS"); in case that a similar report pops up in future, but I'm not exactly sure how to trigger those flags.)

Changed 7 years ago by mojca

a patch to replace WXOSX with DARWIN

comment:3 Changed 7 years ago by mojca

  • Resolution fixed deleted
  • Status changed from closed to reopened

Can you please fix the code with the attached patch wxosx-darwin.diff? The commit r74703 namely only works for Carbon and Cocoa, but not for wxGTK under Mac OS X which was the reason for moving the code the first place.

Changed 7 years ago by mojca

not very well tested patch to remove psn handling from cocoa now that it's in generic code

comment:4 Changed 7 years ago by mojca

The second question is low priority and I also didn't perform sufficient testing yet: why has the code only been removed from Carbon, but not from Cocoa? See the attached patch psn-cocoa.diff. Does that patch make any sense?

comment:5 Changed 3 years ago by vadz

  • Owner set to vadz
  • Status changed from reopened to accepted

Really sorry for the delay, I'm finally going to apply the patch from comment:3 soon. As for the comment:4, this code got completely removed in the meanwhile, so it's not a problem any more.

comment:6 Changed 3 years ago by Vadim Zeitlin <vadim@…>

  • Resolution set to fixed
  • Status changed from accepted to closed

In 1cf41eced/git-wxWidgets:

Use DARWIN for -psn command line argument test

This code should be used in all ports that can be used under macOS, i.e.
also wxGTK and not just wxMac.

Closes #15432.

comment:7 Changed 3 years ago by mojca

  • Cc mojca.miklavec.lists@… added

Thank you very much. May I request backporting the patch also to WX_3_0_BRANCH?

comment:8 Changed 3 years ago by Vadim Zeitlin <vadim@…>

In 18f62b77/git-wxWidgets:

Use DARWIN for -psn command line argument test

This code should be used in all ports that can be used under macOS, i.e.
also wxGTK and not just wxMac.

See #15432.

(cherry picked from commit 1cf41eced6590f9f06bb3b2e0da09aeb323cb138)

Note: See TracTickets for help on using tickets.