mirror of
https://github.com/thp/pyotherside.git
synced 2025-02-05 08:08:23 +08:00
Factor out the unboxing in call() to a separate method. To handle direct calls to call_sync(), rename the implementation of call_sync() to call_internal() and add a call_sync() stub that calls call_internal(). call_internal() can now takes a boolean "unbox" parameter without impacting the formal interfaces that call() and call_sync() provide to QML users. If the "unbox" parameter is true, it unboxes the arguments first. If false, it doesn't. Now call_sync() can call call_internal() requesting unboxing. call() can also do the unboxing itself, and then later process() (the slot for switching call() to a different thread) can call call_internal() requesting no unboxing. Since we now have and must keep track of two versions of the parameters (boxed vs. unboxed), I also rename these parameters to keep things explicit and clear. Here's what was going wrong before: call() was unboxing QJSValue elements inside the argument list into plain QVariants, and then calling (indirectly, to switch threads) call_sync(). call_sync() did no such unboxing. Since call_sync() is exposed directly as an entry point, this meant that priv->call(), which appears to expect unboxed argument lists, was failing in this case. There is a comment noting that call() should do the unboxing in the GUI thread so should not defer it. So the unboxing has to happen in two different places depending on whether the user called call() or call_sync(). Fixes: #49