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

List:       pykde
Subject:    Re: [sip] random crashes when using QMetaEnum
From:       Phil Thompson <phil () riverbankcomputing ! com>
Date:       2020-09-11 13:17:34
Message-ID: fb8e8b147f641f9b6776462e89916a45 () riverbankcomputing ! com
[Download RAW message or body]

On 08/09/2020 13:39, Denis Rouzaud wrote:
> Hi list,
> 
> For an enum (not scoped based), I am running this code:
> 
> for i in range(0, 100):
>     idx =
> QgsDataSourceUri.staticMetaObject.indexOfEnumerator(QgsDataSourceUri.SslMode.__name__)
>     meta_enum = QgsDataSourceUri.staticMetaObject.enumerator(idx)
>     print(meta_enum.isValid())
>     sleep(.3)
> 
> I usually get a crash after 2 to 6 iterations.
> Code is hereunder.
> 
> As far as I can tell, this happens to any version of SIP above 4.19.17 
> (not
> tested under).
> 
> Cheers,
> Denis
> 
> The enum is defined as follows:
> 
> class CORE_EXPORT QgsDataSourceUri
> 
> {
> 
>     Q_GADGET
> 
>   public:
> 
>     enum SslMode
> 
>     {
> 
>       SslPrefer,
> 
>       SslDisable,
> 
>       SslAllow,
> 
>       SslRequire,
> 
>       SslVerifyCa,
> 
>       SslVerifyFull
> 
>     };
> 
>     Q_ENUM( SslMode )
> 
>     QgsDataSourceUri();
> 
> 
> The sip file:
> 
> class QgsDataSourceUri
> 
> {
> 
> %TypeHeaderCode
> 
> #include "qgsdatasourceuri.h"
> 
> %End
> 
>   public:
> 
>     static const QMetaObject staticMetaObject;
> 
>   public:
> 
>     enum SslMode
> 
>     {
> 
>       SslPrefer,
> 
>       SslDisable,
> 
>       SslAllow,
> 
>       SslRequire,
> 
>       SslVerifyCa,
> 
>       SslVerifyFull
> 
>     };
> 
>     QgsDataSourceUri();

I can't reproduce this with a test case I can actually run...

from time import sleep

from PyQt5.QtCore import QState


for i in range(0, 100):
     idx = QState.staticMetaObject.indexOfEnumerator(
             QState.ChildMode.__name__)
     meta_enum = QState.staticMetaObject.enumerator(idx)
     print(meta_enum.isValid())
     sleep(.3)

...using current versions.

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

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