Problem when passing an array as a paramater from QtC++ to Java



  • Hello everybody,
    I'm trying to pass an int array from QTC++ code to a Java function. My code is:

    C++:

    (...)
    int pattern[] = {1901, 4453, 625, 1614, 625, 1588, 625, 1614, 625, 442, 625, 442, 625,
                        468, 625, 442, 625, 494, 572, 1614, 625, 1588, 625, 1614, 625, 494, 572, 442, 651,
                        442, 625, 442, 625, 442, 625, 1614, 625, 1588, 651, 1588, 625, 442, 625, 494, 598,
                        442, 625, 442, 625, 520, 572, 442, 625, 442, 625, 442, 651, 1588, 625, 1614, 625,
                        1588, 625, 1614, 625, 1588, 625, 48958};
    
    #ifdef Q_OS_ANDROID
        QtAndroid::runOnAndroidThread([=]() {
            QAndroidJniObject::callStaticMethod<void>("cat/selrac/IrManager",
                                                               "sendIrFrame",
                                                               "(I[I)V",
                                                                carrierFrequency,
                                                                pattern);
         });
    #endif
    (...)
    

    Java:

        public static void sendIrFrame(int carrierFrequency, int[] pattern)
        {        
            if( mCIR.hasIrEmitter())
            {  
                mCIR.transmit(carrierFrequency, pattern);
            }
        }
    

    The code compiles OK and I could run the application on my Android Device, but when I execute this part of code the app crashes and this messages appear in the console:

    W/dalvikvm(32419): Invalid indirect reference 0x66e7dc8c in decodeIndirectRef
    I/dalvikvm(32419): "main" prio=5 tid=1 RUNNABLE
    I/dalvikvm(32419):   | group="main" sCount=0 dsCount=0 obj=0x41dc3ea0 self=0x41db1ff0
    I/dalvikvm(32419):   | sysTid=32419 nice=0 sched=0/0 cgrp=apps handle=1073971540
    I/dalvikvm(32419):   | state=R schedstat=( 0 0 0 ) utm=176 stm=95 core=0
    I/dalvikvm(32419):   at cat.selrac.IrManager.sendIrFrame(IrManager.java:-1)
    I/dalvikvm(32419):   at org.qtproject.qt5.android.QtNative.runPendingCppRunnables(Native Method)
    I/dalvikvm(32419):   at org.qtproject.qt5.android.QtNative$1.run(QtNative.java:102)
    I/dalvikvm(32419):   at android.os.Handler.handleCallback(Handler.java:733)
    I/dalvikvm(32419):   at android.os.Handler.dispatchMessage(Handler.java:95)
    I/dalvikvm(32419):   at android.os.Looper.loop(Looper.java:146)
    I/dalvikvm(32419):   at android.app.ActivityThread.main(ActivityThread.java:5593)
    I/dalvikvm(32419):   at java.lang.reflect.Method.invokeNative(Native Method)
    I/dalvikvm(32419):   at java.lang.reflect.Method.invoke(Method.java:515)
    I/dalvikvm(32419):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
    I/dalvikvm(32419):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
    I/dalvikvm(32419):   at dalvik.system.NativeStart.main(Native Method)
    I/dalvikvm(32419):
    E/dalvikvm(32419): VM aborting
    F/libc    (32419): Fatal signal 6 (SIGABRT) at 0x00007ea3 (code=-6), thread 32419 (cat.selrac)
    I/DEBUG   (27858): pid: 32419, tid: 32419, name: cat.selrac  >>> cat.selrac <<<
    I/DEBUG   (27858): !@dumpstate -k -t -z -d -o /data/log/dumpstate_app_native -m 32419
    D/CrashAnrDetector(  743): pid: 32419, tid: 32419, name: cat.selrac  >>> cat.selrac <<<
    I/ActivityManager(  743): Process cat.selrac (pid 32419) (adj 9) has died.
    D/Zygote  (  192): Process 32419 terminated by signal (6)
    

    Has anyone knows if I'm doing something wrong?

    Thank you very much.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.