MCPcopy Create free account
hub / github.com/FreeCAD/FreeCAD / setupContextMenu

Method setupContextMenu

src/Gui/ViewProviderFeaturePython.cpp:615–649  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

613}
614
615bool ViewProviderFeaturePythonImp::setupContextMenu(QMenu* menu)
616{
617 _FC_PY_CALL_CHECK(setupContextMenu, return (false));
618
619 // Run the attach method of the proxy object.
620 Base::PyGILStateLocker lock;
621 try {
622 if (has__object__) {
623 PythonWrapper wrap;
624 wrap.loadGuiModule();
625 wrap.loadWidgetsModule();
626 Py::Tuple args(1);
627 args.setItem(0, wrap.fromQWidget(menu, "QMenu"));
628 return Base::pyCall(py_setupContextMenu.ptr(), args.ptr()).isTrue();
629 }
630 else {
631 PythonWrapper wrap;
632 wrap.loadGuiModule();
633 wrap.loadWidgetsModule();
634 Py::Tuple args(2);
635 args.setItem(0, Py::Object(object->getPyObject(), true));
636 args.setItem(1, wrap.fromQWidget(menu, "QMenu"));
637 return Base::pyCall(py_setupContextMenu.ptr(), args.ptr()).isTrue();
638 }
639 }
640 catch (Py::Exception&) {
641 if (PyErr_ExceptionMatches(PyExc_NotImplementedError)) {
642 PyErr_Clear();
643 return false;
644 }
645 Base::PyException e; // extract the Python error text
646 e.reportException();
647 }
648 return true;
649}
650
651void ViewProviderFeaturePythonImp::attach(App::DocumentObject* pcObject)
652{

Callers

nothing calls this directly

Calls 8

pyCallFunction · 0.85
loadGuiModuleMethod · 0.80
loadWidgetsModuleMethod · 0.80
fromQWidgetMethod · 0.80
ObjectClass · 0.70
ptrMethod · 0.45
getPyObjectMethod · 0.45
reportExceptionMethod · 0.45

Tested by

no test coverage detected