How to handle custom TBrowser plugin

Dear ROOT community,

I was need to use the custom GUI command widget similar to one provided by default TRootBrowser class (i.e. the TGCommandPlugin).
My minor improvements includes stripping of the ANSI sequences generated by Clang, redirection the my logging streams and so on.

Thus, in short, my question is “Which way of extending TBrowser class is legitimate (proper for ROOT API)?”.

Considering some promising method names like TBroser::InitPlugins() I was expecting that there is an extension point where one can provide an implementation of, e.g., custom TGCommandPlugin.
However, the TRootBrowser::InitPlugins method only uses plain style of option string parsing, char-by-char invoking hardcoded commands to CLING wrapped in TBrowserPlugin helper.

So I assume that there is no way to extend these TBrowser’s “plugins” in a way the global TPluginManager facility is implemented.
But I noticed the comment in sources containing the following snippet:

   // Initialize default plugins. Could be also of the form:
   // StartEmbedding(0);
   // TPluginHandler *ph;
   // ph = gROOT->GetPluginManager()->FindHandler("TGClassBrowser");
   // if (ph && ph->LoadPlugin() != -1) {
   //    ph->ExecPlugin(3, gClient->GetRoot(), 200, 500);
   // }
   // StopEmbedding();

which clearly claims an opportunity for integration with TPluginManager. This snippet is commented out and I was unable to find similar things around in sources.

So copuld someone, please, clarify my understanding of plugin mechanism implemented in TRootBrowser?

Thank you.
(root v 6.0.4)

Just in case someone will be interested, here is the way I implemented it now (actually target class is actually TEveBrowser, the descendant of TRootBrowser). This is just a workaround at the user side so I’m still will be grateful if someone will advise me a proper way.

Considering the class CustomCommandPlugin <- TGCommandPlugin:

# include "CustomCommandPlugin.h"

// ...

TPluginHandler * ph;
ph = gPluginMgr->FindHandler( "TGCommandPlugin" );
if( ph && -1 != ph->LoadPlugin() ) {
    TEveManager::Create( kTRUE, "FV" );
    gEve->GetBrowser()->StartEmbedding(2); {
        Long_t rc = ph->ExecPlugin( 0, gClient->GetRoot(), 200, 500 );
    } gEve->GetBrowser()->StopEmbedding();
    if( rc ) {
        TObject * p = (TObject *) rc;
        auto * cPl = static_cast<CustomCommandPlugin *>( p );
        // ... Initialize extended functions like binding
        // ... logging streams, re-setting font, etc with
        // ... an instance pointed by cPl
    } else {
        // ... log error "Failed to create custom command widget. "
        //               "Plugin was loaded, but ctr returned NULL."
    }
} else {
    // Use default TGCommandPlugin class, if unable to load the
    // custom plugin:
    TEveManager::Create( kTRUE, "FIV" );
}

However it seems to me that I’ve faced with a known issue as my stack traces in gdb and valgrind looks pretty similar (unfortunately I can not use ROOT build with dbg info for now). I’ve tried to specify plugin handler by gPluginMgr->AddHandler() and via the local resource file provided within TEnv handled by gPluginMgr->LoadHandlersFromEnv().
gdb-stacktrace.txt (3.41 KB)
valgrind-stacktrace.txt (4.71 KB)