Skip to content

Commit 5935f29

Browse files
committedMar 10, 2012
ENH: Add method allowing to know if a python error occurred.
1 parent 7e1e07f commit 5935f29

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed
 

‎src/PythonQt.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -978,6 +978,7 @@ PythonQtPrivate::PythonQtPrivate()
978978
_noLongerWrappedCB = NULL;
979979
_wrappedCB = NULL;
980980
_currentClassInfoForClassWrapperCreation = NULL;
981+
_ErrorOccured = false;
981982
}
982983

983984
void PythonQtPrivate::setupSharedLibrarySuffixes()
@@ -1088,9 +1089,15 @@ bool PythonQt::handleError()
10881089
PyErr_Clear();
10891090
flag = true;
10901091
}
1092+
PythonQt::priv()->_ErrorOccured = flag;
10911093
return flag;
10921094
}
10931095

1096+
bool PythonQt::errorOccured()const
1097+
{
1098+
return PythonQt::priv()->_ErrorOccured;
1099+
}
1100+
10941101
void PythonQt::addSysPath(const QString& path)
10951102
{
10961103
PythonQtObjectPtr sys;

‎src/PythonQt.h

+5
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,9 @@ class PYTHONQT_EXPORT PythonQt : public QObject {
446446
//! The error is currently just output to the python stderr, future version might implement better trace printing
447447
bool handleError();
448448

449+
//! return \a True if \a handleError() has been called and an error occured.
450+
bool errorOccured()const;
451+
449452
//! set a callback that is called when a QObject with parent == NULL is wrapped by pythonqt
450453
void setQObjectWrappedCallback(PythonQtQObjectWrappedCB* cb);
451454
//! 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 {
647650
int _initFlags;
648651
int _PythonQtObjectPtr_metaId;
649652

653+
bool _ErrorOccured;
654+
650655
friend class PythonQt;
651656
};
652657

0 commit comments

Comments
 (0)
Please sign in to comment.