diff --git a/src/cpp/ecl_fun_plugin.h b/src/cpp/ecl_fun_plugin.h index 0cd0201..a1649ea 100644 --- a/src/cpp/ecl_fun_plugin.h +++ b/src/cpp/ecl_fun_plugin.h @@ -467,12 +467,15 @@ QVariant ecl_fun(const QByteArray& pkgFun, int p = pkgFun.indexOf(':'); QByteArray pkg = (p == -1) ? "qml-user" : pkgFun.left(p); QByteArray fun = pkgFun.mid(pkgFun.lastIndexOf(':') + 1); - cl_object l_sym = cl_find_symbol(2, - make_constant_base_string(fun.toUpper().constData()), - cl_find_package(make_constant_base_string(pkg.toUpper().constData()))); - if (l_sym != Cnil) { - symbol = l_sym; - lisp_functions[pkgFun] = symbol; + cl_object l_pkg = cl_find_package(make_constant_base_string(pkg.toUpper().constData())); + if (l_pkg != Cnil) { + cl_object l_sym = cl_find_symbol(2, + make_constant_base_string(fun.toUpper().constData()), + l_pkg); + if (cl_fboundp(l_sym) != Cnil) { + symbol = l_sym; + lisp_functions[pkgFun] = symbol; + } } } cl_object l_args = Cnil; diff --git a/src/cpp/qt_ecl.cpp b/src/cpp/qt_ecl.cpp index 06e43b1..8122703 100644 --- a/src/cpp/qt_ecl.cpp +++ b/src/cpp/qt_ecl.cpp @@ -45,12 +45,15 @@ QVariant ecl_fun(const QByteArray& pkgFun, int p = pkgFun.indexOf(':'); QByteArray pkg = (p == -1) ? "qml-user" : pkgFun.left(p); QByteArray fun = pkgFun.mid(pkgFun.lastIndexOf(':') + 1); - cl_object l_sym = cl_find_symbol(2, - make_constant_base_string(fun.toUpper().constData()), - cl_find_package(make_constant_base_string(pkg.toUpper().constData()))); - if (l_sym != Cnil) { - symbol = l_sym; - lisp_functions[pkgFun] = symbol; + cl_object l_pkg = cl_find_package(make_constant_base_string(pkg.toUpper().constData())); + if (l_pkg != Cnil) { + cl_object l_sym = cl_find_symbol(2, + make_constant_base_string(fun.toUpper().constData()), + l_pkg); + if (cl_fboundp(l_sym) != Cnil) { + symbol = l_sym; + lisp_functions[pkgFun] = symbol; + } } } cl_object l_args = Cnil; diff --git a/src/lisp/qml.lisp b/src/lisp/qml.lisp index e8d68f6..edca0dc 100644 --- a/src/lisp/qml.lisp +++ b/src/lisp/qml.lisp @@ -6,11 +6,12 @@ (defvar *root-item* nil) ; see macro 'with-root-item' (defun string-to-symbol (name) - (let ((upper (string-upcase name)) - (p (position #\: name))) + (let* ((upper (string-upcase name)) + (p (position #\: name)) + (pkg (find-package (subseq upper 0 p)))) (if p - (find-symbol (subseq upper (1+ (position #\: name :from-end t))) - (subseq upper 0 p)) + (and pkg (find-symbol (subseq upper (1+ (position #\: name :from-end t))) + pkg)) (find-symbol upper)))) ;;; function calls from QML @@ -25,7 +26,7 @@ (qt-object caller)))) (if (fboundp fun) (apply fun arguments) - (let ((msg (format nil "[LQML:error] Lisp.call(): function ~S is undefined." function))) + (let ((msg (format nil "[LQML:error] Lisp.call(): ~S is undefined." function))) (when *break-on-errors* (break msg) (format *error-output* "~%~A~%" msg))))))