Hi, we're currently migrating our Python 2.x PyQt4 code from QString/QVariant/... SIP API version 1 to version 2 in preparation for Python 3. The app works fine and we're quite happy with API version 2.
Unfortunately, our app specific Qt Designer plugins have stopped working. The plugins use code from the app and therefore now depend on API version 2, but the PyQt designer plugin loader loads PyQt4.QtDesigner.QPyDesignerCustomWidgetPlugin before loading any of our plugins and therefore the API version gets set to the default (version 1). The attached patch lazy loads PyQt4.QtDesigner.QPyDesignerCustomWidgetPlugin after the first successful plugin module import. Assuming full control over all plugins and further assuming that all plugins use the same API versions, this allows the plugins to call sip.setapi before any default APIs are set. Would something like this be acceptable upstream? Cheers Fabian PS: The patch is against 4.7.3, but (as far as I can tell) 4.9 doesn't appear to have changed much in designer/pluginloader.cpp
Index: python-qt4-4.7.3/designer/pluginloader.cpp =================================================================== --- python-qt4-4.7.3.orig/designer/pluginloader.cpp 2012-01-03 16:22:04.348413741 +0100 +++ python-qt4-4.7.3/designer/pluginloader.cpp 2012-01-03 16:14:48.527366456 +0100 @@ -164,15 +164,6 @@ return; } - // Make sure we have sip.unwrapinstance. - if (!qtdesigner_custom) - { - qtdesigner_custom = getModuleAttr("PyQt4.QtDesigner", "QPyDesignerCustomWidgetPlugin"); - - if (!qtdesigner_custom) - return; - } - // Convert the directory to a Python object with native separators. #if QT_VERSION >= 0x040200 dir = QDir::toNativeSeparators(dir); @@ -226,6 +217,17 @@ continue; } + // Make sure we have PyQt4.QtDesigner.QPyDesignerCustomWidgetPlugin + // Note that we wait this late to give the first plugin the chance + // to configure the PyQt4 API versions. + if (!qtdesigner_custom) + { + qtdesigner_custom = getModuleAttr("PyQt4.QtDesigner", "QPyDesignerCustomWidgetPlugin"); + + if (!qtdesigner_custom) + return; + } + // Go through the module looking for types that implement // QDesignerCustomWidgetInterface (ie. by deriving from // QPyDesignerCustomWidgetPlugin).
_______________________________________________ PyQt mailing list PyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt