[Interest] QObject: Cannot create children for a parent that is in a different thread.

Carel Combrink carel.combrink at gmail.com
Wed Aug 19 07:46:11 CEST 2015


Greetings,

I also had a similar issue once using an external library. My solution was
to let the callback emit a signal to a slot in the object using a queued
connection, and in the slot I did the actual processing of the data.

I buffered the data in the callback before emitting the signal, but if the
data can go through the queued connection it can just as well be arguments
in the signal-slot connection.

Doing this resulted in the main thread processing the data, and creating
the objects in the correct thread.

This was valid for me since it was not real time processing of the data,
not sure how much of a delay was introduced due to me doing it that way
though.

Regards,

---
Check out my SpellChecker Plugin for Qt Creator on github @
https://github.com/CJCombrink/SpellChecker-Plugin
Regards,
Carel



On Wed, Aug 19, 2015 at 12:40 AM, Celal SAVUR <c.savur at gmail.com> wrote:

> Hello Thiago,
>
> Actually I just find out that the C function which I am calling in Qt, is
> creating a thread. I do not have any control over this thread. The library
> I am using that have callback interface and whenever data available it
> calls my callback method in Qt.
>
> So, in order to solve this problem, what should I do?
>
> By the way, my application does not crash so I don't have backtrace.
>
> Thank you in advance.
>
>
>
>
>
>
>
> Celal SAVUR
>
>
>
> On Tue, Aug 18, 2015 at 5:30 PM, Thiago Macieira <
> thiago.macieira at intel.com> wrote:
>
>> On Tuesday 18 August 2015 14:23:05 Thiago Macieira wrote:
>> > On Tuesday 18 August 2015 16:33:39 Celal SAVUR wrote:
>> > > Hello everyone,
>> > >
>> > > I am keep getting this warning. Although I am not using thread. Do you
>> > > have
>> > > any idea?
>> > >
>> > > QObject: Cannot create children for a parent that is in a different
>> > > thread.
>> >
>> > I think you are using threads. Please run your application with
>> > QT_FATAL_WARNINGS=1 set in the environment and pastebin the backtrace.
>>
>> I can tell from the pointer values that you have multiple threads:
>>
>> > > (Parent is QHeaderView(0x1fee070), parent's thread is
>> QThread(0x81dc70),
>> > > current thread is QThread(0x7fff88000b00)
>>
>> The low-value pointers are heap allocations from the main thread's heap
>> pool.
>> The high pointer value for the second QThread is a heap allocation from a
>> secondary thread's pool.
>>
>> The pointer value isn't that of the QThread object, but of the internal
>> QThreadData and that one is created inside each thread. Since we have a
>> pointer that comes from the heap pool of an auxiliary thread, we conclude
>> an
>> auxiliary thread was started.
>>
>> So you are using threads.
>>
>> --
>> Thiago Macieira - thiago.macieira (AT) intel.com
>>   Software Architect - Intel Open Source Technology Center
>>
>> _______________________________________________
>> Interest mailing list
>> Interest at qt-project.org
>> http://lists.qt-project.org/mailman/listinfo/interest
>>
>
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20150819/15e661c4/attachment.html>


More information about the Interest mailing list