Conversation
Both forward declarations and methods are assumed not gcsafe and raising `Exception` unless otherwise specified. This PR is a first pass over the API to ensure that it does not leak unwanted `raises`/not-`gcsafe` effects into the application using `nimqml` from the bulk of its API. The changes do not touch the "public" QAIM methods but aims to fix at least the internals. Of course, raising from within a QAIM callback would crash the application but applying strict `raises: []` would be a (significantly) breaking change since user code would now have to be raises-correct. * `c` functions do not raise exception (`importc` implies `gcsafe` but not `raises:[]`.} * `metaObject` instances are not suitable to expose as a global since it's a ref type (accessing it from different threads is not gcsafe) - this PR switches to a lazy threadvar instead Free bonus: leak fix in QModelIndex
|
@arnetheduck what's the rationale for accessing the QMetaObject from different threads? Usually QObject are created inside a thread and MUST be deleted from the same thread |
You can create instances of the same The reason to do this would for example be to use signals/slots as a cross-thread communication mechanism, ie bind a signal from a QObject in one thread to a slot of an object in another thread (which is allowed). What this PR does is bind the An alternative approach here would be to share the |
|
ok but still we don't quite handle the moveToThread stuff in QObject. We can obviously add that support later on. |
|
@arnetheduck i wonder if using the shared_ptr approach could be better for this use cases. In particular to the LambdaInvoker |
Both forward declarations and methods are assumed not gcsafe and raising
Exceptionunless otherwise specified.This PR is a first pass over the API to ensure that it does not leak unwanted
raises/not-gcsafeeffects into the application usingnimqmlfrom the bulk of its API.The changes do not touch the "public" QAIM methods but aims to fix at least the internals. Of course, raising from within a QAIM callback would crash the application but applying strict
raises: []would be a (significantly) breaking change since user code would now have to be raises-correct.cfunctions do not raise exception (importcimpliesgcsafebut notraises:[].}metaObjectinstances are not suitable to expose as a global since it's a ref type (accessing it from different threads is not gcsafe) - this PR switches to a lazy threadvar insteadFree bonus: leak fix in QModelIndex