Cruisers & Sailing Forums (http://www.cruisersforum.com/forums/)
-   OpenCPN (http://www.cruisersforum.com/forums/f134/)
-   -   PlugIn LateInit (http://www.cruisersforum.com/forums/f134/plugin-lateinit-160982.html)

jongough 11-02-2016 00:59

PlugIn LateInit
 
Hi,
One of the options available to plugins is to request a 'Late Init', where OCPN will call this function at the end of initialisation when all the other stuff has been completed. Looking in the pluginmanager code it would appear that this function call is only available in version 1.10 of the plugin API. Is there a reason for this or is it just an oversight?

I would like to make use of this function in OD to do some work when I know that the rest of OCPN is up and running.

Jon

bdbcat 11-02-2016 07:58

Re: PlugIn LateInit
 
jon...

PlugIn APIs are cumulative. So whatever exists in v110 carries forward to all later API versions. Note how each PlugIn version class derives from the previous one.

Code:

class DECL_EXP opencpn_plugin_110 : public opencpn_plugin_19
{
    public:
            opencpn_plugin_110(void *pmgr);
            virtual ~opencpn_plugin_110();

            virtual void LateInit(void); // If WANTS_LATE_INIT is returned by Init()
};

class DECL_EXP opencpn_plugin_111 : public opencpn_plugin_110
{
public:
    opencpn_plugin_111(void *pmgr);
    virtual ~opencpn_plugin_111();
   
};

So, this function should be available to you now.

Dave

jongough 11-02-2016 12:06

Re: PlugIn LateInit
 
Dave,
Except for:
Code:

        switch(pic->m_api_version)
        {
            case 110:
                if(pic->m_cap_flag & WANTS_LATE_INIT) {
                    wxString msg(_T("PlugInManager: Calling LateInit PlugIn: "));
                    msg += pic->m_plugin_file;
                    wxLogMessage(msg);

                    opencpn_plugin_110* ppi = dynamic_cast<opencpn_plugin_110*>(pic->m_pplugin);
                    ppi->LateInit();
                    }
                break;
        }

in PlugInManager::CallLateInit which only does the late init for version1.10.
Other PlugIn 'wants' have multiple case statements to handle new versions.

I can provide a patch for this if that is OK.

Jon

bdbcat 11-02-2016 14:29

Re: PlugIn LateInit
 
jon...

Sure, missed that spot.

Patch acceptable. I may do a 4.2.1 Release in a couple of weeks.

But I certainly would not code your PlugIn so that it depends on this function. O42 is what it is, bugs and all. PlugIn makers will need to work around the bugs externally.

Dave

jongough 11-02-2016 17:15

Re: PlugIn LateInit
 
Dave,
I would like to use this facility but it is not critical or even really required at the moment (I thought it was going to be due to a couple of crashes, but I have worked around that) for OD. I have put up a pull request for the change.

Jon


All times are GMT -7. The time now is 23:18.

Powered by vBulletin® Version 3.8.8 Beta 1
Copyright ©2000 - 2019, vBulletin Solutions, Inc.


ShowCase vBulletin Plugins by Drive Thru Online, Inc.