[PyQt] Debug output for pyqt5.dll Designer plugin
Kyle Altendorf
sda at fstab.net
Tue Aug 9 14:19:12 BST 2016
Is there any interest in adding some debug output to the pyqt5.dll
Designer plugin? In Windows it fails (almost) completely silently.
The patch included below is incomplete in that it provides only a very
little bit of debugging info but works using both QMessageBox and
QDebug. The QDebug output is available in Windows via at least
DebugView.
https://technet.microsoft.com/en-us/sysinternals/debugview.aspx
The patch is inline below as well as attached.
Cheers,
-kyle
diff -ru clean/PyQt5_gpl-5.7/designer/pluginloader.cpp
PyQt5_gpl-5.7-designer/designer/pluginloader.cpp
--- clean/PyQt5_gpl-5.7/designer/pluginloader.cpp 2016-07-25
14:56:44.000000000 -0700
+++ PyQt5_gpl-5.7-designer/designer/pluginloader.cpp 2016-08-09
06:08:59.618045800 -0700
@@ -33,13 +33,19 @@
#include <QStringList>
#include <QVector>
#include <QtDesigner>
+#include <QDebug>
+
+#include <QMessageBox>
#include "../qpy/QtDesigner/qpydesignercustomwidgetplugin.h"
+#define debug() qDebug() << "pyqt5.dll: "
+
// Construct the collection of Python widgets.
PyCustomWidgets::PyCustomWidgets(QObject *parent) : QObject(parent)
{
+ debug() << "PyCustomWidgets::PyCustomWidgets()";
// Get the default list of directories to search. These correspond
to a
// standard "python" subdirectory of all the places that Designer
looks for
// its own plugins.
@@ -127,12 +133,21 @@
// possible.
if (!Py_IsInitialized())
{
+ debug() << "PyCustomWidgets::PyCustomWidgets(): Attempting
to load" PYTHON_LIB;
+
QLibrary library(PYTHON_LIB);
library.setLoadHints(QLibrary::ExportExternalSymbolsHint);
if (!library.load())
+ {
+ debug() << "PyCustomWidgets::PyCustomWidgets():
Loading " PYTHON_LIB " failed";
+
+ QMessageBox::critical(NULL, "PyQt5 Qt Designer Plugin",
"Failed to load " PYTHON_LIB);
return;
+ }
+
+ debug() << "PyCustomWidgets::PyCustomWidgets(): Loading "
PYTHON_LIB " succeeded";
Py_Initialize();
}
@@ -143,7 +158,12 @@
sys_path = getModuleAttr("sys", "path");
if (!sys_path)
+ {
+ debug() << "PyCustomWidgets::PyCustomWidgets():
sys_path not found";
return;
+ }
+
+ debug() << "PyCustomWidgets::PyCustomWidgets(): sys_path:
" << PyUnicode_AS_DATA(sys_path);
}
// Make sure we have sip.unwrapinstance.
@@ -152,7 +172,10 @@
sip_unwrapinstance = getModuleAttr("sip",
"unwrapinstance");
if (!sip_unwrapinstance)
+ {
+ debug() << "PyCustomWidgets::PyCustomWidgets():
sip_unwrapinstance not found";
return;
+ }
}
// Convert the directory to a Python object with native
separators.
@@ -300,6 +323,7 @@
if (!mod)
{
+ debug() << "PyCustomWidgets::getModuleAttr(): failed to
import" << module;
PyErr_Print();
return 0;
}
@@ -310,6 +334,7 @@
if (!obj)
{
+ debug() << "PyCustomWidgets::getModuleAttr(): failed to get
attribute" << attr << " from " << module;
PyErr_Print();
return 0;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: designer_plugin_debug.patch
Type: text/x-diff
Size: 2798 bytes
Desc: not available
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20160809/3d84641f/attachment.patch>
More information about the PyQt
mailing list