[Qgis-developer] QgsRasterBlock.setColor(size_t, QRgb) in SIP

Martin Dobias wonder.sk at gmail.com
Wed Oct 23 18:46:17 PDT 2013


On Thu, Oct 24, 2013 at 1:32 AM, Radim Blazek <radim.blazek at gmail.com> wrote:
> On Wed, Oct 23, 2013 at 7:07 PM, Martin Dobias <wonder.sk at gmail.com> wrote:
>> When I enter those two lines into QGIS python console, it work fine
>> (no debug output, result of setColor() call is True). Tested on linux
>> 64bit, QGIS master (debug), SIP v4.15.2.
>
> could you also test if you get the right value from block back
>    block.color( index )
> and with indexes > 0

Yes, I get correct values.


>> Otherwise I do not really have an idea what goes wrong there (btw. the
>> index is an interesting number - in hex it is 0x7ff800000000
>
> it does not seem to be really correct
>
>> - maybe it is not handling size_t type correctly?
>
> yes, size_t seems to be the problem, it is not defined in qgsrasterblock.sip,
> probably the definition from qgsgeometry.sip is used:
>   %If (WS_MACX)
>   typedef unsigned long size_t;
>   %End
>   %If (WS_X11 || WS_WIN)
>   typedef unsigned int size_t;
>   %End
> which does not seem to be very robust.

Indeed, the definition does not look robust. Will it help if you
change size_t definition for your platform to "unsigned long long" ?
(assuming you are on 64bit OS)

There was a thread on size_t in PyQt some time ago:
http://www.riverbankcomputing.com/pipermail/pyqt/2006-March/012753.html

> BTW, how to define such things
> correctly, in each sip file or globally in another sip file for all?

You need to define these things just once in one of the .sip files.
The order is not important (unlike c/c++).

Martin


More information about the Qgis-developer mailing list