From 36232f6d375aa9424746f7d23ce42bcf5ed3bcf9 Mon Sep 17 00:00:00 2001 From: polos Date: Sat, 24 Feb 2018 11:08:38 +0100 Subject: [PATCH] change/fix long name of 'qrun' to 'qrun-on-ui-thread' (erroneously called 'qrun-in-gui-thread') --- doc/EQL-Slime-Integration.htm | 10 +++++----- doc/auto-doc.htm | 6 +++--- .../9-simple-lisp-editor/data/eql-keywords.lisp | 4 ++-- examples/X-extras/primes-thread.lisp | 2 +- slime/repl-hook.lisp | 2 +- src/ecl_fun.cpp | 12 ++++++------ src/ecl_fun.h | 2 +- src/eql.cpp | 5 +++-- src/eql5/eql.h | 2 +- src/lisp/ini.lisp | 16 ++++++++-------- src/lisp/package.lisp | 4 ++-- 11 files changed, 33 insertions(+), 32 deletions(-) diff --git a/doc/EQL-Slime-Integration.htm b/doc/EQL-Slime-Integration.htm index 4491ff0..2ae9add 100644 --- a/doc/EQL-Slime-Integration.htm +++ b/doc/EQL-Slime-Integration.htm @@ -27,7 +27,7 @@ ;; in some ECL thread (let (values) - (run-in-gui-thread + (run-on-ui-thread ;; in ECL main/GUI thread (lambda () @@ -36,14 +36,14 @@ ;; back in some ECL thread (values-list values)) -

Here the implementation of the ECL function run-in-gui-thread (embedded in Qt):

+

Here the implementation of the ECL function run-on-ui-thread (embedded in Qt):

 
-  cl_object run_in_gui_thread(cl_object closure) // define ECL function
+  cl_object run_on_ui_thread(cl_object closure) // define ECL function
   {
       QMetaObject::invokeMethod(
           object,                       // any QObject from GUI thread
-          "runInGuiThread",             // see Q_INVOKABLE
+          "runOnUiThread",              // see Q_INVOKABLE
           Qt::BlockingQueuedConnection, // blocking for return values
           Q_ARG(void*, closure));       // 'closure' is just a pointer
 
@@ -53,7 +53,7 @@
       

Now the Lisp closure will run in the GUI/main thread, and the implementation of the Qt function runInGuiThread is as simple as:

 
-  Q_INVOKABLE void runInGuiThread(void* closure) // note Q_INVOKABLE
+  Q_INVOKABLE void runOnUiThread(void* closure) // note Q_INVOKABLE
   {
       cl_funcall(1, (cl_object)closure); // ECL function call
   }
diff --git a/doc/auto-doc.htm b/doc/auto-doc.htm
index b9edf9f..26454fe 100644
--- a/doc/auto-doc.htm
+++ b/doc/auto-doc.htm
@@ -463,17 +463,17 @@ Loads an EQL module, corresponding to a Qt module.
Returns the module name if Constructs a (unsigned-byte 32) value that represents a 32 bit pixel color specified by the red, green, blue and alpha values.


-QRUN-IN-GUI-THREAD (function &optional (blocking t)) +QRUN-ON-UI-THREAD (function &optional (blocking t))
QRUN

-Runs function in GUI thread while (by default) blocking the calling thread (if called from main thread, function will simply be called directly).
This is needed to run GUI code from ECL threads other than the main thread.
Returns T on success.

There are 2 reasons to always wrap any EQL function like this, if called from another ECL thread:
  • Qt GUI methods always need to run in the GUI thread
  • EQL functions are not designed to be reentrant (not needed for GUI code)
See also macro qrun*. +Runs function on the UI thread while (by default) blocking the calling thread (if called from main thread, function will simply be called directly).
This is needed to run GUI code from ECL threads other than the main thread.
Returns T on success.

There are 2 reasons to always wrap any EQL function like this, if called from another ECL thread:
  • Qt UI methods always need to run on the UI thread
  • EQL functions are not designed to be reentrant (not needed for UI code)
See also macro qrun*.
   (qrun 'update-view-data)
 


-QRUN-IN-GUI-THREAD* (&body body) +QRUN-ON-UI-THREAD* (&body body)
QRUN*

diff --git a/examples/9-simple-lisp-editor/data/eql-keywords.lisp b/examples/9-simple-lisp-editor/data/eql-keywords.lisp index cc1d099..b5a679c 100644 --- a/examples/9-simple-lisp-editor/data/eql-keywords.lisp +++ b/examples/9-simple-lisp-editor/data/eql-keywords.lisp @@ -66,9 +66,9 @@ "qrequire" "qrgb" "qrun" - "qrun-in-gui-thread" + "qrun-on-ui-thread" "qrun*" - "qrun-in-gui-thread*" + "qrun-on-ui-thread*" "qsel" "qselect" "qsender" diff --git a/examples/X-extras/primes-thread.lisp b/examples/X-extras/primes-thread.lisp index 83e8ab2..0557571 100644 --- a/examples/X-extras/primes-thread.lisp +++ b/examples/X-extras/primes-thread.lisp @@ -1,5 +1,5 @@ ;;; -;;; A simple demo for macro QRUN-IN-GUI-THREAD* / QRUN* +;;; A simple demo for macro QRUN-ON-UI-THREAD* / QRUN* ;;; ;;; Calculate primes in threads and update QTreeWidget directly from threads. ;;; diff --git a/slime/repl-hook.lisp b/slime/repl-hook.lisp index d7465ee..4b7f355 100644 --- a/slime/repl-hook.lisp +++ b/slime/repl-hook.lisp @@ -10,7 +10,7 @@ (defun %qeval (form) (multiple-value-bind (values package) - (qrun-in-gui-thread* + (qrun-on-ui-thread* (values (multiple-value-list (with-simple-restart (abort "Return to SLIME's top level.") (eval (subst 'identity 'qeval form)))) diff --git a/src/ecl_fun.cpp b/src/ecl_fun.cpp index 0e388e6..2d5bcda 100644 --- a/src/ecl_fun.cpp +++ b/src/ecl_fun.cpp @@ -145,7 +145,7 @@ void iniCLFunctions() { DEFUN ("qproperty", qproperty, 2) DEFUN ("%qrequire", qrequire2, 2) DEFUN ("qremove-event-filter", qremove_event_filter, 1) - DEFUN ("%qrun-in-gui-thread", qrun_in_gui_thread2, 2) + DEFUN ("%qrun-on-ui-thread", qrun_on_ui_thread2, 2) DEFUN ("qsender", qsender, 0) DEFUN ("%qset-gc", qset_gc, 1) DEFUN ("qset-property", qset_property, 3) @@ -2958,26 +2958,26 @@ cl_object qversion() { l_env->values[1] = from_cstring(qVersion()); return l_env->values[0]; } -cl_object qrun_in_gui_thread2(cl_object l_function_or_closure, cl_object l_blocking) { +cl_object qrun_on_ui_thread2(cl_object l_function_or_closure, cl_object l_blocking) { /// args: (function &optional (blocking t)) /// alias: qrun - /// Runs function in GUI thread while (by default) blocking the calling thread (if called from main thread, function will simply be called directly).
This is needed to run GUI code from ECL threads other than the main thread.
Returns T on success.

There are 2 reasons to always wrap any EQL function like this, if called from another ECL thread:
  • Qt GUI methods always need to run in the GUI thread
  • EQL functions are not designed to be reentrant (not needed for GUI code)
See also macro qrun*. + /// Runs function on the UI thread while (by default) blocking the calling thread (if called from main thread, function will simply be called directly).
This is needed to run GUI code from ECL threads other than the main thread.
Returns T on success.

There are 2 reasons to always wrap any EQL function like this, if called from another ECL thread:
  • Qt UI methods always need to run on the UI thread
  • EQL functions are not designed to be reentrant (not needed for UI code)
See also macro qrun*. /// (qrun 'update-view-data) ecl_process_env()->nvalues = 1; if(l_function_or_closure != Cnil) { QObject o; if(o.thread() == QApplication::instance()->thread()) { // direct call - LObjects::eql->runInGuiThread(l_function_or_closure); + LObjects::eql->runOnUiThread(l_function_or_closure); return Ct; } else { // queued call in main event loop (GUI thread) QMetaObject::invokeMethod(LObjects::eql, - "runInGuiThread", + "runOnUiThread", (l_blocking != Cnil) ? Qt::BlockingQueuedConnection : Qt::QueuedConnection, Q_ARG(void*, l_function_or_closure)); return Ct; }} - error_msg("QRUN-IN-GUI-THREAD", LIST1(l_function_or_closure)); + error_msg("QRUN-ON-UI-THREAD", LIST1(l_function_or_closure)); return Cnil; } cl_object qlog2(cl_object l_msg) { diff --git a/src/ecl_fun.h b/src/ecl_fun.h index 5f4cdf6..3440d89 100644 --- a/src/ecl_fun.h +++ b/src/ecl_fun.h @@ -272,7 +272,7 @@ cl_object qprocess_events (); cl_object qproperty (cl_object, cl_object); cl_object qremove_event_filter (cl_object); cl_object qrequire2 (cl_object, cl_object); -cl_object qrun_in_gui_thread2 (cl_object, cl_object); +cl_object qrun_on_ui_thread2 (cl_object, cl_object); cl_object qsender (); cl_object qset_gc (cl_object); cl_object qset_property (cl_object, cl_object, cl_object); diff --git a/src/eql.cpp b/src/eql.cpp index a7529ab..f3f8caa 100644 --- a/src/eql.cpp +++ b/src/eql.cpp @@ -179,11 +179,12 @@ void EQL::exec(QWidget* widget, const QString& lispFile, const QString& slimeHoo if(exec_with_simple_restart) { eval("(eql::exec-with-simple-restart)"); }} -void EQL::runInGuiThread(void* function_or_closure) { +void EQL::runOnUiThread(void* function_or_closure) { const cl_env_ptr l_env = ecl_process_env(); CL_CATCH_ALL_BEGIN(l_env) { CL_UNWIND_PROTECT_BEGIN(l_env) { - cl_funcall(1, (cl_object)function_or_closure); } + cl_object l_fun = (cl_object)function_or_closure; + cl_funcall(1, l_fun); } CL_UNWIND_PROTECT_EXIT {} CL_UNWIND_PROTECT_END; } CL_CATCH_ALL_END; } diff --git a/src/eql5/eql.h b/src/eql5/eql.h index b435d1f..ec698ae 100644 --- a/src/eql5/eql.h +++ b/src/eql5/eql.h @@ -43,7 +43,7 @@ public: " (eql:qversion)" " (format t \"EQL5 ~A (ECL ~A, Qt ~A)~%\" eql (lisp-implementation-version) qt))"); } - Q_INVOKABLE void runInGuiThread(void*); + Q_INVOKABLE void runOnUiThread(void*); public Q_SLOTS: void exitEventLoop() { eventLoop->exit(); } diff --git a/src/lisp/ini.lisp b/src/lisp/ini.lisp index 0f05c20..c1cad51 100644 --- a/src/lisp/ini.lisp +++ b/src/lisp/ini.lisp @@ -328,7 +328,7 @@ (unless (find-package :ecl-readline) (princ "> ")) (let ((form (si::%tpl-read))) - (qrun-in-gui-thread (lambda () (eval-top-level form)) nil)) + (qrun-on-ui-thread (lambda () (eval-top-level form)) nil)) (values)) (defun start-read-thread () @@ -690,13 +690,13 @@ (funcall ,reloaded ',variable ,library-name))))) (defvar ,reloaded nil)))) -(defun qrun-in-gui-thread (function &optional (blocking t)) - (%qrun-in-gui-thread function blocking)) +(defun qrun-on-ui-thread (function &optional (blocking t)) + (%qrun-on-ui-thread function blocking)) #+threads (defvar *gui-thread* mp:*current-process*) -(defmacro qrun-in-gui-thread* (&body body) +(defmacro qrun-on-ui-thread* (&body body) "args: (&body body) alias: qrun* Convenience macro for qrun, wrapping body in a closure (passing arguments, return values). @@ -722,7 +722,7 @@ (first body))) (defmacro qrun* (&body body) ; alias - `(qrun-in-gui-thread* ,@body)) + `(qrun-on-ui-thread* ,@body)) (defun qload (file-name) "args: (file-name) @@ -772,7 +772,7 @@ (alias qfun+ qinvoke-method+) (alias qmsg qmessage-box) (alias qnull qnull-object) -(alias qrun qrun-in-gui-thread) +(alias qrun qrun-on-ui-thread) (alias qsel qselect) (alias qq qquit) @@ -834,9 +834,9 @@ (cons 'qrequire '(module &optional quiet)) (cons 'qrgb '(red green blue &optional (alpha 255))) (cons 'qrun '(function)) - (cons 'qrun-in-gui-thread '(function)) + (cons 'qrun-on-ui-thread '(function)) (cons 'qrun* '(&body body)) - (cons 'qrun-in-gui-thread* '(&body body)) + (cons 'qrun-on-ui-thread* '(&body body)) (cons 'qset-null '(object)) (cons 'qset '(object name value)) (cons 'qset-color '(widget color-role color)) diff --git a/src/lisp/package.lisp b/src/lisp/package.lisp index 2f427ce..5adb90d 100644 --- a/src/lisp/package.lisp +++ b/src/lisp/package.lisp @@ -77,9 +77,9 @@ #:qrequire #:qrgb #:qrun - #:qrun-in-gui-thread + #:qrun-on-ui-thread #:qrun* - #:qrun-in-gui-thread* + #:qrun-on-ui-thread* #:qsel #:qselect #:qsender