[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: [PyQt] SIP 4.18.1 appears to be exposing private methods?
From:       Elvis Stansvik <elvstone () gmail ! com>
Date:       2017-03-10 17:22:47
Message-ID: CAHms=eY08Sq=qVAWyRobDgfL2dt+Zy7ebvWViub1SewKj-R=Bg () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Den 9 mars 2017 8:09 em skrev "Shaheed Haque" <srhaque@theiet.org>:
>
> Yup, that fixed it. Thanks!

So please throw my ramblings in the garbage bin :)

Elvis

>
> For the record, it only seems to cause a problem when the base class
> (the one exposing the public function) has virtual methods, which is
> why most classes were not exhibiting the problem. But rather than rely
> on this, I just turned all private methods on.
>
> On 9 March 2017 at 13:41, Phil Thompson <phil@riverbankcomputing.com>
wrote:
> > On 09/03/2017 07:10, Shaheed Haque wrote:
> >>
> >> Hi,
> >>
> >> I have come across some odd behaviour from SIP for a few of the files
> >> I am generating such that SIP seems to be treating private methods as
> >> if they were not private. For example, in one such case, the C++
> >> header looks like this:
> >>
> >> /usr/include/KF5/AkonadiCore/tagmodel.h
> >> ==============================
> >> namespace Akonadi {
> >> class TagModel: public QAbstractItemModel {
> >> ...
> >> Q_SIGNALS:
> >>     void populated();
> >>
> >> private:
> >>     bool insertRows(int row, int count, const QModelIndex &index =
> >> QModelIndex()) Q_DECL_OVERRIDE;
> >>     bool insertColumns(int column, int count, const QModelIndex &index
> >> = QModelIndex()) Q_DECL_OVERRIDE;
> >>     bool removeColumns(int column, int count, const QModelIndex &index
> >> = QModelIndex()) Q_DECL_OVERRIDE;
> >>     bool removeRows(int row, int count, const QModelIndex &index =
> >> QModelIndex()) Q_DECL_OVERRIDE;
> >> ...
> >> };
> >> ==============================
> >>
> >> And the SIP file says:
> >>
> >> ==============================
> >> namespace Akonadi {
> >> class TagModel: QAbstractItemModel {
> >> ...
> >>     Q_SIGNALS:
> >>         void populated();
> >>     private:
> >>     private:
> >>         // Generated for tagmodel.h, CLASS_DECL on line 36 'TagModel'
> >> (by sip_generator.py:_container_get): non-copyable type handling
> >>         TagModel(const Akonadi::TagModel &);
> >>     };
> >> };
> >> ==============================
> >>
> >> Notice how the SIP does not contain the private member insertRows(),
> >> e.g. after the populated() Q_SIGNAL. However, when I try to compile
> >> the generated SIP, I see errors like this:
> >>
> >> ==============================
> >> In file included from unifiedAkonadiCore.cpp:36:0:
> >> tmp2/tmp/PyKF5/AkonadiCore/sipAkonadiCoreAkonadiTagModel.cpp: In
> >> member function ‘virtual bool sipAkonadi_TagModel::insertRows(int,
> >> int, const QModelIndex&)':
> >> tmp2/tmp/PyKF5/AkonadiCore/sipAkonadiCoreAkonadiTagModel.cpp:2564:54:
> >> error: ‘virtual bool Akonadi::TagModel::insertRows(int, int, const
> >> QModelIndex&)' is private within this context
> >> In file included from /usr/include/KF5/AkonadiCore/TagModel:1:0,
> >>                  from tmp/AkonadiCore/TagModel.sip:28,
> >>                  from unifiedAkonadiCore.cpp:8:
> >> /usr/include/KF5/AkonadiCore/tagmodel.h:83:10: note: declared private
here
> >>      bool insertRows(int row, int count, const QModelIndex &index =
> >> QModelIndex()) Q_DECL_OVERRIDE;
> >>           ^~~~~~~~~~
> >> ===============================
> >>
> >> And sure enough, the generated class sipAkonadi_TagMode has a
> >> protected member for insertRows() in the section commented "There is a
> >> protected method for every virtual method...". Have I missed something
> >> or is this a known issue?
> >
> >
> > You need to add the private methods to the .sip file.
> >
> > Phil
> _______________________________________________
> PyQt mailing list    PyQt@riverbankcomputing.com
> https://www.riverbankcomputing.com/mailman/listinfo/pyqt

[Attachment #5 (text/html)]

<p dir="ltr">Den 9 mars 2017 8:09 em skrev &quot;Shaheed Haque&quot; &lt;<a \
href="mailto:srhaque@theiet.org">srhaque@theiet.org</a>&gt;:<br> &gt;<br>
&gt; Yup, that fixed it. Thanks!</p>
<p dir="ltr">So please throw my ramblings in the garbage bin :)</p>
<p dir="ltr">Elvis</p>
<p dir="ltr">&gt;<br>
&gt; For the record, it only seems to cause a problem when the base class<br>
&gt; (the one exposing the public function) has virtual methods, which is<br>
&gt; why most classes were not exhibiting the problem. But rather than rely<br>
&gt; on this, I just turned all private methods on.<br>
&gt;<br>
&gt; On 9 March 2017 at 13:41, Phil Thompson &lt;<a \
href="mailto:phil@riverbankcomputing.com">phil@riverbankcomputing.com</a>&gt; \
wrote:<br> &gt; &gt; On 09/03/2017 07:10, Shaheed Haque wrote:<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; Hi,<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; I have come across some odd behaviour from SIP for a few of the \
files<br> &gt; &gt;&gt; I am generating such that SIP seems to be treating private \
methods as<br> &gt; &gt;&gt; if they were not private. For example, in one such case, \
the C++<br> &gt; &gt;&gt; header looks like this:<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; /usr/include/KF5/AkonadiCore/tagmodel.h<br>
&gt; &gt;&gt; ==============================<br>
&gt; &gt;&gt; namespace Akonadi {<br>
&gt; &gt;&gt; class TagModel: public QAbstractItemModel {<br>
&gt; &gt;&gt; ...<br>
&gt; &gt;&gt; Q_SIGNALS:<br>
&gt; &gt;&gt;        void populated();<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; private:<br>
&gt; &gt;&gt;        bool insertRows(int row, int count, const QModelIndex &amp;index \
=<br> &gt; &gt;&gt; QModelIndex()) Q_DECL_OVERRIDE;<br>
&gt; &gt;&gt;        bool insertColumns(int column, int count, const QModelIndex \
&amp;index<br> &gt; &gt;&gt; = QModelIndex()) Q_DECL_OVERRIDE;<br>
&gt; &gt;&gt;        bool removeColumns(int column, int count, const QModelIndex \
&amp;index<br> &gt; &gt;&gt; = QModelIndex()) Q_DECL_OVERRIDE;<br>
&gt; &gt;&gt;        bool removeRows(int row, int count, const QModelIndex &amp;index \
=<br> &gt; &gt;&gt; QModelIndex()) Q_DECL_OVERRIDE;<br>
&gt; &gt;&gt; ...<br>
&gt; &gt;&gt; };<br>
&gt; &gt;&gt; ==============================<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; And the SIP file says:<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; ==============================<br>
&gt; &gt;&gt; namespace Akonadi {<br>
&gt; &gt;&gt; class TagModel: QAbstractItemModel {<br>
&gt; &gt;&gt; ...<br>
&gt; &gt;&gt;        Q_SIGNALS:<br>
&gt; &gt;&gt;              void populated();<br>
&gt; &gt;&gt;        private:<br>
&gt; &gt;&gt;        private:<br>
&gt; &gt;&gt;              // Generated for tagmodel.h, CLASS_DECL on line 36 \
&#39;TagModel&#39;<br> &gt; &gt;&gt; (by sip_generator.py:_container_get): \
non-copyable type handling<br> &gt; &gt;&gt;              TagModel(const \
Akonadi::TagModel &amp;);<br> &gt; &gt;&gt;        };<br>
&gt; &gt;&gt; };<br>
&gt; &gt;&gt; ==============================<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; Notice how the SIP does not contain the private member \
insertRows(),<br> &gt; &gt;&gt; e.g. after the populated() Q_SIGNAL. However, when I \
try to compile<br> &gt; &gt;&gt; the generated SIP, I see errors like this:<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; ==============================<br>
&gt; &gt;&gt; In file included from unifiedAkonadiCore.cpp:36:0:<br>
&gt; &gt;&gt; tmp2/tmp/PyKF5/AkonadiCore/sipAkonadiCoreAkonadiTagModel.cpp: In<br>
&gt; &gt;&gt; member function ‘virtual bool \
sipAkonadi_TagModel::insertRows(int,<br> &gt; &gt;&gt; int, const \
QModelIndex&amp;)':<br> &gt; &gt;&gt; \
tmp2/tmp/PyKF5/AkonadiCore/sipAkonadiCoreAkonadiTagModel.cpp:2564:54:<br> &gt; \
&gt;&gt; error: ‘virtual bool Akonadi::TagModel::insertRows(int, int, const<br> \
&gt; &gt;&gt; QModelIndex&amp;)' is private within this context<br> &gt; &gt;&gt; In \
file included from /usr/include/KF5/AkonadiCore/TagModel:1:0,<br> &gt; &gt;&gt;       \
from tmp/AkonadiCore/TagModel.sip:28,<br> &gt; &gt;&gt;                           \
from unifiedAkonadiCore.cpp:8:<br> &gt; &gt;&gt; \
/usr/include/KF5/AkonadiCore/tagmodel.h:83:10: note: declared private here<br> &gt; \
&gt;&gt;         bool insertRows(int row, int count, const QModelIndex &amp;index \
=<br> &gt; &gt;&gt; QModelIndex()) Q_DECL_OVERRIDE;<br>
&gt; &gt;&gt;                 ^~~~~~~~~~<br>
&gt; &gt;&gt; ===============================<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; And sure enough, the generated class sipAkonadi_TagMode has a<br>
&gt; &gt;&gt; protected member for insertRows() in the section commented &quot;There \
is a<br> &gt; &gt;&gt; protected method for every virtual method...&quot;. Have I \
missed something<br> &gt; &gt;&gt; or is this a known issue?<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt; You need to add the private methods to the .sip file.<br>
&gt; &gt;<br>
&gt; &gt; Phil<br>
&gt; _______________________________________________<br>
&gt; PyQt mailing list      <a \
href="mailto:PyQt@riverbankcomputing.com">PyQt@riverbankcomputing.com</a><br> &gt; <a \
href="https://www.riverbankcomputing.com/mailman/listinfo/pyqt">https://www.riverbankcomputing.com/mailman/listinfo/pyqt</a><br></p>



[Attachment #6 (text/plain)]

_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
https://www.riverbankcomputing.com/mailman/listinfo/pyqt

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic