Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 588994
Collapse All | Expand All

(-)a/python/core/conversions.sip (-29 lines)
Lines 680-690 template<TYPE> Link Here
680
  PyObject *kobj, *tobj, *kobj2, *tobj2;
680
  PyObject *kobj, *tobj, *kobj2, *tobj2;
681
  Py_ssize_t i = 0;
681
  Py_ssize_t i = 0;
682
682
683
  //TODO: it works using SIP
684
#if (SIP_VERSION >= 0x041200)
685
  const sipMappedType* qmap2 = sipFindMappedType("QMap<int, TYPE>");
686
#endif
687
688
  // Check the type if that is all that is required.
683
  // Check the type if that is all that is required.
689
  if (sipIsErr == NULL)
684
  if (sipIsErr == NULL)
690
  {
685
  {
Lines 696-712 template<TYPE> Link Here
696
      if (!PyDict_Check(tobj))
691
      if (!PyDict_Check(tobj))
697
        return 0;
692
        return 0;
698
693
699
#if (SIP_VERSION >= 0x041200)
700
      if (!sipCanConvertToMappedType(tobj, qmap2, SIP_NOT_NONE))
701
        return 0;
702
#else
703
      Py_ssize_t j = 0;
694
      Py_ssize_t j = 0;
704
      while (PyDict_Next(tobj, &j, &kobj2, &tobj2))
695
      while (PyDict_Next(tobj, &j, &kobj2, &tobj2))
705
      {
696
      {
706
        if (!sipCanConvertToType(tobj2, sipType_TYPE, SIP_NOT_NONE))
697
        if (!sipCanConvertToType(tobj2, sipType_TYPE, SIP_NOT_NONE))
707
          return 0;
698
          return 0;
708
      }
699
      }
709
#endif
710
    }
700
    }
711
    return 1;
701
    return 1;
712
  }
702
  }
Lines 717-740 template<TYPE> Link Here
717
  {
707
  {
718
    qint64 k = PyLong_AsLongLong(kobj);
708
    qint64 k = PyLong_AsLongLong(kobj);
719
709
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
738
    // using sipConvertToMappedType to convert directly to QMap<int, TYPE> doesn't work
710
    // using sipConvertToMappedType to convert directly to QMap<int, TYPE> doesn't work
739
    // and ends with a segfault
711
    // and ends with a segfault
740
712
Lines 759-765 template<TYPE> Link Here
759
      sipReleaseType(t2, sipType_TYPE, state);
731
      sipReleaseType(t2, sipType_TYPE, state);
760
    }
732
    }
761
    qm->insert(k, qm2);
733
    qm->insert(k, qm2);
762
#endif
763
  }
734
  }
764
735
765
  *sipCppPtr = qm;
736
  *sipCppPtr = qm;

Return to bug 588994