Permalink
Browse files

ENH: Add method allowing to know if a python error occurred.

  • Loading branch information...
1 parent 7e1e07f commit 5935f29978deed892a13ddef02cb14c205c6124d @jcfr jcfr committed Mar 10, 2012
Showing with 12 additions and 0 deletions.
  1. +7 −0 src/PythonQt.cpp
  2. +5 −0 src/PythonQt.h
View
@@ -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;
View
@@ -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;
};

0 comments on commit 5935f29

Please sign in to comment.