maxmods / wx.mod

wxMax - wxWidgets binding for BlitzMax
Other
7 stars 5 forks source link

AppArgs not working with wxMax #44

Open peterigz opened 4 years ago

peterigz commented 4 years ago

Hello, for some reason the AppArgs array seems to be getting erased when using wxWidgets. Maybe there's a way to access them via wxWidgets with argc/argv but I couldn't figure out how. For example, this works fine without importing wx mod:

SuperStrict

Print "Number of arguments = "+AppArgs.length

For Local a:String = EachIn AppArgs
    Print a
Next

But this doesn't:


Framework wx.wxApp
Import wx.wxFrame

Type MyApp Extends wxApp

    Field frame:wxFrame

    Method OnInit:Int()

        frame = wxFrame.CreateFrame(,,"Hello World", 100, 100)
        frame.show()

        Print "Number of arguments = "+AppArgs.length

        For Local a:String = EachIn AppArgs
            Print a
        Next

        Return True

    End Method

End Type

New MyApp.run()

When launching each program on the command line with a few parameters, the first example returns all parameters fine, but the wx example only prints out 1 parameter (the command that executed the program)

It used to on previous versions of wxWidgets (or maybe previous MacOS version), but the latest versions seems to be affected. Not sure if this is a bug in wxWidgets or I just need to figure out where to get at the args in wxWidgets. This is on BlitzMaxNG MacOS Catalina. Thanks!

GWRon commented 4 years ago

Do you have old builds of your application - and do they work? Maybe it is an issue introduced by Catalina and not the libraries/built binaries.

Regarding wxWidgets and AppArgs.

The AppArgs for BlitzMax should be filled/loaded before the actual program (so usage of wxApp) are started up:

blitz.mod - blitz_app.c

void bbStartup( int argc,char *argv[],void *dummy1,void *dummy2 ){
[...]
    bbGCStartup();
    bbThreadStartup();
[...]

    for( k=0;k<argc;++k ){
        BBString *arg=bbStringFromCString( argv[k] );
        BBINCREFS( arg );
        *p++=arg;
    }

So .. it should normally not be affected by some wxWidgets stuff at all.

GWRon commented 4 years ago

You built a GUI application didn't you (not a "console" one - behaviour might change) ?

Maybe the wxApp instance now gets instantiated before bbStartup is run ?

Nonetheless "C wxApp" might provide access to argc and argv - but for now this is not exposed to the "Blitzmax wxApp". Maybe @woollybah could expose that - to for now allow a fallback to these arguments instead of the blitzmax ones.

https://docs.wxwidgets.org/3.0/overview_app.html

peterigz commented 4 years ago

Thanks, yes both the examples I put above are built with gui mode, as soon as wxApp is imported I can't seem to get those args.

I think it probably is something to do with Catalina as it worked ok before I started building the 64bit version. What that thing is though I'm not sure. Also works fine on windows.