<p dir="ltr">Den 9 mars 2017 8:40 fm skrev "Elvis Stansvik" <<a href="mailto:elvstone@gmail.com">elvstone@gmail.com</a>>:<br>
><br>
> Den 9 mars 2017 8:11 fm skrev "Shaheed Haque" <<a href="mailto:srhaque@theiet.org">srhaque@theiet.org</a>>:<br>
> ><br>
> > Hi,<br>
> ><br>
> > I have come across some odd behaviour from SIP for a few of the files<br>
> > I am generating such that SIP seems to be treating private methods as<br>
> > if they were not private. For example, in one such case, the C++<br>
> > header looks like this:<br>
> ><br>
> > /usr/include/KF5/AkonadiCore/tagmodel.h<br>
> > ==============================<br>
> > namespace Akonadi {<br>
> > class TagModel: public QAbstractItemModel {<br>
> > ...<br>
> > Q_SIGNALS:<br>
> > void populated();<br>
> ><br>
> > private:<br>
> > bool insertRows(int row, int count, const QModelIndex &index =<br>
> > QModelIndex()) Q_DECL_OVERRIDE;<br>
> > bool insertColumns(int column, int count, const QModelIndex &index<br>
> > = QModelIndex()) Q_DECL_OVERRIDE;<br>
> > bool removeColumns(int column, int count, const QModelIndex &index<br>
> > = QModelIndex()) Q_DECL_OVERRIDE;<br>
> > bool removeRows(int row, int count, const QModelIndex &index =<br>
> > QModelIndex()) Q_DECL_OVERRIDE;<br>
> > ...<br>
> > };<br>
> > ==============================<br>
> ><br>
> > And the SIP file says:<br>
> ><br>
> > ==============================<br>
> > namespace Akonadi {<br>
> > class TagModel: QAbstractItemModel {<br>
> > ...<br>
> > Q_SIGNALS:<br>
> > void populated();<br>
> > private:<br>
> > private:<br>
> > // Generated for tagmodel.h, CLASS_DECL on line 36 'TagModel'<br>
> > (by sip_generator.py:_container_get): non-copyable type handling<br>
> > TagModel(const Akonadi::TagModel &);<br>
> > };<br>
> > };<br>
> > ==============================<br>
> ><br>
> > Notice how the SIP does not contain the private member insertRows(),<br>
> > e.g. after the populated() Q_SIGNAL. However, when I try to compile<br>
> > the generated SIP, I see errors like this:<br>
> ><br>
> > ==============================<br>
> > In file included from unifiedAkonadiCore.cpp:36:0:<br>
> > tmp2/tmp/PyKF5/AkonadiCore/sipAkonadiCoreAkonadiTagModel.cpp: In<br>
> > member function ‘virtual bool sipAkonadi_TagModel::insertRows(int,<br>
> > int, const QModelIndex&)’:<br>
> > tmp2/tmp/PyKF5/AkonadiCore/sipAkonadiCoreAkonadiTagModel.cpp:2564:54:<br>
> > error: ‘virtual bool Akonadi::TagModel::insertRows(int, int, const<br>
> > QModelIndex&)’ is private within this context<br>
> > In file included from /usr/include/KF5/AkonadiCore/TagModel:1:0,<br>
> > from tmp/AkonadiCore/TagModel.sip:28,<br>
> > from unifiedAkonadiCore.cpp:8:<br>
> > /usr/include/KF5/AkonadiCore/tagmodel.h:83:10: note: declared private here<br>
> > bool insertRows(int row, int count, const QModelIndex &index =<br>
> > QModelIndex()) Q_DECL_OVERRIDE;<br>
> > ^~~~~~~~~~<br>
> > ===============================<br>
> ><br>
> > And sure enough, the generated class sipAkonadi_TagMode has a<br>
> > protected member for insertRows() in the section commented "There is a<br>
> > protected method for every virtual method...". Have I missed something<br>
> > or is this a known issue?<br>
><br>
> I've never used SIP, so this is just a guess, but maybe its confusion comes from the fact that those methods are public in the base class, and your class is publicly inheriting it? I would say it was probably a mistake to declare them private?<br>
><br>
> I'm not good enough with C++ to know what happens then, but I think that (at least in C++11) if you want to make a public method private in the subclass, you should use private: Base::fun();<br>
><br>
> Not sure what is happening with SIP here though, Phil will have to answer.</p>
<p dir="ltr">My suspicion would be that some part of SIP's machinery thinks they are public (which I think is what they are, being declared as such in the base class), while another thinks they're private (because of the attempt to hide them in the derived class). If so, then maybe there's room for improvement in SIP to make it sort it out properly.</p>
<p dir="ltr">But this is just a guess :)</p>
<p dir="ltr">Elvis</p>
<p dir="ltr">><br>
> Cheers,<br>
> Elvis<br>
><br>
> ><br>
> > Thanks, Shaheed<br>
> > _______________________________________________<br>
> > PyQt mailing list <a href="mailto:PyQt@riverbankcomputing.com">PyQt@riverbankcomputing.com</a><br>
> > <a href="https://www.riverbankcomputing.com/mailman/listinfo/pyqt">https://www.riverbankcomputing.com/mailman/listinfo/pyqt</a><br></p>