Ticket #51149: patch-sip.diff

File patch-sip.diff, 1.7 KB (added by aaschwanden (Andy Aschwanden), 8 years ago)
  • conversions.sip

    old new  
    680680  PyObject *kobj, *tobj, *kobj2, *tobj2;
    681681  Py_ssize_t i = 0;
    682682
    683   //TODO: it works using SIP
    684 #if (SIP_VERSION >= 0x041200)
    685   const sipMappedType* qmap2 = sipFindMappedType("QMap<int, TYPE>");
    686 #endif
    687 
    688683  // Check the type if that is all that is required.
    689684  if (sipIsErr == NULL)
    690685  {
     
    696691      if (!PyDict_Check(tobj))
    697692        return 0;
    698693
    699 #if (SIP_VERSION >= 0x041200)
    700       if (!sipCanConvertToMappedType(tobj, qmap2, SIP_NOT_NONE))
    701         return 0;
    702 #else
    703694      Py_ssize_t j = 0;
    704695      while (PyDict_Next(tobj, &j, &kobj2, &tobj2))
    705696      {
    706697        if (!sipCanConvertToType(tobj2, sipType_TYPE, SIP_NOT_NONE))
    707698          return 0;
    708699      }
    709 #endif
    710700    }
    711701    return 1;
    712702  }
     
    717707  {
    718708    qint64 k = PyLong_AsLongLong(kobj);
    719709
    720 #if (SIP_VERSION >= 0x041200)
    721     // TODO: search for the minimum SIP version this code works on, it works
    722     // on SIP 4.13.3 (GS). See #else to know why the version check is needed.
    723 
    724     int state;
    725 
    726     TYPE* t = reinterpret_cast<TYPE*>(sipConvertToMappedType(tobj, qmap2, sipTransferObj,SIP_NOT_NONE,&state,sipIsErr));
    727 
    728     if (*sipIsErr)
    729     {
    730       sipReleaseMappedType(t, qmap2, state);
    731       delete qm;
    732       return 0;
    733     }
    734 
    735     qm.insert(k, *t);
    736     sipReleaseMappedType(t, qmap2, state);
    737 #else
    738710    // using sipConvertToMappedType to convert directly to QMap<int, TYPE> doesn't work
    739711    // and ends with a segfault
    740712
     
    759731      sipReleaseType(t2, sipType_TYPE, state);
    760732    }
    761733    qm->insert(k, qm2);
    762 #endif
    763734  }
    764735
    765736  *sipCppPtr = qm;