Skip to content

Commit

Permalink
ENH: Add method allowing to know if a python error occurred.
Browse files Browse the repository at this point in the history
  • Loading branch information
jcfr committed Mar 10, 2012
1 parent 7e1e07f commit 5935f29
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/PythonQt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -978,6 +978,7 @@ PythonQtPrivate::PythonQtPrivate()
_noLongerWrappedCB = NULL;
_wrappedCB = NULL;
_currentClassInfoForClassWrapperCreation = NULL;
_ErrorOccured = false;
}

void PythonQtPrivate::setupSharedLibrarySuffixes()
Expand Down Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions src/PythonQt.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -647,6 +650,8 @@ class PYTHONQT_EXPORT PythonQtPrivate : public QObject {
int _initFlags;
int _PythonQtObjectPtr_metaId;

bool _ErrorOccured;

friend class PythonQt;
};

Expand Down

0 comments on commit 5935f29

Please sign in to comment.