Commit fe6b1ede authored by Clinton Stimpson's avatar Clinton Stimpson

ENH:  Add ability to record/playback a python script.
      Also add ability to query QObject properties from python.
parent 236b4165
PROJECT(QtTesting)
#OPTION(QT_TESTING_WITH_PYTHON "Build Testing with Python" ON)
SET(QT_TESTING_WITH_PYTHON OFF)
SET(QT_TESTING_WITH_XML ON)
IF(QT_TESTING_WITH_PYTHON)
INCLUDE_DIRECTORIES(
${PYTHON_INCLUDE_PATH}
)
SET(PYTHON_MOCS
pqPythonEventObserver.h
)
SET(PYTHON_SRCS
pqPythonEventObserver.cxx
pqPythonEventObserver.h
pqPythonEventSource.cxx
pqPythonEventSource.h
)
ENDIF(QT_TESTING_WITH_PYTHON)
INCLUDE_DIRECTORIES(
${QtTesting_BINARY_DIR}
${QtTesting_SOURCE_DIR}
......@@ -20,15 +41,18 @@ QT4_WRAP_CPP(MOC_BUILT_SOURCES
pqDoubleSpinBoxEventTranslator.h
pqEventDispatcher.h
pqEventPlayer.h
pqEventSource.h
pqEventTranslator.h
pqLineEditEventTranslator.h
pqMenuEventTranslator.h
pqRecordEventsDialog.h
pqSpinBoxEventTranslator.h
pqStdoutEventObserver.h
pqThreadedEventSource.h
pqTabBarEventTranslator.h
pqWidgetEventTranslator.h
pqXMLEventObserver.h
${PYTHON_MOCS}
)
SET_DIRECTORY_PROPERTIES(PROPERTIES INCLUDE_DIRECTORIES "${include_dirs_tmp}")
......@@ -88,6 +112,8 @@ ADD_LIBRARY(QtTesting
pqTabBarEventPlayer.h
pqTabBarEventTranslator.cxx
pqTabBarEventTranslator.h
pqThreadedEventSource.cxx
pqThreadedEventSource.h
pqWidgetEventPlayer.h
pqWidgetEventTranslator.h
pqXMLEventObserver.cxx
......@@ -96,6 +122,7 @@ ADD_LIBRARY(QtTesting
pqXMLEventSource.h
${MOC_BUILT_SOURCES}
${UI_BUILT_SOURCES}
${PYTHON_SRCS}
)
SOURCE_GROUP("Generated" FILES
......@@ -108,7 +135,18 @@ TARGET_LINK_LIBRARIES(QtTesting
${QT_QTTEST_LIBRARY}
)
IF(QT_TESTING_WITH_PYTHON)
TARGET_LINK_LIBRARIES(QtTesting
${PYTHON_LIBRARIES}
)
ENDIF(QT_TESTING_WITH_PYTHON)
CONFIGURE_FILE(${QtTesting_SOURCE_DIR}/QtTestingConfigure.h.in
${QtTesting_BINARY_DIR}/QtTestingConfigure.h)
INSTALL(TARGETS QtTesting
RUNTIME DESTINATION ${PV_INSTALL_BIN_DIR_CM24} COMPONENT Runtime
LIBRARY DESTINATION ${PV_INSTALL_LIB_DIR_CM24} COMPONENT Runtime
ARCHIVE DESTINATION ${PV_INSTALL_LIB_DIR_CM24} COMPONENT Development)
/*=========================================================================
Program: ParaView
Module: QtTestingConfigure.h.in
Copyright (c) 2005,2006 Sandia Corporation, Kitware Inc.
All rights reserved.
ParaView is a free software; you can redistribute it and/or modify it
under the terms of the ParaView license version 1.1.
See License_v1.1.txt for the full ParaView license.
A copy of this license can be obtained by contacting
Kitware Inc.
28 Corporate Drive
Clifton Park, NY 12065
USA
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
=========================================================================*/
#ifndef _QtTestingConfigure_h
#define _QtTestingConfigure_h
#cmakedefine QT_TESTING_WITH_XML
#cmakedefine QT_TESTING_WITH_PYTHON
#endif // _QtTestingConfigure_h
......@@ -68,6 +68,8 @@ public:
pqEventDispatcher::pqEventDispatcher() :
Implementation(new pqImplementation())
{
QObject::connect(this, SIGNAL(readyPlayNextEvent()),
this, SLOT(playNextEvent()));
}
pqEventDispatcher::~pqEventDispatcher()
......@@ -99,23 +101,37 @@ void pqEventDispatcher::playEvents(pqEventSource& source, pqEventPlayer& player)
&this->Implementation->Timer,
SIGNAL(timeout()),
this,
SLOT(playNextEvent()));
SIGNAL(readyPlayNextEvent()));
#else
QObject::connect(
QAbstractEventDispatcher::instance(),
SIGNAL(aboutToBlock()),
this,
SLOT(playNextEvent()),
SIGNAL(readyPlayNextEvent()),
Qt::QueuedConnection);
#endif
}
void pqEventDispatcher::playNextEvent()
{
if(!this->Implementation->Source)
{
return;
}
QString object;
QString command;
QString arguments;
if(!this->Implementation->Source->getNextEvent(object, command, arguments))
// block signals as some event sources may interact with the event loop
this->blockSignals(true);
bool result = this->Implementation->Source->getNextEvent(
object, command, arguments);
this->blockSignals(false);
if(!result)
{
this->stopPlayback();
emit this->succeeded();
......@@ -145,15 +161,16 @@ void pqEventDispatcher::stopPlayback()
&this->Implementation->Timer,
SIGNAL(timeout()),
this,
SLOT(playNextEvent()));
SIGNAL(readyPlayNextEvent()));
#else
QObject::disconnect(
QAbstractEventDispatcher::instance(),
SIGNAL(aboutToBlock()),
this,
SLOT(playNextEvent()));
SIGNAL(readyPlayNextEvent()));
#endif
this->Implementation->Source = 0;
this->Implementation->Player = 0;
}
......@@ -60,6 +60,7 @@ public:
signals:
void succeeded();
void failed();
void readyPlayNextEvent();
private slots:
void playNextEvent();
......
......@@ -34,12 +34,13 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define _pqEventSource_h
#include "QtTestingExport.h"
#include <QObject>
class QString;
/// Abstract interface for objects that can supply high-level testing events
class QTTESTING_EXPORT pqEventSource
class QTTESTING_EXPORT pqEventSource : public QObject
{
Q_OBJECT
public:
virtual ~pqEventSource() {}
......@@ -50,10 +51,6 @@ public:
QString& command,
QString& arguments) = 0;
protected:
pqEventSource() {}
pqEventSource(const pqEventSource&) {}
pqEventSource& operator=(const pqEventSource&) { return *this; }
};
#endif // !_pqEventSource_h
/*=========================================================================
Program: ParaView
Module: pqPythonEventObserver.cxx
Copyright (c) 2005,2006 Sandia Corporation, Kitware Inc.
All rights reserved.
ParaView is a free software; you can redistribute it and/or modify it
under the terms of the ParaView license version 1.1.
See License_v1.1.txt for the full ParaView license.
A copy of this license can be obtained by contacting
Kitware Inc.
28 Corporate Drive
Clifton Park, NY 12065
USA
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
=========================================================================*/
#include "pqPythonEventObserver.h"
#include <QTextStream>
////////////////////////////////////////////////////////////////////////////////////
// pqPythonEventObserver
pqPythonEventObserver::pqPythonEventObserver(QTextStream& stream) :
Stream(stream)
{
this->Stream << "#/usr/bin/env python\n\n";
this->Stream << "import QtTesting\n\n";
}
pqPythonEventObserver::~pqPythonEventObserver()
{
this->Stream.flush();
}
void pqPythonEventObserver::onRecordEvent(
const QString& Widget,
const QString& Command,
const QString& Arguments)
{
QString varname = this->Names[Widget];
if(varname == QString::null)
{
varname = QString("object%1").arg(this->Names.count());
this->Names.insert(Widget, varname);
QString objname("%1 = '%2'");
objname = objname.arg(varname);
objname = objname.arg(Widget);
this->Stream << objname << "\n";
}
QString pycommand("QtTesting.playCommand(%1, '%2', '%3')");
pycommand = pycommand.arg(varname);
pycommand = pycommand.arg(Command);
pycommand = pycommand.arg(Arguments);
this->Stream << pycommand << "\n";
}
/*=========================================================================
Program: ParaView
Module: pqPythonEventObserver.h
Copyright (c) 2005,2006 Sandia Corporation, Kitware Inc.
All rights reserved.
ParaView is a free software; you can redistribute it and/or modify it
under the terms of the ParaView license version 1.1.
See License_v1.1.txt for the full ParaView license.
A copy of this license can be obtained by contacting
Kitware Inc.
28 Corporate Drive
Clifton Park, NY 12065
USA
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
=========================================================================*/
#ifndef _pqPythonEventObserver_h
#define _pqPythonEventObserver_h
#include <QObject>
#include <QHash>
#include <QString>
class QTextStream;
/**
Observes high-level ParaView events, and serializes them to a stream as Python
for possible playback (as a test-case, demo, tutorial, etc). To use,
connect the onRecordEvent() slot to the pqEventTranslator::recordEvent()
signal.
\note Output is sent to the stream from this object's destructor, so you
must ensure that it goes out of scope before trying to playback the stream.
\sa pqEventTranslator, pqStdoutEventObserver, pqPythonEventSource.
*/
class pqPythonEventObserver :
public QObject
{
Q_OBJECT
public:
pqPythonEventObserver(QTextStream& Stream);
~pqPythonEventObserver();
public slots:
void onRecordEvent(
const QString& Widget,
const QString& Command,
const QString& Arguments);
private:
/// Stores a stream that will be used to store the Python output
QTextStream& Stream;
QHash<QString, QString> Names;
};
#endif // !_pqPythonEventObserver_h
/*=========================================================================
Program: ParaView
Module: pqPythonEventSource.cxx
Copyright (c) 2005,2006 Sandia Corporation, Kitware Inc.
All rights reserved.
ParaView is a free software; you can redistribute it and/or modify it
under the terms of the ParaView license version 1.1.
See License_v1.1.txt for the full ParaView license.
A copy of this license can be obtained by contacting
Kitware Inc.
28 Corporate Drive
Clifton Park, NY 12065
USA
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
=========================================================================*/
// python header first
#include "Python.h"
// self include
#include "pqPythonEventSource.h"
// Qt include
#include <QVariant>
#include <QFile>
#include <QtDebug>
#include <QMutex>
#include <QWaitCondition>
#include <QCoreApplication>
#include <QEvent>
// Qt testing includes
#include "pqObjectNaming.h"
// TODO not have a global instance pointer?
static pqPythonEventSource* Instance = NULL;
static QString PropertyObject;
static QString PropertyResult;
static QWaitCondition WaitResults;
namespace
{
class pqGetPropertyEvent : public QEvent
{
public:
pqGetPropertyEvent() : QEvent(QEvent::User) {}
};
}
static PyObject*
QtTesting_playCommand(PyObject* /*self*/, PyObject* args)
{
// void QtTesting.playCommand('object', 'command', 'arguments')
// an exception is thrown in this fails
const char* object = 0;
const char* command = 0;
const char* arguments = 0;
if(!PyArg_ParseTuple(args, const_cast<char*>("sss"), &object, &command, &arguments))
{
PyErr_SetString(PyExc_TypeError, "bad arguments to playCommand()");
return NULL;
}
if(Instance)
{
Instance->postNextEvent(object, command, arguments);
}
else
{
PyErr_SetString(PyExc_AssertionError, "pqPythonEventSource not defined");
return NULL;
}
return Py_BuildValue(const_cast<char*>(""));
}
static PyObject*
QtTesting_getProperty(PyObject* /*self*/, PyObject* args)
{
// string QtTesting.getProperty('object', 'property')
// returns the string value of the property
const char* object = 0;
const char* property = 0;
if(!PyArg_ParseTuple(args, const_cast<char*>("ss"), &object, &property))
{
return NULL;
}
if(!Instance)
{
PyErr_SetString(PyExc_AssertionError, "pqPythonEventSource not defined");
return NULL;
}
PropertyResult = property;
PropertyObject = object;
QCoreApplication::postEvent(Instance, new pqGetPropertyEvent());
QMutex mut;
mut.lock();
WaitResults.wait(&mut);
if(PropertyObject == QString::null)
{
PyErr_SetString(PyExc_ValueError, "object not found");
return NULL;
}
return Py_BuildValue(const_cast<char*>("s"),
PropertyResult.toAscii().data());
}
static PyMethodDef QtTestingMethods[] = {
{
const_cast<char*>("playCommand"),
QtTesting_playCommand,
METH_VARARGS,
const_cast<char*>("Play a test command.")
},
{
const_cast<char*>("getProperty"),
QtTesting_getProperty,
METH_VARARGS,
const_cast<char*>("Get a property of an object.")
},
{NULL, NULL, 0, NULL} // Sentinal
};
PyMODINIT_FUNC
initQtTesting(void)
{
Py_InitModule(const_cast<char*>("QtTesting"), QtTestingMethods);
}
class pqPythonEventSource::pqInternal
{
public:
QString FileName;
PyThreadState* MainThreadState;
};
pqPythonEventSource::pqPythonEventSource()
{
this->Internal = new pqInternal;
// initialize python
Py_Initialize();
// initialize the QtTesting module
initQtTesting();
// initialize threading
PyEval_InitThreads();
this->Internal->MainThreadState = PyThreadState_Get();
PyEval_ReleaseLock();
}
pqPythonEventSource::~pqPythonEventSource()
{
delete this->Internal;
}
void pqPythonEventSource::setContent(const QString& path)
{
// start the python thread
this->Internal->FileName = path;
this->start();
}
bool pqPythonEventSource::event(QEvent* e)
{
if(dynamic_cast<pqGetPropertyEvent*>(e))
{
QObject* qobject = pqObjectNaming::GetObject(PropertyObject);
if(!qobject)
{
PropertyObject = QString::null;
}
else
{
PropertyResult = qobject->property(
PropertyResult.toAscii().data()).toString();
}
WaitResults.wakeAll();
return true;
}
return pqThreadedEventSource::event(e);
}
void pqPythonEventSource::run()
{
const char* filename = this->Internal->FileName.toAscii().data();
FILE* pythonScript = fopen(filename, "r");
if(!pythonScript)
{
// TODO: report error
return;
}
PyEval_AcquireLock();
PyInterpreterState* mainInterpreterState;
mainInterpreterState = this->Internal->MainThreadState->interp;
PyThreadState* myThreadState = PyThreadState_New(mainInterpreterState);
PyThreadState_Swap(myThreadState);
Instance = this;
// finally run the script
PyRun_SimpleFile(pythonScript, filename);
PyThreadState_Swap(NULL);
PyThreadState_Clear(myThreadState);
PyThreadState_Delete(myThreadState);
PyEval_ReleaseLock();
fclose(pythonScript);
this->done();
}
/*=========================================================================
Program: ParaView
Module: pqPythonEventSource.h
Copyright (c) 2005,2006 Sandia Corporation, Kitware Inc.
All rights reserved.
ParaView is a free software; you can redistribute it and/or modify it
under the terms of the ParaView license version 1.1.
See License_v1.1.txt for the full ParaView license.
A copy of this license can be obtained by contacting
Kitware Inc.
28 Corporate Drive
Clifton Park, NY 12065
USA
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
=========================================================================*/
#ifndef _pqPythonEventSource_h
#define _pqPythonEventSource_h
#include "pqThreadedEventSource.h"
class QString;
/** Concrete implementation of pqEventSource that retrieves events recorded
by pqPythonEventObserver */
class QTTESTING_EXPORT pqPythonEventSource :
public pqThreadedEventSource
{
public:
pqPythonEventSource();
~pqPythonEventSource();
void setContent(const QString& path);
protected:
virtual void run();
virtual bool event(QEvent*);
class pqInternal;
pqInternal* Internal;
};
#endif // !_pqPythonEventSource_h
/*=========================================================================
Program: ParaView
Module: pqThreadedEventSource.cxx
Copyright (c) 2005,2006 Sandia Corporation, Kitware Inc.
All rights reserved.
ParaView is a free software; you can redistribute it and/or modify it
under the terms of the ParaView license version 1.1.
See License_v1.1.txt for the full ParaView license.
A copy of this license can be obtained by contacting
Kitware Inc.
28 Corporate Drive
Clifton Park, NY 12065
USA
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
=========================================================================*/
#include "pqThreadedEventSource.h"
#include <QMutex>
#include <QThread>
#include <QString>
#include <QEventLoop>
#include <QTimer>
#include <QAbstractEventDispatcher>
class pqThreadedEventSource::pqInternal : public QThread
{
friend class pqThreadedEventSource;
public:
pqInternal(pqThreadedEventSource& source)
: Source(source),
MainThread(*QThread::currentThread())
{
}
virtual void run()
{
Source.run();
}
pqThreadedEventSource& Source;
QMutex Mutex1;
QMutex Mutex2;
QMutex Mutex3;
QThread& MainThread;
QEventLoop Loop;
QString CurrentObject;
QString CurrentCommand;
QString CurrentArgument;
};
pqThreadedEventSource::pqThreadedEventSource()
{
this->Internal = new pqInternal(*this);
// lock the mutex