diff --git a/src/PythonQt.cpp b/src/PythonQt.cpp index d87d1097..642afb2a 100644 --- a/src/PythonQt.cpp +++ b/src/PythonQt.cpp @@ -53,7 +53,7 @@ #include "PythonQtStdDecorators.h" #include "PythonQtQFileImporter.h" #include -#include + PythonQt* PythonQt::_self = NULL; int PythonQt::_uniqueModuleCount = 0; @@ -142,7 +142,7 @@ void PythonQt::init(int flags, const QByteArray& pythonQtModuleName) Py_INCREF(obj); PyModule_AddObject(pack2, names[i], obj); } else { - std::cerr << "method not found " << names[i] << std::endl; + qWarning() << "method not found " << names[i]; } } } @@ -180,12 +180,12 @@ PythonQt::PythonQt(int flags, const QByteArray& pythonQtModuleName) // add our own python object types for qt object slots if (PyType_Ready(&PythonQtSlotFunction_Type) < 0) { - std::cerr << "could not initialize PythonQtSlotFunction_Type" << ", in " << __FILE__ << ":" << __LINE__ << std::endl; + qWarning() << "could not initialize PythonQtSlotFunction_Type" << ", in " << __FILE__ << ":" << __LINE__; } Py_INCREF(&PythonQtSlotFunction_Type); if (PyType_Ready(&PythonQtSignalFunction_Type) < 0) { - std::cerr << "could not initialize PythonQtSignalFunction_Type" << ", in " << __FILE__ << ":" << __LINE__ << std::endl; + qWarning() << "could not initialize PythonQtSignalFunction_Type" << ", in " << __FILE__ << ":" << __LINE__; } Py_INCREF(&PythonQtSignalFunction_Type); @@ -193,26 +193,26 @@ PythonQt::PythonQt(int flags, const QByteArray& pythonQtModuleName) PythonQtClassWrapper_Type.tp_base = &PyType_Type; // add our own python object types for classes if (PyType_Ready(&PythonQtClassWrapper_Type) < 0) { - std::cerr << "could not initialize PythonQtClassWrapper_Type" << ", in " << __FILE__ << ":" << __LINE__ << std::endl; + qWarning() << "could not initialize PythonQtClassWrapper_Type" << ", in " << __FILE__ << ":" << __LINE__; } Py_INCREF(&PythonQtClassWrapper_Type); // add our own python object types for CPP instances if (PyType_Ready(&PythonQtInstanceWrapper_Type) < 0) { PythonQt::handleError(); - std::cerr << "could not initialize PythonQtInstanceWrapper_Type" << ", in " << __FILE__ << ":" << __LINE__ << std::endl; + qWarning() << "could not initialize PythonQtInstanceWrapper_Type" << ", in " << __FILE__ << ":" << __LINE__; } Py_INCREF(&PythonQtInstanceWrapper_Type); // add our own python object types for redirection of stdout if (PyType_Ready(&PythonQtStdOutRedirectType) < 0) { - std::cerr << "could not initialize PythonQtStdOutRedirectType" << ", in " << __FILE__ << ":" << __LINE__ << std::endl; + qWarning() << "could not initialize PythonQtStdOutRedirectType" << ", in " << __FILE__ << ":" << __LINE__; } Py_INCREF(&PythonQtStdOutRedirectType); // add our own python object types for redirection of stdin if (PyType_Ready(&PythonQtStdInRedirectType) < 0) { - std::cerr << "could not initialize PythonQtStdInRedirectType" << ", in " << __FILE__ << ":" << __LINE__ << std::endl; + qWarning() << "could not initialize PythonQtStdInRedirectType" << ", in " << __FILE__ << ":" << __LINE__; } Py_INCREF(&PythonQtStdInRedirectType); @@ -246,7 +246,7 @@ void PythonQt::setRedirectStdInCallback(PythonQtInputChangedCB* callback, void * { if (!callback) { - std::cerr << "PythonQt::setRedirectStdInCallback - callback parameter is NULL !" << std::endl; + qWarning() << "PythonQt::setRedirectStdInCallback - callback parameter is NULL !"; return; } @@ -1011,7 +1011,7 @@ QStringList PythonQt::introspectObject(PyObject* object, ObjectType type) } break; default: - std::cerr << "PythonQt: introspection: unknown case" << ", in " << __FILE__ << ":" << __LINE__ << std::endl; + qWarning() << "PythonQt: introspection: unknown case" << ", in " << __FILE__ << ":" << __LINE__; } } Py_DECREF(value); @@ -1355,12 +1355,12 @@ int custom_system_exit_exception_handler() PyErr_Fetch(&exception, &value, &tb); #ifdef PY3K - std::cout << std::endl; + //std::cout; #else if (Py_FlushLine()) PyErr_Clear(); #endif - fflush(stdout); + //fflush(stdout); if (value == NULL || value == Py_None) goto done; if (PyExceptionInstance_Check(value)) { @@ -1483,7 +1483,7 @@ void PythonQt::setModuleImportPath(PyObject* module, const QStringList& paths) void PythonQt::stdOutRedirectCB(const QString& str) { if (!PythonQt::self()) { - std::cout << str.toLatin1().data() << std::endl; + qDebug() << str.toLatin1().data(); return; } Q_EMIT PythonQt::self()->pythonStdOut(str); @@ -1492,7 +1492,7 @@ void PythonQt::stdOutRedirectCB(const QString& str) void PythonQt::stdErrRedirectCB(const QString& str) { if (!PythonQt::self()) { - std::cerr << str.toLatin1().data() << std::endl; + qWarning() << str.toLatin1().data(); return; } Q_EMIT PythonQt::self()->pythonStdErr(str); diff --git a/src/PythonQt.h b/src/PythonQt.h index e807d80b..a9cfda8e 100644 --- a/src/PythonQt.h +++ b/src/PythonQt.h @@ -55,7 +55,6 @@ #include #include #include -#include class PythonQtClassInfo; diff --git a/src/PythonQtClassInfo.cpp b/src/PythonQtClassInfo.cpp index 7e277581..5225da94 100644 --- a/src/PythonQtClassInfo.cpp +++ b/src/PythonQtClassInfo.cpp @@ -140,9 +140,9 @@ bool PythonQtClassInfo::lookForPropertyAndCache(const char* memberName) if (nameMapped) { _cachedMembers.insert(memberName, newInfo); } - #ifdef PYTHONQT_DEBUG - std::cout << "caching property " << memberName << " on " << _meta->className() << std::endl; - #endif +#ifdef PYTHONQT_DEBUG + qDebug() << "caching property " << memberName << " on " << _meta->className(); +#endif found = true; } return found; @@ -281,13 +281,13 @@ bool PythonQtClassInfo::lookForEnumAndCache(const QMetaObject* meta, const char* enumValuePtr.setNewRef(PythonQtPrivate::createEnumValueInstance(enumType, e.value(j))); PythonQtMemberInfo newInfo(enumValuePtr); _cachedMembers.insert(memberName, newInfo); - #ifdef PYTHONQT_DEBUG - std::cout << "caching enum " << memberName << " on " << meta->className() << std::endl; - #endif +#ifdef PYTHONQT_DEBUG + qDebug() << "caching enum " << memberName << " on " << meta->className(); +#endif found = true; break; } else { - std::cout << "enum " << e.name() << " not found on " << className() << std::endl; + qWarning() << "enum " << e.name() << " not found on " << className(); } } } diff --git a/src/PythonQtConversion.cpp b/src/PythonQtConversion.cpp index eec68190..b382d899 100644 --- a/src/PythonQtConversion.cpp +++ b/src/PythonQtConversion.cpp @@ -204,7 +204,7 @@ PyObject* PythonQtConv::ConvertQtValueToPythonInternal(int type, const void* dat wrap->_useQMetaTypeDestroy = true; return (PyObject*)wrap; } - std::cerr << "Unknown type that can not be converted to Python: " << type << ", in " << __FILE__ << ":" << __LINE__ << std::endl; + qWarning() << "Unknown type that can not be converted to Python: " << type << ", in " << __FILE__ << ":" << __LINE__; } } Py_INCREF(Py_None); diff --git a/src/PythonQtConversion.h b/src/PythonQtConversion.h index 88358725..ae20ed10 100644 --- a/src/PythonQtConversion.h +++ b/src/PythonQtConversion.h @@ -49,7 +49,7 @@ #include #include -#include +#include typedef PyObject* PythonQtConvertMetaTypeToPythonCB(const void* inObject, int metaTypeId); typedef bool PythonQtConvertPythonToMetaTypeCB(PyObject* inObject, void* outObject, int metaTypeId, bool strict); @@ -62,8 +62,7 @@ PythonQtConv::registerMetaTypeToPythonConverter(typeId, PythonQtConvertListOfVal #define PythonQtRegisterToolClassesTemplateConverter(innertype) \ PythonQtRegisterListTemplateConverter(QList, innertype); \ - PythonQtRegisterListTemplateConverter(QVector, innertype); \ - PythonQtRegisterListTemplateConverter(std::vector, innertype); + PythonQtRegisterListTemplateConverter(QVector, innertype); // TODO: add QHash etc. here! //! a static class that offers methods for type conversion @@ -168,7 +167,7 @@ PyObject* PythonQtConvertListOfValueTypeToPythonList(const void* /*QList* */ ListType* list = (ListType*)inList; static const int innerType = PythonQtConv::getInnerTemplateMetaType(QByteArray(QMetaType::typeName(metaTypeId))); if (innerType == QVariant::Invalid) { - std::cerr << "PythonQtConvertListOfValueTypeToPythonList: unknown inner type " << QMetaType::typeName(metaTypeId) << std::endl; + qWarning() << "PythonQtConvertListOfValueTypeToPythonList: unknown inner type " << QMetaType::typeName(metaTypeId); } PyObject* result = PyTuple_New(list->size()); int i = 0; @@ -185,7 +184,7 @@ bool PythonQtConvertPythonListToListOfValueType(PyObject* obj, void* /*QList* ListType* list = (ListType*)outList; static const int innerType = PythonQtConv::getInnerTemplateMetaType(QByteArray(QMetaType::typeName(metaTypeId))); if (innerType == QVariant::Invalid) { - std::cerr << "PythonQtConvertPythonListToListOfValueType: unknown inner type " << QMetaType::typeName(metaTypeId) << std::endl; + qWarning() << "PythonQtConvertPythonListToListOfValueType: unknown inner type " << QMetaType::typeName(metaTypeId); } bool result = false; if (PySequence_Check(obj)) { diff --git a/src/PythonQtInstanceWrapper.cpp b/src/PythonQtInstanceWrapper.cpp index 7eef089e..b0b2d269 100644 --- a/src/PythonQtInstanceWrapper.cpp +++ b/src/PythonQtInstanceWrapper.cpp @@ -359,7 +359,7 @@ static PyObject *PythonQtInstanceWrapper_getattro(PyObject *obj,PyObject *name) PyDict_SetItemString(dict, name.toLatin1().data(), o); Py_DECREF(o); } else { - std::cerr << "PythonQtInstanceWrapper: something is wrong, could not get attribute " << name.toLatin1().data(); + qWarning() << "PythonQtInstanceWrapper: something is wrong, could not get attribute " << name.toLatin1().data(); } } @@ -370,7 +370,7 @@ static PyObject *PythonQtInstanceWrapper_getattro(PyObject *obj,PyObject *name) PyDict_SetItemString(dict, name.data(), o); Py_DECREF(o); } else { - std::cerr << "PythonQtInstanceWrapper: dynamic property could not be read " << name.data(); + qWarning() << "PythonQtInstanceWrapper: dynamic property could not be read " << name.data(); } } } diff --git a/src/PythonQtMethodInfo.cpp b/src/PythonQtMethodInfo.cpp index 22700066..cc1b3454 100644 --- a/src/PythonQtMethodInfo.cpp +++ b/src/PythonQtMethodInfo.cpp @@ -41,7 +41,10 @@ #include "PythonQtMethodInfo.h" #include "PythonQtClassInfo.h" -#include + +#ifdef PYTHONQT_DEBUG +#include +#endif QHash PythonQtMethodInfo::_cachedSignatures; QHash PythonQtMethodInfo::_parameterNameAliases; @@ -56,7 +59,7 @@ PythonQtMethodInfo::PythonQtMethodInfo(const QMetaMethod& meta, PythonQtClassInf #endif sig = sig.mid(sig.indexOf('(')); QByteArray fullSig = QByteArray(meta.typeName()) + " " + sig; - std::cout << "caching " << fullSig.data() << std::endl; + qDebug() << "caching " << fullSig.data(); #endif ParameterInfo type; diff --git a/src/PythonQtSignal.cpp b/src/PythonQtSignal.cpp index 4cc39ec5..4b9fbc80 100644 --- a/src/PythonQtSignal.cpp +++ b/src/PythonQtSignal.cpp @@ -47,11 +47,6 @@ #include "PythonQtConversion.h" #include "PythonQtSlot.h" -#include - -#include -#include - #include //----------------------------------------------------------------------------------- diff --git a/src/PythonQtSignalReceiver.cpp b/src/PythonQtSignalReceiver.cpp index 789930c1..449f10fb 100644 --- a/src/PythonQtSignalReceiver.cpp +++ b/src/PythonQtSignalReceiver.cpp @@ -154,7 +154,7 @@ PythonQtSignalReceiver::PythonQtSignalReceiver(QObject* obj):PythonQtSignalRecei _destroyedSignal1Id = QObject::staticMetaObject.indexOfSignal("destroyed()"); _destroyedSignal2Id = QObject::staticMetaObject.indexOfSignal("destroyed(QObject*)"); if (_destroyedSignal1Id == -1 || _destroyedSignal2Id == -1) { - std::cerr << "PythonQt: could not find destroyed signal index, should never happen!" << std::endl; + qWarning() << "PythonQt: could not find destroyed signal index, should never happen!"; } } diff --git a/src/PythonQtSlot.cpp b/src/PythonQtSlot.cpp index 0c523203..3861da0d 100644 --- a/src/PythonQtSlot.cpp +++ b/src/PythonQtSlot.cpp @@ -45,7 +45,6 @@ #include "PythonQtClassInfo.h" #include "PythonQtMisc.h" #include "PythonQtConversion.h" -#include #include #include @@ -301,7 +300,7 @@ PyObject *PythonQtSlotFunction_CallImpl(PythonQtClassInfo* classInfo, QObject* o int argc = args?PyTuple_Size(args):0; #ifdef PYTHONQT_DEBUG - std::cout << "called " << info->metaMethod()->typeName() << " " << info->metaMethod()->signature() << std::endl; + qDebug() << "called " << info->metaMethod()->typeName() << " " << info->metaMethod()->signature(); #endif PyObject* r = NULL; diff --git a/src/gui/PythonQtScriptingConsole.cpp b/src/gui/PythonQtScriptingConsole.cpp index 5c2220b5..770716e5 100644 --- a/src/gui/PythonQtScriptingConsole.cpp +++ b/src/gui/PythonQtScriptingConsole.cpp @@ -85,7 +85,9 @@ void PythonQtScriptingConsole::stdOut(const QString& s) int idx; while ((idx = _stdOut.indexOf('\n'))!=-1) { consoleMessage(_stdOut.left(idx)); - std::cout << _stdOut.left(idx).toLatin1().data() << std::endl; +#ifdef PYTHONQT_DEBUG + qDebug() << _stdOut.left(idx).toLatin1().data(); +#endif _stdOut = _stdOut.mid(idx+1); } } @@ -97,7 +99,9 @@ void PythonQtScriptingConsole::stdErr(const QString& s) int idx; while ((idx = _stdErr.indexOf('\n'))!=-1) { consoleMessage(_stdErr.left(idx)); - std::cerr << _stdErr.left(idx).toLatin1().data() << std::endl; +#ifdef PYTHONQT_DEBUG + qWarning() << _stdErr.left(idx).toLatin1().data(); +#endif _stdErr = _stdErr.mid(idx+1); } } diff --git a/tests/PythonQtTestMain.cpp b/tests/PythonQtTestMain.cpp index bc594ff9..b6c0824d 100644 --- a/tests/PythonQtTestMain.cpp +++ b/tests/PythonQtTestMain.cpp @@ -42,6 +42,7 @@ #include "PythonQt.h" #include "PythonQtTests.h" #include +#include int main( int argc, char **argv ) {