Too much query executed with QSqlQuery cause fatal signal if executed in different thread
-
@cmra said in Too much query executed with QSqlQuery cause fatal signal if executed in different thread:
connName
Where is it defined ? What does it contain ?
-
The processEvents() calls does not change nothing (I call it at line number 300 and the error happen at line 315 in release build). The error happen again.
connName is a global QString variable defined in the QRunnableDerivedObject and it's value is "async_conn", but this connection name is used only with one QSqlDatabase at start of importing process, no more. -
So there's your problem: you are creating connections with the exact same name in all of your threads. You should make the name unique per thread. For example add the thread id to the connection string.
-
No it doesn't...because as I explained before I have just one thread and so just one connection.. I create only one thread fot importing data and no other. The connections in the main app don't use thread to exec query and they have different names.
I don't beleave that QThreadPool create more than one thread itself. -
To be sure to understand you correctly, you are trying to execute 33000 queries on an Android phone ? What kind of device is that ?
-
Yes it is right....I tried on Samsung S6 and Samsung j6. But I already execute with success all the queries in the past, but now I can't find what wrong...if depend by an update of android sdk or ndk or I made a mistake in some place (the code is so simple that I exclude that).
So I ask for help to you because may be some errors that I can't see. -
....and FINALLY I FOUND THE SOLUTIONS that wasn't in this part of code (this is correct)...
I use reference & to a global variable in the base app and assign it to a pointer * = &var.. When declare as pointer also the global variable all works good.
Thanks too much all people help me, but the problem was not here. I'm sorry to busy your time...
Thanks again. -
Glad you found out !
Global variable ?
They should be avoided as much as possible. What is it and what are you doing with it ?
-
The strange thing is that I don't use these variables in the new thread but I use only the QStringList passed.
But the error happen only in the new thread during the import otherwise the app seam to work right.
I don't know why.
To develop the app I use qml and I use "qmlRegisterType()" to use c++ object. -
If you really need that kind of global object (which you likely don't), then you should rather implement them as singletons with proper access protection.