Skip to content

Commit dbd8dbd

Browse files
committed
Add method allowing to know if a python error occurred.
Conflicts: src/PythonQt.cpp src/PythonQt.h
1 parent 9814246 commit dbd8dbd

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/PythonQt.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,6 +1115,7 @@ PythonQtPrivate::PythonQtPrivate()
11151115
_wrappedCB = NULL;
11161116
_currentClassInfoForClassWrapperCreation = NULL;
11171117
_profilingCB = NULL;
1118+
_ErrorOccured = false;
11181119
}
11191120

11201121
void PythonQtPrivate::setupSharedLibrarySuffixes()
@@ -1233,9 +1234,15 @@ bool PythonQt::handleError()
12331234
PyErr_Clear();
12341235
flag = true;
12351236
}
1237+
PythonQt::priv()->_ErrorOccured = flag;
12361238
return flag;
12371239
}
12381240

1241+
bool PythonQt::errorOccured()const
1242+
{
1243+
return PythonQt::priv()->_ErrorOccured;
1244+
}
1245+
12391246
void PythonQt::addSysPath(const QString& path)
12401247
{
12411248
PythonQtObjectPtr sys;

src/PythonQt.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,9 @@ class PYTHONQT_EXPORT PythonQt : public QObject {
481481
//! newly loaded wrappers can add methods even when the object was wrapped by PythonQt before the wrapper was loaded
482482
void clearNotFoundCachedMembers();
483483

484+
//! return \a True if \a handleError() has been called and an error occured.
485+
bool errorOccured()const;
486+
484487
//! set a callback that is called when a QObject with parent == NULL is wrapped by pythonqt
485488
void setQObjectWrappedCallback(PythonQtQObjectWrappedCB* cb);
486489
//! set a callback that is called when a QObject with parent == NULL is no longer wrapped by pythonqt
@@ -708,6 +711,8 @@ class PYTHONQT_EXPORT PythonQtPrivate : public QObject {
708711
int _initFlags;
709712
int _PythonQtObjectPtr_metaId;
710713

714+
bool _ErrorOccured;
715+
711716
friend class PythonQt;
712717
};
713718

0 commit comments

Comments
 (0)