MapWindow 4 - Plugins : MapWindow Discussion Forum
Ok I was examining the routines and when they are called and in what order so I could figure out where to put the initial resource management calls so that me plug-in can be localized and noticed a interesting effect. If you take a blank plug-in template and put a debug.writeline in
Initialization process of a Plug-in, AddMenu and possible bug?
Posted by: fskrotzki ()
Date: February 02, 2010 01:29PM

Ok I was examining the routines and when they are called and in what order so I could figure out where to put the initial resource management calls so that me plug-in can be localized and noticed a interesting effect.

If you take a blank plug-in template and put a debug.writeline in each routine, you will come to find out that some of these routines are called MANY times when I really only see the need for them to be called once or twice.

At the start of MapWindow this happens:

MapWindow.Interfaces.IPlugin.Author
MapWindow.Interfaces.IPlugin.BuildDate
MapWindow.Interfaces.IPlugin.Description
MapWindow.Interfaces.IPlugin.Name
MapWindow.Interfaces.IPlugin.Version

When a plug-in is initialized this happens next
MapWindow.Interfaces.IPlugin.Initialize

Now for each and every you call AddMenu it then calls the following series again
MapWindow.Interfaces.IPlugin.Author
MapWindow.Interfaces.IPlugin.BuildDate
MapWindow.Interfaces.IPlugin.Description
MapWindow.Interfaces.IPlugin.Name
MapWindow.Interfaces.IPlugin.Version

Is it really nessary to call over and over each of these when adding a menu item? It would seem a huge waste of code and CPU time.

Now I started this looking for the one function that was called first and only once so that I could use that to initialize my resources for the proper language and then use that so that when MapWindow.Interfaces.IPlugin.Description was called we could return it in the localized string instead of English all the time. But having these routines called over and over makes having to include checking so that we don't keep creating new resource hooks amoung other things.

Since MapWindow.Interfaces.IPlugin.Description is called before the plug-in routine MapWindow.Interfaces.IPlugin.Initialize is called that was clearly not the proper place to be calling setting that up and calling it.

Is this supposed to work that way or is this actually a bug?

Options: ReplyQuote


Sorry, only registered users may post in this forum.





Banner Exchange




GISCP.com




Send us your banner logo (160x120) for the space above, and add this MapWindow banner ad to your site:

Just paste this text in your page: