mirror of
https://github.com/nomic-ai/gpt4all.git
synced 2025-08-15 22:53:22 +00:00
chatmodel: fix call of setParent from wrong thread
Attempting to notify the objects of this change from a different thread causes an error in debug builds: ``` ASSERT failure in QCoreApplication::sendEvent: "Cannot send events to objects owned by a a different thread. Current thread 0x0x1a9dc360490. Receiver '' (of type 'ChatModel') was created in thread 0x0x1a9ad1a99f0", file C:\Users\qt\work\qtbase\src\corelib\kernel\qcoreapplication.cpp, line 557 ``` QObject::setParent is not documented to be thread-safe. Signed-off-by: Jared Van Bortel <jared@nomic.ai>
This commit is contained in:
parent
17bbedc77c
commit
82e543e6b9
@ -204,7 +204,8 @@ public:
|
||||
: QObject(nullptr)
|
||||
{
|
||||
moveToThread(parent->thread());
|
||||
setParent(parent);
|
||||
// setParent must be called from the thread the object lives in
|
||||
QMetaObject::invokeMethod(this, [this, parent]() { this->setParent(parent); });
|
||||
}
|
||||
|
||||
// NOTE: System messages are currently never serialized and only *stored* by the local server.
|
||||
|
Loading…
Reference in New Issue
Block a user