[Android-development] QNetworkAccessManager crashes by JNI-call (native Android) with Fatal signal 6 (SIGABRT)
Malek Khlif
qt.malek.khlif at gmail.com
Fri Jun 10 21:01:42 CEST 2016
Hello,
I suggest to remove "this" from QNetworkAccessManager constructore:
Use
QNetworkAccessManager *manager = new QNetworkAccessManager;
instead of
QNetworkAccessManager *manager = new QNetworkAccessManager(this); // <CRASH>
2016-06-10 15:04 GMT+01:00 Maik Ziemert <mail at moozoom.de>:
> Hello,
>
> no, I create an instance of QCoreApplication before I use the
> QNetworkAccessManager:
>
> void SimpleQtLibrary::test() // Simple test method (call over JNI)
>
> {
>
> this->createCoreApplication();
>
>
> this->createNetworkManager(); // <CRASH>
>
>
> this->exec();
>
>
> return;
>
> }
>
>
> void SimpleQtLibrary::createCoreApplication()
>
> {
>
> int argc = 1;
>
> char * argv[] = {„my.app", NULL};
>
>
> if (QCoreApplication::instance() == NULL)
>
> {
>
> new QCoreApplication(argc, argv);
>
> }
>
>
> return;
>
> }
>
>
> int SimpleQtLibrary::exec()
>
> {
>
> return QCoreApplication::exec();
>
> }
>
> void DTQSimpleTeamDriveLibrary::createNetworkManager()
>
> {
>
> QNetworkAccessManager *manager = new QNetworkAccessManager(this); // <CRASH>
>
> return;
>
> }
>
>
>
> Am 10.06.2016 um 15:58 schrieb Malek Khlif <qt.malek.khlif at gmail.com>:
>
> Hello,
>
> I suppose that you use QNetworkAccessManager before that you create an
> instance of QCoreApplication .
>
> 2016-06-10 15:53 GMT+02:00 Maik Ziemert <mail at moozoom.de>:
>
>> I have a big problem with my Qt library - integrated in a native Android
>> App over JNI.
>>
>>
>> I wrote a static qt library. In this library I instantiate a
>> QNetworkAccessManager for using a network communication:
>>
>>
>> @QT CODE
>>
>> void SimpleQtLibrary::createNetworkManager()
>> {
>>
>> QNetworkAccessManager *manager = new QNetworkAccessManager(this);
>>
>> <CRASH>
>>
>> ...
>>
>> return;
>> }
>>
>> @QT CODE END
>>
>>
>> I know, this async manager needs a own thread for internal signals.
>>
>>
>> In my android project I will integrate this qt static library over jni:
>>
>>
>> @JNI CODE
>>
>> #include <string.h>
>> #include <jni.h>
>> #include <android/log.h>
>>
>> #include <qtlibrary.h>
>>
>> static QtLibrary qtLib;
>>
>> extern "C" {
>> JNIEXPORT void JNICALL
>> Java_com_company_qtlibrary_Interface_test(JNIEnv * env, jobject obj);
>> };
>>
>> JNIEXPORT void JNICALL Java_com_company_qtlibrary_Interface_test(JNIEnv *
>> env, jobject obj)
>> {
>> qtLib.test();
>>
>> return;
>> }
>>
>> @JNI CODE END
>>
>>
>> If I let running my android app, while the qt call over JNI, the app
>> crashes:
>>
>> Fatal signal 6 (SIGABRT) at 0x000072f1 (code=-6), thread 29425
>>
>>
>> How can I solve this problem? The QCoreApplication event loop works on
>> the main thread (in Android), e.g. I can create a QTimer with a tick()
>> every second.
>>
>>
>> Please help me in this case. I dont know what I can do to find a goof
>> solution.
>>
>>
>> Thank you in advanced!
>>
>> _______________________________________________
>> Android-development mailing list
>> Android-development at qt-project.org
>> http://lists.qt-project.org/mailman/listinfo/android-development
>>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/android-development/attachments/20160610/3c0ef479/attachment.html>
More information about the Android-development
mailing list