Crash calling App_AllowsAutomaticWindowTabbing

  1. 3 months ago

    Hi,
    some of my apps, in the app's open event had this code:
    App_AllowsAutomaticWindowTabbing(false)

    Now, after wrapping such apps with App Wrapper 3 (3.9), the app crashes as soon as launched with the friendly system-message:

    An exception of class FunctionNotFoundException was not handled. The app must shut down.

    Wrapping the app with App Wrapper 3 (3.8) no exception was raised.

    Now, to be honest, I don't even know why I used such function, so I'm ready to drop the call App_AllowsAutomaticWindowTabbing(false), yet I'd like at least to know if there is any way to keep it without firing the exception.
    Who knows, maybe there is somebody else who, using this code, after wrapping his/her app finds it crashing.

    Suggestions welcome. Thank you.

    BTW: The snippet below was taken from the forum.

    Public Sub App_AllowsAutomaticWindowTabbing(pbAllowTabGrouping As Boolean)
      #if TargetMacOS and TargetCocoa then
        Soft Declare Function objc_getClass lib "libobjc.dylib" (name As CString) As Ptr
        Soft Declare Function sel_registerName lib "libobjc.dylib" (name As CString) As Ptr
        Soft Declare Function RespondsToSelector Lib "Cocoa" selector "respondsToSelector:" (target As Ptr, Sel As Ptr) As Boolean
        
        Dim nsWindowClass As Ptr = objc_getClass("NSWindow")
        if RespondsToSelector(nsWindowClass, sel_registerName("setAllowsAutomaticWindowTabbing:")) then
          Soft Declare Sub AllowTabGrouping lib "AppKit" selector "setAllowsAutomaticWindowTabbing:" (classPtr As Ptr, enableDisable As Boolean)
          AllowTabGrouping(nsWindowClass, pbAllowTabGrouping)
        end if
      #endif
    End Sub

    the code I use is not exactly the same (note, my version turns it OFF, but that is easy to change)

    //
    // Disable auto tabbing in Sierra
    #If TargetCocoa
    Declare Function NSClassFromString Lib "Cocoa" (s As CFStringRef) As Ptr
    Declare Function NSSelectorFromString Lib "Cocoa" (s As CFStringRef) As Ptr
    Declare Sub setAllowsAutomaticWindowTabbing Lib "Cocoa" selector "setAllowsAutomaticWindowTabbing:" (cls As Ptr, ena As Boolean)
    Declare Function respondsToSelector Lib "Cocoa" selector "respondsToSelector:" (p As Ptr, sel As Ptr) As Boolean
    Dim nswCls As Ptr = NSClassFromString ("NSWindow")
    If respondsToSelector (nswCls, NSSelectorFromString ("setAllowsAutomaticWindowTabbing:")) Then
    setAllowsAutomaticWindowTabbing (nswCls, False) // change to a flag to turn it on or off
    End If
    #EndIf
  2. Dave S

    May 20 Answer San Diego, California USA

    the code I use is not exactly the same (note, my version turns it OFF, but that is easy to change)

    //
    // Disable auto tabbing in Sierra
    #If TargetCocoa
    Declare Function NSClassFromString Lib "Cocoa" (s As CFStringRef) As Ptr
    Declare Function NSSelectorFromString Lib "Cocoa" (s As CFStringRef) As Ptr
    Declare Sub setAllowsAutomaticWindowTabbing Lib "Cocoa" selector "setAllowsAutomaticWindowTabbing:" (cls As Ptr, ena As Boolean)
    Declare Function respondsToSelector Lib "Cocoa" selector "respondsToSelector:" (p As Ptr, sel As Ptr) As Boolean
    Dim nswCls As Ptr = NSClassFromString ("NSWindow")
    If respondsToSelector (nswCls, NSSelectorFromString ("setAllowsAutomaticWindowTabbing:")) Then
    setAllowsAutomaticWindowTabbing (nswCls, False) // change to a flag to turn it on or off
    End If
    #EndIf
  3. Fine, now after wrapping the app, no crash.
    Thank you.

  4. Sam R

    May 21 Pre-Release Testers, Xojo Pro Hengchun, Pingtung, Taiwan

    By default App Wrapper 3.9 uses the new "Hardened Runtime" option as it will at some point become required.

    My guess is that the new security is preventing your application from directly accessing "libobjc.dylib".

or Sign Up to reply!