From 5935f29978deed892a13ddef02cb14c205c6124d Mon Sep 17 00:00:00 2001 From: Jean-Christophe Fillion-Robin Date: Sat, 10 Mar 2012 04:05:48 -0500 Subject: [PATCH] ENH: Add method allowing to know if a python error occurred. --- src/PythonQt.cpp | 7 +++++++ src/PythonQt.h | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/src/PythonQt.cpp b/src/PythonQt.cpp index 342e6226..df4cbbea 100644 --- a/src/PythonQt.cpp +++ b/src/PythonQt.cpp @@ -978,6 +978,7 @@ PythonQtPrivate::PythonQtPrivate() _noLongerWrappedCB = NULL; _wrappedCB = NULL; _currentClassInfoForClassWrapperCreation = NULL; + _ErrorOccured = false; } void PythonQtPrivate::setupSharedLibrarySuffixes() @@ -1088,9 +1089,15 @@ bool PythonQt::handleError() PyErr_Clear(); flag = true; } + PythonQt::priv()->_ErrorOccured = flag; return flag; } +bool PythonQt::errorOccured()const +{ + return PythonQt::priv()->_ErrorOccured; +} + void PythonQt::addSysPath(const QString& path) { PythonQtObjectPtr sys; diff --git a/src/PythonQt.h b/src/PythonQt.h index 3ec29229..c766eca0 100644 --- a/src/PythonQt.h +++ b/src/PythonQt.h @@ -446,6 +446,9 @@ class PYTHONQT_EXPORT PythonQt : public QObject { //! The error is currently just output to the python stderr, future version might implement better trace printing bool handleError(); + //! return \a True if \a handleError() has been called and an error occured. + bool errorOccured()const; + //! set a callback that is called when a QObject with parent == NULL is wrapped by pythonqt void setQObjectWrappedCallback(PythonQtQObjectWrappedCB* cb); //! set a callback that is called when a QObject with parent == NULL is no longer wrapped by pythonqt @@ -647,6 +650,8 @@ class PYTHONQT_EXPORT PythonQtPrivate : public QObject { int _initFlags; int _PythonQtObjectPtr_metaId; + bool _ErrorOccured; + friend class PythonQt; };