I’m currently porting a software from root5 to root6. I’m experiencing an issue where the menuitem are not triggering the functions they are supposed to. I’m using the root API from a C++ compiled application. Menu items are declared like this in the C++ code:
laxmenu->AddFirst(new TClassMenuItem(
TClassMenuItem::kPopupUserFunction,claxis,"Zoom ALL X as last","URZoomAllXAsLast",0,"TObject*",0,0));
The function is declared in a header file:
void URZoomAllXAsLast(TObject* objaxis);
The dictionary is generated using this linkdef file:
(Segmentation fault is expected, the function does not check for NULL argument).
But in the application, a click on the corresponding menu item does not call the function. Any idea why the function is not connected to the click event ?
C:\root-dev\build\x64\debug\tutorials\gui>root -l customContextMenu.C
root [0]
Processing customContextMenu.C...
Info in <TCanvas::MakeDefCanvas>: created default TCanvas with name c1
root [1] URZoomAllXAsLast 1ba8ab55d40
Here is a simple example, using customContextMenu.c as a starting point: https:/ /github.com/EmmanuelP/root-test (Broken URL, new users are not allowed to post links )
Callbacks are not called in the compiled application, but it works when the menus are built from the root interpreter.
But this test failed with the following error after a click on the menu item:
IncrementalExecutor::executeFunction: symbol '_Z16URZoomAllXAsLastP7TObject' unresolved while linking [cling interface function]!
You are probably missing the definition of URZoomAllXAsLast(TObject*)
Maybe you need to load the corresponding shared library?
In the proxy test, URZoomAllXAsLast was not found due to name mangling being disabled by extern "C". The proxy workaround also works if I reenable C++ name mangling in callbacks.h.