Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#111 m_pDispatch is not 0 if not attached

1.17
closed-accepted
nobody
None
5
2013-09-07
2012-08-02
sineca
No

In my COM communication with another application I used to compare the m_pDispatch != 0 to make sure that we are attached. Since Version 1.17 m_pDispatch is always != 0, whether it is attached or not.
I am using Jacob 1.17, jdk1.6.0_31

Discussion

  • clay_shooter
    clay_shooter
    2012-12-15

    Do you have a test case or example program that shows this. There were 32 bit to 64 bit pointer changes in that release but it shouldn't have an effect like you describe[

     
  • sineca
    sineca
    2012-12-19

    I was not able to reproduce this behavoir in a small example. Even the same calls in a small main and inside my working project react differently. I have no idea how to figure out so I will stick to 1.16.

    Bye

     
  • sineca
    sineca
    2012-12-19

    Sorry, I mixed up 32 bit Java and 64 bit java. With 64 bit Java everything works as expected. 32 bit Java fails:
    Example:
    ...
    Dispatch dispExcel = new Dispatch("Excel.Application");
    Variant varWb = Dispatch.get(dispExcel, "ActiveWorkbook");
    Dispatch dispWb = new Dispatch(varWb.getDispatch());

    /* This is NOT 0 WITH 32 bit Java and it is 0 with 64 bit java */
    long lWb = dispWb.m_pDispatch;

    Variant res = Dispatch.get(dispWb, "Activate");
    ...

     
  • clay_shooter
    clay_shooter
    2013-07-24

    We converted all the m_pDispatch code to long values in 1.17. Not sure if somehow we are getting the top 32 bits of the dispatch object filled with junk now

     
  • clay_shooter
    clay_shooter
    2013-07-24

    Found an error in the release method SetIntField should be SetLongField. This fix will show up in 1.17 M3

    /
    * release method
    /
    JNIEXPORT void JNICALL Java_com_jacob_com_Dispatch_release
    (JNIEnv env, jobject _this)
    {
    jclass clazz = env->GetObjectClass(_this);
    jfieldID jf = env->GetFieldID( clazz, DISP_FLD, "J");
    jlong num = env->GetLongField(_this, jf);

    IDispatch disp = (IDispatch )num;
    if (disp) {
    disp->Release();
    env->SetIntField(_this, jf, 0ll);
    }
    }

     
  • clay_shooter
    clay_shooter
    2013-07-24

    • status: open --> pending-accepted
     
  • clay_shooter
    clay_shooter
    2013-09-07

    • status: pending-accepted --> closed-accepted