Subclass the Application

Im having trouble getting MBS plugins to ‘stay registered’
When double clicking a document for the second time, MBS says its been used before registration.

Im sure thats not true.

MBS docs suggest subclassing the app to ensure registration happens first

I can see how to add a class and subclass Application, but can’t see how to make that ‘the’ app, or to ensure that its methods and events happen before anything else.

Any advice on the use (and purpose) of a subclassed app?

[quote=132248:@Jeff Tullin]Im having trouble getting MBS plugins to ‘stay registered’
When double clicking a document for the second time, MBS says its been used before registration.

Im sure thats not true.

MBS docs suggest subclassing the app to ensure registration happens first

I can see how to add a class and subclass Application, but can’t see how to make that ‘the’ app, or to ensure that its methods and events happen before anything else.

Any advice on the use (and purpose) of a subclassed app?[/quote]

Why not simply place the registration code at the top of the app Open event ?

the class named app in your project is already the application subclass!

It literally is the first statement in app.open
The app is well open by the time a second document has been double clicked upon, too.

Thats what I thought. The MBS docs say :

which implied that there might be something else in play.

Since the register is the first line of the app, I don’t understand how a second opendocument event could be using a plugin before registration.

I have trouble understanding what you describe. Is it anything like :

  • Application launches OK
  • You double click on a document, and get a message. How ? Msgbox ? What is the exact message ?

At any rate, Christian will probably be able to assist.

In the code he sent me, there is

if not registerMBSPlugin(things) then MsgBox "MBS Plugin serial not valid?" end if

Is it the kind of message you are getting or something else ?

Ive added some message boxes.
The message box is coming from the plugins themselves. You will see the same message I am seeing if you omit the register completely and run a compiled app.
Registration returns true: it does work properly.

In the last couple of minutes I seem to have identified that the problem happens if the registration happens twice.
First time it works, second time I get the ‘used before registering’ message and then the registration succeeds.
So the trick will be to ensure that registration occurs only once no matter how the app is started.

[quote=132294:@Jeff Tullin]Ive added some message boxes.
The message box is coming from the plugins themselves. You will see the same message I am seeing if you omit the register completely and run a compiled app.
Registration returns true: it does work properly.

In the last couple of minutes I seem to have identified that the problem happens if the registration happens twice.
First time it works, second time I get the ‘used before registering’ message and then the registration succeeds.
So the trick will be to ensure that registration occurs only once no matter how the app is started.[/quote]

You mean :

MBS Xojo Plugins This application uses unregistered plugins from Monkeybread Software. Please inform the developer of this application that they need to purchase a license from Monkeybread Software to remove this message. Thank you. (Picture: ScreenshotMBS, Version 14.3 from Jul 2 2014, Process ID: 2841)

I do not quite understand how the app Open event can execute twice. But you could use a boolean app property and set it to true when you register the first time around, like this

if not registered then //register code registerMBSPLugins() register = True end if

Oddly no.

So a different message to ‘not registered at all’.
Seems the plugins know they have been used.
Probably no point in them displaying this message, but I worked around it with something very like your method.

I created an INIT method, and a bInitialised variable.
And I set that to true when the register is called.

All MBS calls are prefixed by
if not app.bInitialised then app.Init