2

When I do in the Python QGIS console QgsColorSchemeRegistry.instance().schemes(), it returns the following

[<qgis._core.QgsColorScheme object at 0x7f6cc5d8ccc8>,
 <qgis._core.QgsColorScheme object at 0x7f6cc5d8c938>,
 <qgis._core.QgsColorScheme object at 0x7f6cc5f54c30>]

If I loop the schemes with [scheme.schemeName() for scheme in QgsColorSchemeRegistry.instance().schemes()], I get:

[u'Recent colors',
 u'Standard colors',
 u'Project colors']

So, it seems that all schemes have been through a cast so the only way to make the difference is via their schemeName but it's not generic when you use other languages.

In my understanding, I would expect a list with returned content like below:

[<qgis._core.QgsRecentColorScheme object at 0x7f6cc5d8ccc8>,
 <qgis._core.QgsGplColorScheme object at 0x7f6cc5d8c938>,
 <qgis._core.QgsProjectColorScheme object at 0x7f6cc5f54c30>]

First, my guess is right?

Secondly, what is the "best" way to manage this case properly, if any?

1

Seems it was a bug in QGIS <= 2.12. Coincidentally I'd fixed it just a few days before your question (https://github.com/qgis/QGIS/commit/de1001b9f78dedc511be1b5de594308efdf686de) .

So in QGIS > 2.12.1 this will behave correctly.

In response to your second question: "what is the "best" way to manage this case properly, if any?"

File a bug over at http://hub.qgis.org. It needs to be fixed in QGIS itself, so we'd very much like to know if you encounter situations like this.

  • if type are "right" like described, I think I can manage it by testing with isinstance without continuing to manage tests via the schemeName(). I don't think I should open a new bug, with your correction. I missed something? – ThomasG77 Dec 13 '15 at 23:32
  • No need to file a bug about this one, it's fixed now. I just meant if you encountered other cases where python objects aren't correctly downcast. – ndawson Dec 14 '15 at 1:37
  • Just a ping about something related (impossibility to have a reference to a QWidgetAction with a deterministic approach) hub.qgis.org/issues/14011 – ThomasG77 Dec 18 '15 at 21:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.