From 27eb8bebebceedbf76690a611fa5e1ebffbe2969 Mon Sep 17 00:00:00 2001 From: "Zheng, Lei" Date: Sat, 22 Feb 2020 16:21:15 +0800 Subject: [PATCH] App: fix Link appLinkExecute Call hasAttr() first before getAttr(). --- src/App/Link.cpp | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/src/App/Link.cpp b/src/App/Link.cpp index a07c967c7c..22869ad949 100644 --- a/src/App/Link.cpp +++ b/src/App/Link.cpp @@ -207,22 +207,24 @@ App::DocumentObjectExecReturn *LinkBaseExtension::extensionExecute(void) { const char *method = getLinkExecuteValue(); if(!method || !method[0]) method = "appLinkExecute"; - Py::Object attr = proxyValue.getAttr(method); - if(attr.ptr() && attr.isCallable()) { - Py::Tuple args(4); - args.setItem(0, Py::asObject(linked->getPyObject())); - args.setItem(1, Py::asObject(container->getPyObject())); - if(!_getElementCountValue()) { - Py::Callable(attr).apply(args); - } else { - const auto &elements = _getElementListValue(); - for(int i=0; i<_getElementCountValue(); ++i) { - args.setItem(2, Py::Int(i)); - if(i < (int)elements.size()) - args.setItem(3, Py::asObject(elements[i]->getPyObject())); - else - args.setItem(3, Py::Object()); + if(proxyValue.hasAttr(method)) { + Py::Object attr = proxyValue.getAttr(method); + if(attr.ptr() && attr.isCallable()) { + Py::Tuple args(4); + args.setItem(0, Py::asObject(linked->getPyObject())); + args.setItem(1, Py::asObject(container->getPyObject())); + if(!_getElementCountValue()) { Py::Callable(attr).apply(args); + } else { + const auto &elements = _getElementListValue(); + for(int i=0; i<_getElementCountValue(); ++i) { + args.setItem(2, Py::Int(i)); + if(i < (int)elements.size()) + args.setItem(3, Py::asObject(elements[i]->getPyObject())); + else + args.setItem(3, Py::Object()); + Py::Callable(attr).apply(args); + } } } }