<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">2015-04-21 17:20 GMT+02:00 Phil Thompson <span dir="ltr"><<a href="mailto:phil@riverbankcomputing.com" target="_blank">phil@riverbankcomputing.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="">On 21/04/2015 4:12 pm, Alessandro Pasotti wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Hi,<br>
<br>
I noticed that if I create a property() alias on a virtual method, the<br>
alias will always call the base class method instead of the concrete<br>
instance method.<br>
<br>
Is this the expected behaviour?<br>
Is it documented somewhere?<br>
<br>
Here using PyQt4 4.8.5 and python 2.7, SIP should be 4.15.5<br>
</blockquote>
<br></span>
A simple, complete example that demonstrates the problem would help.<br></blockquote><div><br><br></div><div>Hi Phil,<br><br></div><div>I know an example would help but a simple one is not possible: I'm working on a QT app embedded in a python plugin embedded in a 10K sloc C++ app.<br><br></div><div>But, I try.<br><br>instance "d" is a QgsPostgresProvider : public QgsVectorDataProvider <a href="https://github.com/elpaso/QGIS/blob/master/src/providers/postgres/qgspostgresprovider.h">https://github.com/elpaso/QGIS/blob/master/src/providers/postgres/qgspostgresprovider.h</a><br>which is a subclass of QgsVectorDataProvider <a href="https://github.com/elpaso/QGIS/blob/master/src/core/qgsvectordataprovider.h">https://github.com/elpaso/QGIS/blob/master/src/core/qgsvectordataprovider.h</a><br></div><div>API Docs: <a href="http://qgis.org/api/qgsvectordataprovider_8h_source.html">http://qgis.org/api/qgsvectordataprovider_8h_source.html</a></div><div><br></div><div><br></div></div>

<p style="margin:0px;text-indent:0px"><span style="color:rgb(0,0,128)">In [</span><span style="font-weight:600;color:rgb(0,0,128)">70</span><span style="color:rgb(0,0,128)">]:</span> d = l.dataProvider()</p>
<p style="margin:0px;text-indent:0px"><br></p>
<p style="margin:0px;text-indent:0px"><span style="color:rgb(0,0,128)">In [</span><span style="font-weight:600;color:rgb(0,0,128)">71</span><span style="color:rgb(0,0,128)">]:</span> d</p>
<p style="margin:0px;text-indent:0px"><span style="color:rgb(139,0,0)">Out[</span><span style="font-weight:600;color:rgb(139,0,0)">71</span><span style="color:rgb(139,0,0)">]:</span> <qgis._core.QgsVectorDataProvider at 0x7f132375fb00></p>
<p style="margin:0px;text-indent:0px"><br></p>
<p style="margin:0px;text-indent:0px"><span style="color:rgb(0,0,128)">In [</span><span style="font-weight:600;color:rgb(0,0,128)">72</span><span style="color:rgb(0,0,128)">]:</span> d.capabilities?</p>
<p style="margin:0px;text-indent:0px"><span style="color:rgb(139,0,0)">Docstring: </span>QgsVectorDataProvider.capabilities() -> int</p>
<p style="margin:0px;text-indent:0px"><span style="color:rgb(139,0,0)">Type:      </span>builtin_function_or_method</p>
<p style="margin:0px;text-indent:0px"><br></p>
<p style="margin:0px;text-indent:0px"><span style="color:rgb(0,0,128)">In [</span><span style="font-weight:600;color:rgb(0,0,128)">73</span><span style="color:rgb(0,0,128)">]:</span> d.capabilities()</p>
<p style="margin:0px;text-indent:0px"><span style="color:rgb(139,0,0)">Out[</span><span style="font-weight:600;color:rgb(139,0,0)">73</span><span style="color:rgb(139,0,0)">]:</span> 115615</p>
<p style="margin:0px;text-indent:0px"><br></p>
<p style="margin:0px;text-indent:0px"><span style="color:rgb(0,0,128)">In [</span><span style="font-weight:600;color:rgb(0,0,128)">74</span><span style="color:rgb(0,0,128)">]:</span> d.__class__.capabilities2 = property(d.__class__.capabilities)</p>
<p style="margin:0px;text-indent:0px"><br></p>
<p style="margin:0px;text-indent:0px"><span style="color:rgb(0,0,128)">In [</span><span style="font-weight:600;color:rgb(0,0,128)">75</span><span style="color:rgb(0,0,128)">]:</span> d.capabilities2?</p>
<p style="margin:0px;text-indent:0px"><span style="color:rgb(139,0,0)">Type:        </span>property</p>
<p style="margin:0px;text-indent:0px"><span style="color:rgb(139,0,0)">String form: </span><property object at 0x7f1322ac6470></p>
<p style="margin:0px;text-indent:0px"><span style="color:rgb(139,0,0)">Docstring:   </span>QgsVectorDataProvider.capabilities() -> int</p>
<p style="margin:0px;text-indent:0px"><br></p>
<p style="margin:0px;text-indent:0px"><span style="color:rgb(0,0,128)"><br></span></p><p style="margin:0px;text-indent:0px"><span style="color:rgb(0,0,128)">In [</span><span style="font-weight:600;color:rgb(0,0,128)">76</span><span style="color:rgb(0,0,128)">]:</span> d.capabilities2</p>
<p style="margin:0px;text-indent:0px"><span style="color:rgb(139,0,0)">Out[</span><span style="font-weight:600;color:rgb(139,0,0)">76</span><span style="color:rgb(139,0,0)">]:</span> 0</p><br><br></div><div class="gmail_extra">The problem is that instruction 73 calls QgsPostgresProvider::capabilities() while instruction 76 calls QgsVectorDataProvider::capabilities() <a href="https://github.com/elpaso/QGIS/blob/master/src/core/qgsvectordataprovider.cpp#L107">https://github.com/elpaso/QGIS/blob/master/src/core/qgsvectordataprovider.cpp#L107</a> and returns 0 (NO CAPABILITIES).<br></div><div class="gmail_extra"><br clear="all"></div><div class="gmail_extra">Am I doing something wrong?<br><br></div><div class="gmail_extra">-- <br><div class="gmail_signature">Alessandro Pasotti<br>w3:   <a href="http://www.itopen.it" target="_blank">www.itopen.it</a></div>
</div></div>