Skip to content

Commit 858d220

Browse files
committed
Fix documentation on calls from other threads
Documentation and error message change on calling methods from other threads. No functional change. Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
1 parent 1681db4 commit 858d220

2 files changed

Lines changed: 9 additions & 12 deletions

File tree

src/ptz-device.cpp

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,13 @@
1717
* simplifies the registration of PTZDevice methods as targets for
1818
* proc_handler calls.
1919
*
20-
* In this current implementation, the proc_handler must be called from
21-
* the GUI thread. If called from another thread it will output a
22-
* warning and return without action. It is done this way because the
23-
* calldata_t* is transient and owned by the calling thread, but Qt
24-
* objects need to be called from their own thread, and calldata would
25-
* be stale if the call was queued with QMetaObject::invokeMethod()
26-
*
27-
* This isn't ideal, as there are places where other plugins may want to
28-
* make calls from their own threads. The rule can be relaxed on a call
29-
* by call basis if the method is made thread safe.
20+
* In this current implementation, the proc_handler can be called from
21+
* any thread, and the calldata method must decode the arguments and use
22+
* invokeMethod to call the real target. invokeMethod will check if it
23+
* was called from the object's thread. If it wasn't, and if the method
24+
* doesn't return anything, then the call is queued on the correct
25+
* thread. For methods that do return data, they aren't handled yet and
26+
* will log an error when calling from a different thread.
3027
*/
3128
#define ptz_ph_lambda(_method) [](void *p, calldata_t *cd) \
3229
{ \
@@ -202,7 +199,7 @@ void PTZDevice::move_rel(calldata_t *cd)
202199
void PTZDevice::get(calldata_t *cd) const
203200
{
204201
if (QThread::currentThread() != thread()) {
205-
ptz_log(LOG_ERROR, "PTZDevice::get(calldata) called from non-GUI thread; ignored");
202+
ptz_log(LOG_ERROR, "PTZDevice::get(calldata) called from wrong thread; ignored");
206203
return;
207204
}
208205
QString arg = calldata_string(cd, "property");

src/ptz-visca.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -794,7 +794,7 @@ void PTZVisca::get(calldata_t *cd) const
794794
void PTZVisca::set(calldata_t *cd)
795795
{
796796
if (QThread::currentThread() != thread()) {
797-
ptz_log(LOG_ERROR, "PTZVisca::set(calldata) called from non-GUI thread; ignored");
797+
ptz_log(LOG_ERROR, "PTZVisca::set(calldata) called from wrong thread; ignored");
798798
return;
799799
}
800800
bool power_on;

0 commit comments

Comments
 (0)