Darrell Anderson 12 years ago
commit f8224f3a62

3
configure vendored

@ -734,6 +734,9 @@ while [ "$#" -gt 0 ]; do
glibmainloop)
if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then
CFG_GLIBMAINLOOP="$VAL"
if [ "$VAL" = "yes" ]; then
echo "WARNING: glib main loop support is ***incomplete*** and will cause problems with threaded applications and/or those using non-standard event loops!"
fi
else
UNKNOWN_OPT=yes
fi

@ -290,7 +290,6 @@ ftglue_face_goto_table( FT_Face face,
if ( face->num_faces > 1 )
{
/* deal with TrueType collections */
FT_ULong offset;
LOG(( ">> This is a TrueType Collection\n" ));
@ -298,8 +297,6 @@ ftglue_face_goto_table( FT_Face face,
ACCESS_Frame( 4 ) )
goto Exit;
offset = GET_ULong();
FORGET_Frame();
}

@ -83,6 +83,9 @@
#endif
class Q_EXPORT_CODECS_JP TQJpUnicodeConv {
public:
virtual ~TQJpUnicodeConv() {}
public:
enum Rules {
// "ASCII" is ANSI X.3.4-1986, a.k.a. US-ASCII here.

@ -381,6 +381,7 @@ class TQIconViewToolTip : public TQToolTip
{
public:
TQIconViewToolTip( TQWidget *parent, TQIconView *iv );
virtual ~TQIconViewToolTip();
void maybeTip( const TQPoint &pos );
@ -393,6 +394,10 @@ TQIconViewToolTip::TQIconViewToolTip( TQWidget *parent, TQIconView *iv )
{
}
TQIconViewToolTip::~TQIconViewToolTip()
{
}
void TQIconViewToolTip::maybeTip( const TQPoint &pos )
{
if ( !parentWidget() || !view || view->wordWrapIconText() || !view->showToolTips() )

@ -63,6 +63,7 @@ class TQWSDecoration;
#ifdef QT_THREAD_SUPPORT
class TQMutex;
class TQThread;
#endif // QT_THREAD_SUPPORT
@ -369,7 +370,9 @@ private:
#ifndef QT_NO_CURSOR
static TQCursor *app_cursor;
#endif
#ifndef QT_THREAD_SUPPORT
static TQEventLoop* eventloop;
#endif
static int app_tracking;
static bool is_app_running;
static bool is_app_closing;
@ -425,6 +428,7 @@ private:
static void removePostedEvent( TQEvent * );
static void removePostedEvents( TQObject *receiver, int event_type );
friend class TQObject;
friend class TQWidget;
friend class TQETWidget;
friend class TQDialog;
@ -444,6 +448,15 @@ private: // Disabled copy constructor and operator=
TQApplication( const TQApplication & );
TQApplication &operator=( const TQApplication & );
#endif
private:
static TQEventLoop* currentEventLoop();
public:
#ifdef QT_THREAD_SUPPORT
static TQThread* guiThread();
#endif
static bool isGuiThread();
};
inline int TQApplication::argc() const

@ -137,6 +137,8 @@ public:
HelpRequest = 95, // CE (?) button pressed
WindowStateChange = 96, // window state has changed
IconDrag = 97, // proxy icon dragged
MetaCall = 98, // meta method call (internal)
ThreadChange = 99, // thread changed
User = 1000, // first user event id
MaxUser = 65535 // last user event id
};

@ -102,25 +102,6 @@ public:
virtual void wakeUp();
#ifdef Q_QDOC
#else // Q_QDOC
#if defined(QT_USE_GLIBMAINLOOP)
// glib main loop support
/* internal: used to fit glib-main-loop gsource concept */
bool gsourcePrepare(GSource *gs, int * timeout);
bool gsourceCheck(GSource * gs);
bool gsourceDispatch(GSource * gs);
bool processX11Events();
// end glib main loop support
#endif //QT_USE_GLIBMAINLOOP
#endif // Q_QDOC
void setSingleToolkitEventHandling(bool enabled);
signals:
@ -145,6 +126,24 @@ private:
TQEventLoopPrivate *d;
friend class TQApplication;
#ifdef Q_QDOC
#else // Q_QDOC
#if defined(QT_USE_GLIBMAINLOOP)
// glib main loop support
/* internal: used to fit glib-main-loop gsource concept */
public:
bool gsourcePrepare(GSource *gs, int * timeout);
bool gsourceCheck(GSource * gs);
bool gsourceDispatch(GSource * gs);
bool processX11Events();
// end glib main loop support
#endif //QT_USE_GLIBMAINLOOP
#endif // Q_QDOC
};
#endif // TQEVENTLOOP_H

@ -63,6 +63,10 @@ template <class T> class TQValueList;
class Q_EXPORT TQNetworkProtocolFactoryBase
{
public:
TQNetworkProtocolFactoryBase();
virtual ~TQNetworkProtocolFactoryBase();
public:
virtual TQNetworkProtocol *createObject() = 0;

@ -63,6 +63,10 @@ class TQObjectUserData;
#endif
struct TQUObject;
#ifdef QT_THREAD_SUPPORT
class TQThread;
#endif
class Q_EXPORT TQObject: public TQt
{
TQ_OBJECT
@ -217,6 +221,18 @@ private: // Disabled copy constructor and operator=
TQObject( const TQObject & );
TQObject &operator=( const TQObject & );
#endif
public:
#ifdef QT_THREAD_SUPPORT
TQThread* contextThreadObject() const;
void moveToThread(TQThread *targetThread);
#endif
private:
#ifdef QT_THREAD_SUPPORT
void moveToThread_helper(TQThread *targetThread);
void setThreadObject_helper(TQThread *targetThread);
#endif
};

@ -290,6 +290,7 @@ class Q_EXPORT TQStyleControlElementData {
TQString caption;
TQStyleControlElementGenericWidgetData topLevelWidgetData;
TQ_UINT32 topLevelWidgetFlags;
TQPixmap paletteBgPixmap;
};
class Q_EXPORT TQStyleWidgetActionRequestData {
@ -1070,6 +1071,18 @@ public:
// bool - whether or not the upper two button drawing areas should be combined into one
SH_ScrollBar_CombineSubLineRegionDrawingAreas,
// TQt::TQRgb - color of the popup menu arrow (active, menuitem enabled)
SH_PopupMenu_SubMenuArrowColorActiveEnabled,
// TQt::TQRgb - color of the popup menu arrow (active, menuitem disabled)
SH_PopupMenu_SubMenuArrowColorActiveDisabled,
// TQt::TQRgb - color of the popup menu arrow (inactive, menuitem enabled)
SH_PopupMenu_SubMenuArrowColorInactiveEnabled,
// TQt::TQRgb - color of the popup menu arrow (active, menuitem disabled)
SH_PopupMenu_SubMenuArrowColorInactiveDisabled,
// do not add any values below/greater than this
SH_CustomBase = 0xf0000000
};

@ -118,11 +118,25 @@ protected:
private:
TQThreadInstance * d;
friend class TQThreadInstance;
friend class TQCoreApplicationThread;
friend class TQApplication;
friend class TQEventLoop;
#if defined(TQ_DISABLE_COPY)
TQThread( const TQThread & );
TQThread &operator=( const TQThread & );
#endif // TQ_DISABLE_COPY
public:
static TQThread* currentThreadObject();
};
class Q_EXPORT TQEventLoopThread : public TQThread
{
public:
TQEventLoopThread();
~TQEventLoopThread();
virtual void run();
};
#endif // QT_THREAD_SUPPORT

@ -68,6 +68,7 @@
#if defined(QT_THREAD_SUPPORT)
# include "ntqmutex.h"
# include "ntqthread.h"
# include <private/qthreadinstance_p.h>
#endif // QT_THREAD_SUPPORT
#include <stdlib.h>
@ -383,7 +384,25 @@ Q_EXPORT TQt::HANDLE tqt_get_application_thread_id()
}
#endif // QT_THREAD_SUPPORT
#ifndef QT_THREAD_SUPPORT
TQEventLoop *TQApplication::eventloop = 0; // application event loop
#endif
#ifdef QT_THREAD_SUPPORT
TQEventLoop* TQApplication::currentEventLoop() {
TQThread* thread = TQThread::currentThreadObject();
if (thread) {
if (thread->d) {
return thread->d->eventLoop;
}
}
return NULL;
}
#else
TQEventLoop* TQApplication::currentEventLoop() {
return TQApplication::eventloop;
}
#endif
#ifndef QT_NO_ACCEL
extern bool tqt_dispatchAccelEvent( TQWidget*, TQKeyEvent* ); // def in qaccel.cpp
@ -516,6 +535,41 @@ TQClipboard *tqt_clipboard = 0; // global clipboard object
#endif
TQWidgetList * tqt_modal_stack=0; // stack of modal widgets
#ifdef QT_THREAD_SUPPORT
// thread wrapper for the main() thread
class TQCoreApplicationThread : public TQThread
{
public:
inline TQCoreApplicationThread()
{
TQThreadInstance::setCurrentThread(this);
// thread should be running and not finished for the lifetime
// of the application (even if QCoreApplication goes away)
d->running = true;
d->finished = false;
d->eventLoop = NULL;
}
inline ~TQCoreApplicationThread()
{
// avoid warning from TQThread
d->running = false;
}
private:
inline void run()
{
// this function should never be called, it is implemented
// only so that we can instantiate the object
tqFatal("TQCoreApplicationThread: internal error");
}
};
static TQCoreApplicationThread tqt_main_thread;
static TQThread *mainThread() { return &tqt_main_thread; }
#else
static TQThread* mainThread() { return TQThread::currentThread(); }
#endif
// Definitions for posted events
struct TQPostEvent {
TQPostEvent( TQObject *r, TQEvent *e ): receiver( r ), event( e ) {}
@ -818,8 +872,8 @@ void TQApplication::construct( int &argc, char **argv, Type type )
initialize( argc, argv );
if ( tqt_is_gui_used )
tqt_maxWindowRect = desktop()->rect();
if ( eventloop )
eventloop->appStartingUp();
if ( currentEventLoop() )
currentEventLoop()->appStartingUp();
}
/*!
@ -874,8 +928,8 @@ TQApplication::TQApplication( Display* dpy, HANDLE visual, HANDLE colormap )
if ( tqt_is_gui_used )
tqt_maxWindowRect = desktop()->rect();
if ( eventloop )
eventloop->appStartingUp();
if ( currentEventLoop() )
currentEventLoop()->appStartingUp();
}
/*!
@ -916,13 +970,26 @@ TQApplication::TQApplication(Display *dpy, int argc, char **argv,
if ( tqt_is_gui_used )
tqt_maxWindowRect = desktop()->rect();
if ( eventloop )
eventloop->appStartingUp();
if ( currentEventLoop() )
currentEventLoop()->appStartingUp();
}
#endif // Q_WS_X11
#ifdef QT_THREAD_SUPPORT
TQThread* TQApplication::guiThread() {
return mainThread();
}
bool TQApplication::isGuiThread() {
return (TQThread::currentThreadObject() == guiThread());
}
#else
bool TQApplication::isGuiThread() {
return true;
}
#endif
void TQApplication::init_precmdline()
{
@ -1030,8 +1097,8 @@ TQApplication::~TQApplication()
}
#endif
if ( eventloop )
eventloop->appClosingDown();
if ( currentEventLoop() )
currentEventLoop()->appClosingDown();
if ( postRList ) {
TQVFuncList::Iterator it = postRList->begin();
while ( it != postRList->end() ) { // call post routines
@ -2698,8 +2765,28 @@ bool TQApplication::internalNotify( TQObject *receiver, TQEvent * e)
}
if (!handled)
if (!handled) {
#if defined(QT_THREAD_SUPPORT)
int locklevel = 0;
int llcount;
if (TQApplication::tqt_mutex) {
TQApplication::tqt_mutex->lock(); // 1 of 2
locklevel = tqt_mutex->level() - 1;
for (llcount=0; llcount<locklevel; llcount++) {
TQApplication::tqt_mutex->unlock();
}
TQApplication::tqt_mutex->unlock(); // 2 of 2
}
#endif
consumed = receiver->event( e );
#if defined(QT_THREAD_SUPPORT)
if (TQApplication::tqt_mutex) {
for (llcount=0; llcount<locklevel; llcount++) {
TQApplication::tqt_mutex->lock();
}
}
#endif
}
e->spont = FALSE;
return consumed;
}
@ -2793,9 +2880,10 @@ void TQApplication::processOneEvent()
*/
TQEventLoop *TQApplication::eventLoop()
{
if ( !eventloop && !is_app_closing )
if ( !currentEventLoop() && !is_app_closing ) {
(void) new TQEventLoop( tqApp, "default event loop" );
return eventloop;
}
return currentEventLoop();
}
@ -3263,8 +3351,23 @@ void TQApplication::postEvent( TQObject *receiver, TQEvent *event )
l->append( pe );
globalPostedEvents->append( pe );
if (eventloop)
eventloop->wakeUp();
#ifdef QT_THREAD_SUPPORT
if ( event->type() == TQEvent::MetaCall ) {
// Wake up the receiver thread event loop
TQThread* thread = receiver->contextThreadObject();
if (thread) {
if (thread->d) {
if (thread->d->eventLoop) {
thread->d->eventLoop->wakeUp();
}
}
}
return;
}
#endif
if (currentEventLoop())
currentEventLoop()->wakeUp();
}
@ -3326,7 +3429,8 @@ void TQApplication::sendPostedEvents( TQObject *receiver, int event_type )
&& ( receiver == 0 // we send to all receivers
|| receiver == pe->receiver ) // we send to THAT receiver
&& ( event_type == 0 // we send all types
|| event_type == pe->event->type() ) ) { // we send THAT type
|| event_type == pe->event->type() ) // we send THAT type
&& ( (!pe->receiver) || (pe->receiver->contextThreadObject() == TQThread::currentThreadObject()) ) ) { // only send if active thread is receiver object owning thread
// first, we diddle the event so that we can deliver
// it, and that noone will try to touch it later.
pe->event->posted = FALSE;

@ -430,7 +430,7 @@ static bool qt_x11EventFilter( XEvent* ev )
//XIM qt_xim = 0;
Q_EXPORT XIMStyle qt_xim_style = 0;
Q_EXPORT XIMStyle qt_xim_preferred_style = 0;
Q_EXPORT static XIMStyle xim_default_style = XIMPreeditCallbacks | XIMStatusNothing;
static XIMStyle xim_default_style = XIMPreeditCallbacks | XIMStatusNothing;
#endif
Q_EXPORT int qt_ximComposingKeycode=0;
@ -5889,7 +5889,7 @@ static Bool qt_net_wm_sync_request_scanner(Display*, XEvent* event, XPointer arg
{
return (event->type == ClientMessage && event->xclient.window == *(Window*)arg
&& event->xclient.message_type == tqt_wm_protocols
&& event->xclient.data.l[ 0 ] == qt_net_wm_sync_request );
&& ((unsigned int)event->xclient.data.l[ 0 ]) == qt_net_wm_sync_request );
}
#endif

@ -1749,9 +1749,9 @@ TQColorDrag::TQColorDrag( TQWidget *dragsource, const char *name )
void TQColorDrag::setColor( const TQColor &col )
{
short r = (col.red() << 8) | col.red();
short g = (col.green() << 8) | col.green();
short b = (col.blue() << 8) | col.blue();
unsigned short r = (col.red() << 8) | col.red();
unsigned short g = (col.green() << 8) | col.green();
unsigned short b = (col.blue() << 8) | col.blue();
// make sure we transmit data in network order
r = htons(r);

@ -41,6 +41,11 @@
#include "ntqapplication.h"
#include "ntqdatetime.h"
#ifdef QT_THREAD_SUPPORT
# include "ntqthread.h"
# include "qthreadinstance_p.h"
#endif
/*!
\class TQEventLoop
\brief The TQEventLoop class manages the event queue.
@ -100,15 +105,27 @@ TQEventLoop::TQEventLoop( TQObject *parent, const char *name )
: TQObject( parent, name )
{
#if defined(QT_CHECK_STATE)
if ( TQApplication::eventloop )
tqFatal( "TQEventLoop: there must be only one event loop object. \nConstruct it before TQApplication." );
// for now ;)
if ( TQApplication::currentEventLoop() )
tqFatal( "TQEventLoop: there must be only one event loop object per thread. \nIf this is supposed to be the main GUI event loop, construct it before TQApplication." );
if (!TQThread::currentThreadObject()) {
tqFatal( "TQEventLoop: this object can only be used in threads constructed via TQThread." );
}
#endif // QT_CHECK_STATE
d = new TQEventLoopPrivate;
init();
#ifdef QT_THREAD_SUPPORT
TQThread* thread = TQThread::currentThreadObject();
if (thread) {
if (thread->d) {
thread->d->eventLoop = this;
}
}
#else
TQApplication::eventloop = this;
#endif
}
/*!
@ -118,7 +135,16 @@ TQEventLoop::~TQEventLoop()
{
cleanup();
delete d;
#ifdef QT_THREAD_SUPPORT
TQThread* thread = TQThread::currentThreadObject();
if (thread) {
if (thread->d) {
thread->d->eventLoop = 0;
}
}
#else
TQApplication::eventloop = 0;
#endif
}
/*!

@ -84,49 +84,51 @@ struct TQSockNotGPollFD
class TQEventLoopPrivate
{
public:
TQEventLoopPrivate()
{
reset();
}
void reset() {
looplevel = 0;
quitcode = 0;
quitnow = FALSE;
exitloop = FALSE;
shortcut = FALSE;
singletoolkit = TRUE;
}
int looplevel;
int quitcode;
unsigned int quitnow : 1;
unsigned int exitloop : 1;
unsigned int shortcut : 1;
TQEventLoopPrivate()
{
#if defined(Q_WS_X11)
int xfd;
GPollFD x_gPollFD;
xfd = -1;
x_gPollFD.fd = -1;
#endif // Q_WS_X11
reset();
}
void reset() {
looplevel = 0;
quitcode = 0;
quitnow = FALSE;
exitloop = FALSE;
shortcut = FALSE;
singletoolkit = TRUE;
}
int looplevel;
int quitcode;
unsigned int quitnow : 1;
unsigned int exitloop : 1;
unsigned int shortcut : 1;
int thread_pipe[2];
#if defined(Q_WS_X11)
int xfd;
GPollFD x_gPollFD;
#endif // Q_WS_X11
int thread_pipe[2];
GPollFD threadPipe_gPollFD;
TQPtrList<TQSockNotGPollFD> sn_list;
// pending socket notifiers list
TQPtrList<TQSockNotGPollFD> sn_pending_list;
TQPtrList<TQSockNotGPollFD> sn_list;
// pending socket notifiers list
TQPtrList<TQSockNotGPollFD> sn_pending_list;
// store flags for one iteration
uint pev_flags;
uint pev_flags;
// My GSource
GSource * gSource;
bool singletoolkit;
// main context
GMainContext *ctx;
};
#endif // TQEVENTLOOP_GLIB_P_H

@ -40,6 +40,7 @@
#include "ntqeventloop.h"
#include "ntqapplication.h"
#include "ntqbitarray.h"
#include "ntqmutex.h"
#include <stdlib.h>
#include <sys/types.h>
@ -561,6 +562,8 @@ int TQEventLoop::activateTimers()
n_act++;
TQTimerEvent e( t->id );
TQApplication::sendEvent( t->obj, &e ); // send event
if ( !timerList ) // sendEvent allows other threads to execute, therefore we must check for list existence when it returns!
return 0;
if ( timerList->findRef( begin ) == -1 )
begin = 0;
}

@ -44,6 +44,7 @@
#include "ntqeventloop.h"
#include "ntqapplication.h"
#include "ntqbitarray.h"
#include "ntqmutex.h"
#include <stdlib.h>
#include <sys/types.h>
@ -369,9 +370,9 @@ void TQEventLoop::registerSocketNotifier( TQSocketNotifier *notifier )
return;
}
#ifdef DEBUG_QT_GLIBMAINLOOP
printf("register socket notifier %d\n", sockfd);
#endif
#ifdef DEBUG_QT_GLIBMAINLOOP
printf("register socket notifier %d\n", sockfd);
#endif
TQPtrList<TQSockNotGPollFD> *list = &d->sn_list;
TQSockNotGPollFD *sn;
@ -424,9 +425,9 @@ void TQEventLoop::unregisterSocketNotifier( TQSocketNotifier *notifier )
return;
}
#ifdef DEBUG_QT_GLIBMAINLOOP
printf("unregister socket notifier %d\n", sockfd);
#endif
#ifdef DEBUG_QT_GLIBMAINLOOP
printf("unregister socket notifier %d\n", sockfd);
#endif
TQPtrList<TQSockNotGPollFD> *list = &d->sn_list;
TQSockNotGPollFD *sn;
@ -457,9 +458,9 @@ void TQEventLoop::setSocketNotifierPending( TQSocketNotifier *notifier )
return;
}
#ifdef DEBUG_QT_GLIBMAINLOOP
printf("set socket notifier pending %d\n", sockfd);
#endif
#ifdef DEBUG_QT_GLIBMAINLOOP
printf("set socket notifier pending %d\n", sockfd);
#endif
TQPtrList<TQSockNotGPollFD> *list = &d->sn_list;
TQSockNotGPollFD *sn;
@ -505,7 +506,9 @@ void TQEventLoop::wakeUp()
size_t nbytes = 0;
char c = 0;
if ( ::ioctl( d->thread_pipe[0], FIONREAD, (char*)&nbytes ) >= 0 && nbytes == 0 ) {
::write( d->thread_pipe[1], &c, 1 );
if (::write( d->thread_pipe[1], &c, 1 ) < 0) {
// Failed!
}
}
}
@ -576,17 +579,14 @@ int TQEventLoop::activateSocketNotifiers()
while ( (sn=it.current()) ) {
++it;
d->sn_pending_list.removeRef( sn );
if ( sn->pending ) {
#ifdef DEBUG_QT_GLIBMAINLOOP
printf("activate sn : send event fd=%d\n", sn->gPollFD.fd );
#endif
sn->pending = FALSE;
TQApplication::sendEvent( sn->obj, &event );
n_act++;
}
if ( sn->pending ) {
#ifdef DEBUG_QT_GLIBMAINLOOP
printf("activate sn : send event fd=%d\n", sn->gPollFD.fd );
#endif
sn->pending = FALSE;
TQApplication::sendEvent( sn->obj, &event );
n_act++;
}
}
return n_act;

@ -146,55 +146,57 @@ bool TQEventLoop::processEvents( ProcessEventsFlags flags )
if ( tqt_is_gui_used ) {
TQApplication::sendPostedEvents();
// Two loops so that posted events accumulate
while ( XPending( TQPaintDevice::x11AppDisplay() ) ) {
// also flushes output buffer
while ( XPending( TQPaintDevice::x11AppDisplay() ) ) {
if ( d->shortcut ) {
return FALSE;
}
XNextEvent( TQPaintDevice::x11AppDisplay(), &event );
if ( flags & ExcludeUserInput ) {
switch ( event.type ) {
case ButtonPress:
case ButtonRelease:
case MotionNotify:
case XKeyPress:
case XKeyRelease:
case EnterNotify:
case LeaveNotify:
continue;
case ClientMessage:
{
// from qapplication_x11.cpp
extern Atom tqt_wm_protocols;
extern Atom tqt_wm_take_focus;
extern Atom qt_qt_scrolldone;
// only keep the wm_take_focus and
// qt_qt_scrolldone protocols, discard all
// other client messages
if ( event.xclient.format != 32 )
continue;
if ( event.xclient.message_type == tqt_wm_protocols ||
(Atom) event.xclient.data.l[0] == tqt_wm_take_focus )
break;
if ( event.xclient.message_type == qt_qt_scrolldone )
break;
if (TQApplication::isGuiThread()) {
// Two loops so that posted events accumulate
while ( XPending( TQPaintDevice::x11AppDisplay() ) ) {
// also flushes output buffer
while ( XPending( TQPaintDevice::x11AppDisplay() ) ) {
if ( d->shortcut ) {
return FALSE;
}
XNextEvent( TQPaintDevice::x11AppDisplay(), &event );
if ( flags & ExcludeUserInput ) {
switch ( event.type ) {
case ButtonPress:
case ButtonRelease:
case MotionNotify:
case XKeyPress:
case XKeyRelease:
case EnterNotify:
case LeaveNotify:
continue;
case ClientMessage:
{
// from qapplication_x11.cpp
extern Atom tqt_wm_protocols;
extern Atom tqt_wm_take_focus;
extern Atom qt_qt_scrolldone;
// only keep the wm_take_focus and
// qt_qt_scrolldone protocols, discard all
// other client messages
if ( event.xclient.format != 32 )
continue;
if ( event.xclient.message_type == tqt_wm_protocols ||
(Atom) event.xclient.data.l[0] == tqt_wm_take_focus )
break;
if ( event.xclient.message_type == qt_qt_scrolldone )
break;
}
default: break;
}
}
nevents++;
if ( tqApp->x11ProcessEvent( &event ) == 1 )
return TRUE;
}
default: break;
}
}
nevents++;
if ( tqApp->x11ProcessEvent( &event ) == 1 )
return TRUE;
}
}
}
@ -261,7 +263,7 @@ bool TQEventLoop::processEvents( ProcessEventsFlags flags )
FD_ZERO( &d->sn_vec[2].select_fds );
}
if ( tqt_is_gui_used ) {
if ( tqt_is_gui_used && TQApplication::isGuiThread() ) {
// select for events on the event socket - only on X11
FD_SET( d->xfd, &d->sn_vec[0].select_fds );
highest = TQMAX( highest, d->xfd );
@ -282,7 +284,8 @@ bool TQEventLoop::processEvents( ProcessEventsFlags flags )
// unlock the GUI mutex and select. when we return from this function, there is
// something for us to do
#if defined(QT_THREAD_SUPPORT)
locker.mutex()->unlock();
if ( locker.mutex() ) locker.mutex()->unlock();
else return false;
#endif
int nsel;
@ -296,7 +299,8 @@ bool TQEventLoop::processEvents( ProcessEventsFlags flags )
// relock the GUI mutex before processing any pending events
#if defined(QT_THREAD_SUPPORT)
locker.mutex()->lock();
if ( locker.mutex() ) locker.mutex()->lock();
else return false;
#endif
// we are awake, broadcast it

@ -39,7 +39,6 @@
**
**********************************************************************/
#include "qeventloop_glib_p.h" // includes qplatformdefs.h
#include "ntqeventloop.h"
#include "ntqapplication.h"
@ -49,58 +48,85 @@
#if defined(QT_THREAD_SUPPORT)
# include "ntqmutex.h"
# include "ntqthread.h"
#endif // QT_THREAD_SUPPORT
#include <errno.h>
#include <glib.h>
// #define DEBUG_QT_GLIBMAINLOOP 1
// TQt-GSource Structure and Callbacks
typedef struct {
GSource source;
TQEventLoop * qeventLoop;
GSource source;
TQEventLoop * qeventLoop;
} TQtGSource;
static gboolean qt_gsource_prepare ( GSource *source,
gint *timeout );
static gboolean qt_gsource_prepare ( GSource *source, gint *timeout );
static gboolean qt_gsource_check ( GSource *source );
static gboolean qt_gsource_dispatch ( GSource *source,
GSourceFunc callback, gpointer user_data );
static gboolean qt_gsource_dispatch ( GSource *source, GSourceFunc callback, gpointer user_data );
static GSourceFuncs qt_gsource_funcs = {
qt_gsource_prepare,
qt_gsource_check,
qt_gsource_dispatch,
NULL,
NULL,
NULL
qt_gsource_prepare,
qt_gsource_check,
qt_gsource_dispatch,
NULL,
NULL,
NULL
};
// forward main loop callbacks to TQEventLoop methods!
static gboolean qt_gsource_prepare ( GSource *source,
gint *timeout )
gint *timeout )
{
TQtGSource * qtGSource;
qtGSource = (TQtGSource*) source;
return qtGSource->qeventLoop->gsourcePrepare(source, timeout);
TQtGSource * qtGSource = (TQtGSource*) source;
TQEventLoop* candidateEventLoop = qtGSource->qeventLoop;
TQEventLoop* activeThreadEventLoop = TQApplication::eventLoop();
if (candidateEventLoop == activeThreadEventLoop) {
return candidateEventLoop->gsourcePrepare(source, timeout);
}
else {
// Prepare failed
return FALSE;
}
}
static gboolean qt_gsource_check ( GSource *source )
{
TQtGSource * qtGSource = (TQtGSource*) source;
return qtGSource->qeventLoop->gsourceCheck(source);
TQtGSource * qtGSource = (TQtGSource*) source;
TQEventLoop* candidateEventLoop = qtGSource->qeventLoop;
TQEventLoop* activeThreadEventLoop = TQApplication::eventLoop();
if (candidateEventLoop == activeThreadEventLoop) {
return candidateEventLoop->gsourceCheck(source);
}
else {
// Check failed
return FALSE;
}
}
static gboolean qt_gsource_dispatch ( GSource *source,
GSourceFunc callback, gpointer user_data )
{
Q_UNUSED(callback);
Q_UNUSED(user_data);
Q_UNUSED(callback);
Q_UNUSED(user_data);
TQtGSource * qtGSource = (TQtGSource*) source;
return qtGSource->qeventLoop->gsourceDispatch(source);
TQtGSource * qtGSource = (TQtGSource*) source;
TQEventLoop* candidateEventLoop = qtGSource->qeventLoop;
TQEventLoop* activeThreadEventLoop = TQApplication::eventLoop();
if (candidateEventLoop == activeThreadEventLoop) {
return candidateEventLoop->gsourceDispatch(source);
}
else {
// Dispatch failed
return FALSE;
}
}
@ -134,339 +160,329 @@ static TQVFuncList *qt_postselect_handler = 0;
void qt_install_preselect_handler( VFPTR handler )
{
if ( !qt_preselect_handler )
qt_preselect_handler = new TQVFuncList;
qt_preselect_handler->append( handler );
if ( !qt_preselect_handler ) {
qt_preselect_handler = new TQVFuncList;
}
qt_preselect_handler->append( handler );
}
void qt_remove_preselect_handler( VFPTR handler )
{
if ( qt_preselect_handler ) {
TQVFuncList::Iterator it = qt_preselect_handler->find( handler );
if ( it != qt_preselect_handler->end() )
qt_preselect_handler->remove( it );
}
if ( qt_preselect_handler ) {
TQVFuncList::Iterator it = qt_preselect_handler->find( handler );
if ( it != qt_preselect_handler->end() ) {
qt_preselect_handler->remove( it );
}
}
}
void qt_install_postselect_handler( VFPTR handler )
{
if ( !qt_postselect_handler )
qt_postselect_handler = new TQVFuncList;
qt_postselect_handler->prepend( handler );
if ( !qt_postselect_handler ) {
qt_postselect_handler = new TQVFuncList;
}
qt_postselect_handler->prepend( handler );
}
void qt_remove_postselect_handler( VFPTR handler )
{
if ( qt_postselect_handler ) {
TQVFuncList::Iterator it = qt_postselect_handler->find( handler );
if ( it != qt_postselect_handler->end() )
qt_postselect_handler->remove( it );
}
if ( qt_postselect_handler ) {
TQVFuncList::Iterator it = qt_postselect_handler->find( handler );
if ( it != qt_postselect_handler->end() ) {
qt_postselect_handler->remove( it );
}
}
}
void TQEventLoop::init()
{
// initialize ProcessEventFlags (all events & wait for more)
d->pev_flags = AllEvents | WaitForMore;
// initialize the common parts of the event loop
if (pipe( d->thread_pipe ) < 0) {
// Error!
}
fcntl(d->thread_pipe[0], F_SETFD, FD_CLOEXEC);
fcntl(d->thread_pipe[1], F_SETFD, FD_CLOEXEC);
// intitialize the X11 parts of the event loop
d->xfd = -1;
if ( tqt_is_gui_used )
d->xfd = XConnectionNumber( TQPaintDevice::x11AppDisplay() );
// new GSource
TQtGSource * qtGSource = (TQtGSource*) g_source_new(&qt_gsource_funcs,
sizeof(TQtGSource));
g_source_set_can_recurse ((GSource*)qtGSource, TRUE);
qtGSource->qeventLoop = this;
// init main loop and attach gsource
#ifdef DEBUG_QT_GLIBMAINLOOP
printf("inside init(1)\n");
#endif
g_main_loop_new (NULL, 1);
g_source_attach( (GSource*)qtGSource, NULL );
d->gSource = (GSource*) qtGSource;
// initialize the common parts of the event loop
if (pipe( d->thread_pipe ) < 0) {
// Error!
}
fcntl(d->thread_pipe[0], F_SETFD, FD_CLOEXEC);
fcntl(d->thread_pipe[1], F_SETFD, FD_CLOEXEC);
// intitialize the X11 parts of the event loop
d->xfd = -1;
if ( tqt_is_gui_used && TQApplication::isGuiThread() ) {
d->xfd = XConnectionNumber( TQPaintDevice::x11AppDisplay() );
}
// new main context for thread
d->ctx = g_main_context_new();
g_main_context_push_thread_default(d->ctx);
// new GSource
TQtGSource * qtGSource = (TQtGSource*) g_source_new(&qt_gsource_funcs, sizeof(TQtGSource));
g_source_set_can_recurse ((GSource*)qtGSource, TRUE);
qtGSource->qeventLoop = this;
// init main loop and attach gsource
#ifdef DEBUG_QT_GLIBMAINLOOP
printf("inside init(1)\n");
#endif
g_main_loop_new (d->ctx, 1);
g_source_attach( (GSource*)qtGSource, d->ctx );
d->gSource = (GSource*)qtGSource;
// poll for X11 events
if ( tqt_is_gui_used ) {
if ( tqt_is_gui_used && TQApplication::isGuiThread() ) {
d->x_gPollFD.fd = d->xfd;
d->x_gPollFD.events = G_IO_IN | G_IO_HUP;
g_source_add_poll(d->gSource, &d->x_gPollFD);
}
d->x_gPollFD.events = G_IO_IN | G_IO_HUP | G_IO_ERR;
g_source_add_poll(d->gSource, &d->x_gPollFD);
}
// poll thread-pipe
d->threadPipe_gPollFD.fd = d->thread_pipe[0];
d->threadPipe_gPollFD.events = G_IO_IN | G_IO_HUP;
d->threadPipe_gPollFD.events = G_IO_IN | G_IO_HUP | G_IO_ERR;
g_source_add_poll(d->gSource, &d->threadPipe_gPollFD);
#ifdef DEBUG_QT_GLIBMAINLOOP
printf("inside init(2)\n");
#endif
#ifdef DEBUG_QT_GLIBMAINLOOP
printf("inside init(2)\n");
#endif
}
void TQEventLoop::cleanup()
{
// cleanup the common parts of the event loop
close( d->thread_pipe[0] );
close( d->thread_pipe[1] );
cleanupTimers();
// cleanup the common parts of the event loop
close( d->thread_pipe[0] );
close( d->thread_pipe[1] );
cleanupTimers();
// cleanup the X11 parts of the event loop
d->xfd = -1;
// unref the main context
g_main_context_unref(d->ctx);
// cleanup the X11 parts of the event loop
d->xfd = -1;
// todo: destroy gsource
}
bool TQEventLoop::processEvents( ProcessEventsFlags flags )
{
#ifdef DEBUG_QT_GLIBMAINLOOP
printf("inside processEvents(1) looplevel=%d\n", d->looplevel );
#endif
ProcessEventsFlags save_flags;
int rval;
save_flags = d->pev_flags;
#ifdef DEBUG_QT_GLIBMAINLOOP
printf("inside processEvents(1) looplevel=%d\n", d->looplevel );
#endif
d->pev_flags = flags;
rval = g_main_context_iteration(NULL, flags & WaitForMore ? TRUE : FALSE);
d->pev_flags = save_flags;
ProcessEventsFlags save_flags;
int rval;
save_flags = d->pev_flags;
d->pev_flags = flags;
rval = g_main_context_iteration(d->ctx, flags & WaitForMore ? TRUE : FALSE);
#ifdef DEBUG_QT_GLIBMAINLOOP
printf("inside processEvents(2) looplevel=%d rval=%d\n", d->looplevel, rval );
#endif
d->pev_flags = save_flags;
return rval; // were events processed?
#ifdef DEBUG_QT_GLIBMAINLOOP
printf("inside processEvents(2) looplevel=%d rval=%d\n", d->looplevel, rval );
#endif
return rval; // were events processed?
}
bool TQEventLoop::processX11Events()
{
ProcessEventsFlags flags = d->pev_flags;
// process events from the X server
XEvent event;
int nevents = 0;
// process events from the X server
XEvent event;
int nevents = 0;
#if defined(QT_THREAD_SUPPORT)
TQMutexLocker locker( TQApplication::tqt_mutex );
TQMutexLocker locker( TQApplication::tqt_mutex );
#endif
// handle gui and posted events
if ( tqt_is_gui_used ) {
TQApplication::sendPostedEvents();
// Two loops so that posted events accumulate
while ( XPending( TQPaintDevice::x11AppDisplay() ) ) {
// also flushes output buffer
while ( XPending( TQPaintDevice::x11AppDisplay() ) ) {
if ( d->shortcut ) {
return FALSE;
}
XNextEvent( TQPaintDevice::x11AppDisplay(), &event );
if ( flags & ExcludeUserInput ) {
switch ( event.type ) {
case ButtonPress:
case ButtonRelease:
case MotionNotify:
case XKeyPress:
case XKeyRelease:
case EnterNotify:
case LeaveNotify:
continue;
case ClientMessage:
{
// from qapplication_x11.cpp
extern Atom tqt_wm_protocols;
extern Atom tqt_wm_take_focus;
extern Atom qt_qt_scrolldone;
// only keep the wm_take_focus and
// qt_qt_scrolldone protocols, discard all
// other client messages
if ( event.xclient.format != 32 )
continue;
if ( event.xclient.message_type == tqt_wm_protocols ||
(Atom) event.xclient.data.l[0] == tqt_wm_take_focus )
break;
if ( event.xclient.message_type == qt_qt_scrolldone )
break;
// handle gui and posted events
if ( tqt_is_gui_used ) {
TQApplication::sendPostedEvents();
if (TQApplication::isGuiThread()) {
// Two loops so that posted events accumulate
while ( XPending( TQPaintDevice::x11AppDisplay() ) ) {
// also flushes output buffer
while ( XPending( TQPaintDevice::x11AppDisplay() ) ) {
if ( d->shortcut ) {
return FALSE;
}
XNextEvent( TQPaintDevice::x11AppDisplay(), &event );
if ( flags & ExcludeUserInput ) {
switch ( event.type ) {
case ButtonPress:
case ButtonRelease:
case MotionNotify:
case XKeyPress:
case XKeyRelease:
case EnterNotify:
case LeaveNotify:
continue;
case ClientMessage:
{
// from qapplication_x11.cpp
extern Atom tqt_wm_protocols;
extern Atom tqt_wm_take_focus;
extern Atom qt_qt_scrolldone;
// only keep the wm_take_focus and
// qt_qt_scrolldone protocols, discard all
// other client messages
if ( event.xclient.format != 32 )
continue;
if ( event.xclient.message_type == tqt_wm_protocols ||
(Atom) event.xclient.data.l[0] == tqt_wm_take_focus )
break;
if ( event.xclient.message_type == qt_qt_scrolldone )
break;
}
default: break;
}
}
nevents++;
if ( tqApp->x11ProcessEvent( &event ) == 1 ) {
return TRUE;
}
}
}
default: break;
}
}
nevents++;
if ( tqApp->x11ProcessEvent( &event ) == 1 )
return TRUE;
}
}
}
if ( d->shortcut ) {
return FALSE;
}
if ( d->shortcut ) {
TQApplication::sendPostedEvents();
const uint exclude_all = ExcludeSocketNotifiers | 0x08;
// 0x08 == ExcludeTimers for X11 only
if ( nevents > 0 && ( flags & exclude_all ) == exclude_all && ( flags & WaitForMore ) ) {
return TRUE;
}
return FALSE;
}
TQApplication::sendPostedEvents();
const uint exclude_all = ExcludeSocketNotifiers | 0x08;
// 0x08 == ExcludeTimers for X11 only
if ( nevents > 0 && ( flags & exclude_all ) == exclude_all &&
( flags & WaitForMore ) ) {
return TRUE;
}
return FALSE;
}
bool TQEventLoop::gsourcePrepare(GSource *gs, int * timeout)
{
Q_UNUSED(gs);
#ifdef DEBUG_QT_GLIBMAINLOOP
printf("inside gsourcePrepare(1)\n");
#endif
#ifdef DEBUG_QT_GLIBMAINLOOP
printf("inside gsourcePrepare(1)\n");
#endif
ProcessEventsFlags flags = d->pev_flags;
#if defined(QT_THREAD_SUPPORT)
TQMutexLocker locker( TQApplication::tqt_mutex );
TQMutexLocker locker( TQApplication::tqt_mutex );
#endif
// don't block if exitLoop() or exit()/quit() has been called.
bool canWait = d->exitloop || d->quitnow ? FALSE : (flags & WaitForMore);
// Process timers and socket notifiers - the common UNIX stuff
// return the maximum time we can wait for an event.
static timeval zerotm;
timeval *tm = 0;
if ( ! ( flags & 0x08 ) ) { // 0x08 == ExcludeTimers for X11 only
tm = qt_wait_timer(); // wait for timer or X event
if ( !canWait ) {
if ( !tm )
tm = &zerotm;
tm->tv_sec = 0; // no time to wait
tm->tv_usec = 0;
}
}
// include or exclude SocketNotifiers (by setting or cleaning poll events)
if ( ! ( flags & ExcludeSocketNotifiers ) ) {
TQPtrListIterator<TQSockNotGPollFD> it( d->sn_list );
TQSockNotGPollFD *sn;
while ( (sn=it.current()) ) {
++it;
sn->gPollFD.events = sn->events; // restore poll events
// don't block if exitLoop() or exit()/quit() has been called.
bool canWait = d->exitloop || d->quitnow ? FALSE : (flags & WaitForMore);
// Process timers and socket notifiers - the common UNIX stuff
// return the maximum time we can wait for an event.
static timeval zerotm;
timeval *tm = 0;
if ( ! ( flags & 0x08 ) ) { // 0x08 == ExcludeTimers for X11 only
tm = qt_wait_timer(); // wait for timer or X event
if ( !canWait ) {
if ( !tm ) {
tm = &zerotm;
}
tm->tv_sec = 0; // no time to wait
tm->tv_usec = 0;
}
} else {
TQPtrListIterator<TQSockNotGPollFD> it( d->sn_list );
TQSockNotGPollFD *sn;
while ( (sn=it.current()) ) {
++it;
sn->gPollFD.events = 0; // delete poll events
}
// include or exclude SocketNotifiers (by setting or cleaning poll events)
if ( ! ( flags & ExcludeSocketNotifiers ) ) {
TQPtrListIterator<TQSockNotGPollFD> it( d->sn_list );
TQSockNotGPollFD *sn;
while ( (sn=it.current()) ) {
++it;
sn->gPollFD.events = sn->events; // restore poll events
}
}
else {
TQPtrListIterator<TQSockNotGPollFD> it( d->sn_list );
TQSockNotGPollFD *sn;
while ( (sn=it.current()) ) {
++it;
sn->gPollFD.events = 0; // delete poll events
}
}
#ifdef DEBUG_QT_GLIBMAINLOOP
printf("inside gsourcePrepare(2) canwait=%d\n", canWait);
#endif
if ( canWait )
emit aboutToBlock();
#ifdef DEBUG_QT_GLIBMAINLOOP
printf("inside gsourcePrepare(2) canwait=%d\n", canWait);
#endif
if ( qt_preselect_handler ) {
TQVFuncList::Iterator it, end = qt_preselect_handler->end();
for ( it = qt_preselect_handler->begin(); it != end; ++it )
(**it)();
}
// unlock the GUI mutex and select. when we return from this function, there is
// something for us to do
#if defined(QT_THREAD_SUPPORT)
locker.mutex()->unlock();
#endif
if ( canWait ) {
emit aboutToBlock();
}
#ifdef DEBUG_QT_GLIBMAINLOOP
printf("inside gsourcePrepare(2.1) canwait=%d\n", canWait);
#endif
if ( qt_preselect_handler ) {
TQVFuncList::Iterator it, end = qt_preselect_handler->end();
for ( it = qt_preselect_handler->begin(); it != end; ++it )
(**it)();
}
#ifdef DEBUG_QT_GLIBMAINLOOP
printf("inside gsourcePrepare(2.1) canwait=%d\n", canWait);
#endif
// do we have to dispatch events?
if (hasPendingEvents()) {
if (hasPendingEvents()) {
*timeout = 0; // no time to stay in poll
#ifdef DEBUG_QT_GLIBMAINLOOP
printf("inside gsourcePrepare(3a)\n");
#endif
#ifdef DEBUG_QT_GLIBMAINLOOP
printf("inside gsourcePrepare(3a)\n");
#endif
return FALSE;
}
}
// stay in poll until something happens?
if (!tm) { // fixme
*timeout = -1; // wait forever
#ifdef DEBUG_QT_GLIBMAINLOOP
printf("inside gsourcePrepare(3b) timeout=%d \n", *timeout);
#endif
#ifdef DEBUG_QT_GLIBMAINLOOP
printf("inside gsourcePrepare(3b) timeout=%d \n", *timeout);
#endif
return FALSE;
}
// else timeout >=0
// else timeout >=0
*timeout = tm->tv_sec * 1000 + tm->tv_usec/1000;
#ifdef DEBUG_QT_GLIBMAINLOOP
printf("inside gsourcePrepare(3c) timeout=%d \n", *timeout);
#endif
#ifdef DEBUG_QT_GLIBMAINLOOP
printf("inside gsourcePrepare(3c) timeout=%d \n", *timeout);
#endif
return FALSE;
return FALSE;
}
bool TQEventLoop::gsourceCheck(GSource *gs) {
Q_UNUSED(gs);
#ifdef DEBUG_QT_GLIBMAINLOOP
printf("inside gsourceCheck(1)\n");
#endif
#ifdef DEBUG_QT_GLIBMAINLOOP
printf("inside gsourceCheck(1)\n");
#endif
// Socketnotifier events?
TQPtrList<TQSockNotGPollFD> *list = &d->sn_list;
//if ( list ) {
TQSockNotGPollFD *sn = list->first();
while ( sn ) {
if ( sn->gPollFD.revents )
@ -476,45 +492,43 @@ bool TQEventLoop::gsourceCheck(GSource *gs) {
//}
if (d->x_gPollFD.revents) {
#ifdef DEBUG_QT_GLIBMAINLOOP
printf("inside gsourceCheck(2) xfd!\n");
#endif
#ifdef DEBUG_QT_GLIBMAINLOOP
printf("inside gsourceCheck(2) xfd!\n");
#endif
return TRUE; // we got events!
}
if (d->threadPipe_gPollFD.revents) {
#ifdef DEBUG_QT_GLIBMAINLOOP
printf("inside gsourceCheck(2) threadpipe!!\n");
#endif
if (d->threadPipe_gPollFD.revents) {
#ifdef DEBUG_QT_GLIBMAINLOOP
printf("inside gsourceCheck(2) threadpipe!!\n");
#endif
return TRUE; // we got events!
}
if (hasPendingEvents()) {
#ifdef DEBUG_QT_GLIBMAINLOOP
printf("inside gsourceCheck(2) pendingEvents!\n");
#endif
if (hasPendingEvents()) {
#ifdef DEBUG_QT_GLIBMAINLOOP
printf("inside gsourceCheck(2) pendingEvents!\n");
#endif
return TRUE; // we got more X11 events!
}
// check if we have timers to activate?
// check if we have timers to activate?
timeval * tm =qt_wait_timer();
if (tm && (tm->tv_sec == 0 && tm->tv_usec == 0 )) {
#ifdef DEBUG_QT_GLIBMAINLOOP
printf("inside gsourceCheck(2) qtwaittimer!\n");
#endif
return TRUE;
}
if (tm && (tm->tv_sec == 0 && tm->tv_usec == 0 )) {
#ifdef DEBUG_QT_GLIBMAINLOOP
printf("inside gsourceCheck(2) qtwaittimer!\n");
#endif
return TRUE;
}
// nothing to dispatch
#ifdef DEBUG_QT_GLIBMAINLOOP
printf("inside gsourceCheck(2) nothing to dispatch!\n");
#endif
// nothing to dispatch
#ifdef DEBUG_QT_GLIBMAINLOOP
printf("inside gsourceCheck(2) nothing to dispatch!\n");
#endif
return FALSE;
return FALSE;
}
@ -526,44 +540,41 @@ bool TQEventLoop::gsourceDispatch(GSource *gs) {
TQMutexLocker locker( TQApplication::tqt_mutex );
#endif
#if defined(QT_THREAD_SUPPORT)
locker.mutex()->lock();
if (locker.mutex()) locker.mutex()->lock();
#endif
int nevents=0;
ProcessEventsFlags flags = d->pev_flags;
#ifdef DEBUG_QT_GLIBMAINLOOP
printf("inside gsourceDispatch(1)\n");
#endif
// we are awake, broadcast it
emit awake();
emit tqApp->guiThreadAwake();
// some other thread woke us up... consume the data on the thread pipe so that
// select doesn't immediately return next time
#ifdef DEBUG_QT_GLIBMAINLOOP
printf("inside gsourceDispatch(1)\n");
#endif
// we are awake, broadcast it
emit awake();
emit tqApp->guiThreadAwake();
// some other thread woke us up... consume the data on the thread pipe so that
// select doesn't immediately return next time
if ( d->threadPipe_gPollFD.revents) {
char c;
if (::read( d->thread_pipe[0], &c, 1 ) < 0) {
// Error!
}
}
char c;
if (::read( d->thread_pipe[0], &c, 1 ) < 0) {
// Error!
}
}
if ( qt_postselect_handler ) {
TQVFuncList::Iterator it, end = qt_postselect_handler->end();
for ( it = qt_postselect_handler->begin(); it != end; ++it )
(**it)();
}
if ( qt_postselect_handler ) {
TQVFuncList::Iterator it, end = qt_postselect_handler->end();
for ( it = qt_postselect_handler->begin(); it != end; ++it )
(**it)();
}
// activate socket notifiers
if ( ! ( flags & ExcludeSocketNotifiers )) {
// activate socket notifiers
if ( ! ( flags & ExcludeSocketNotifiers )) {
// if select says data is ready on any socket, then set the socket notifier
// to pending
// if ( &d->sn_list ) {
TQPtrList<TQSockNotGPollFD> *list = &d->sn_list;
TQSockNotGPollFD *sn = list->first();
while ( sn ) {
@ -572,40 +583,38 @@ bool TQEventLoop::gsourceDispatch(GSource *gs) {
sn = list->next();
}
// }
nevents += activateSocketNotifiers();
}
}
// activate timers
if ( ! ( flags & 0x08 ) ) {
// activate timers
if ( ! ( flags & 0x08 ) ) {
// 0x08 == ExcludeTimers for X11 only
nevents += activateTimers();
}
}
// return true if we handled events, false otherwise
//return (nevents > 0);
// now process x11 events!
#ifdef DEBUG_QT_GLIBMAINLOOP
printf("inside gsourceDispatch(2) hasPendingEvents=%d\n", hasPendingEvents());
#endif
#ifdef DEBUG_QT_GLIBMAINLOOP
printf("inside gsourceDispatch(2) hasPendingEvents=%d\n", hasPendingEvents());
#endif
if (hasPendingEvents()) {
// color approx. optimization - only on X11
qt_reset_color_avail();
#if defined(QT_THREAD_SUPPORT)
if (locker.mutex()) locker.mutex()->unlock();
#endif
processX11Events();
}
else {
#if defined(QT_THREAD_SUPPORT)
locker.mutex()->unlock();
if (locker.mutex()) locker.mutex()->unlock();
#endif
}
if (d->singletoolkit) {
return TRUE; // Eat the event
@ -617,21 +626,27 @@ bool TQEventLoop::gsourceDispatch(GSource *gs) {
bool TQEventLoop::hasPendingEvents() const
{
extern uint qGlobalPostedEventsCount(); // from qapplication.cpp
return ( qGlobalPostedEventsCount() || ( tqt_is_gui_used ? XPending( TQPaintDevice::x11AppDisplay() ) : 0));
extern uint qGlobalPostedEventsCount(); // from qapplication.cpp
return ( qGlobalPostedEventsCount() || ( (tqt_is_gui_used && TQApplication::isGuiThread()) ? XPending( TQPaintDevice::x11AppDisplay() ) : 0));
}
void TQEventLoop::appStartingUp()
{
if ( tqt_is_gui_used )
d->xfd = XConnectionNumber( TQPaintDevice::x11AppDisplay() );
if ( tqt_is_gui_used ) {
d->xfd = XConnectionNumber( TQPaintDevice::x11AppDisplay() );
if ( (d->x_gPollFD.fd == -1) && TQApplication::isGuiThread() ) {
d->x_gPollFD.fd = d->xfd;
d->x_gPollFD.events = G_IO_IN | G_IO_HUP | G_IO_ERR;
g_source_add_poll(d->gSource, &d->x_gPollFD);
}
}
}
void TQEventLoop::appClosingDown()
{
d->xfd = -1;
d->xfd = -1;
}
void TQEventLoop::setSingleToolkitEventHandling(bool enabled) {
d->singletoolkit = enabled;
d->singletoolkit = enabled;
}

@ -5424,6 +5424,7 @@ static void write_pbm_image( TQImageIO *iio )
class TQImageIOFrameGrabber : public TQImageConsumer {
public:
TQImageIOFrameGrabber() : framecount(0) { }
virtual ~TQImageIOFrameGrabber() { }
TQImageDecoder *decoder;
int framecount;

@ -477,6 +477,7 @@ bool TQInputContext::isComposing() const
*/
bool TQInputContext::filterEvent( const TQEvent *event )
{
Q_UNUSED(event);
return FALSE;
}
@ -679,6 +680,11 @@ void TQInputContext::unsetFocus()
*/
void TQInputContext::setMicroFocus( int x, int y, int w, int h, TQFont *f )
{
Q_UNUSED(x);
Q_UNUSED(y);
Q_UNUSED(w);
Q_UNUSED(h);
Q_UNUSED(f);
}
@ -705,6 +711,9 @@ void TQInputContext::mouseHandler( int x, TQEvent::Type type,
TQt::ButtonState button,
TQt::ButtonState state )
{
Q_UNUSED(x);
Q_UNUSED(button);
Q_UNUSED(state);
// Default behavior for simple ephemeral input contexts. Some
// complex input contexts should not be reset here.
if ( type == TQEvent::MouseButtonPress ||

@ -67,6 +67,8 @@
*/
bool TQInputContext::x11FilterEvent( TQWidget *keywidget, XEvent *event )
{
Q_UNUSED(keywidget);
Q_UNUSED(event);
return FALSE;
}

@ -80,7 +80,7 @@ void my_error_exit (j_common_ptr cinfo)
my_error_mgr* myerr = (my_error_mgr*) cinfo->err;
char buffer[JMSG_LENGTH_MAX];
(*cinfo->err->format_message)(cinfo, buffer);
tqWarning(buffer);
tqWarning("%s", buffer);
longjmp(myerr->setjmp_buffer, 1);
}

@ -381,6 +381,14 @@ public:
of these values.
*/
TQNetworkProtocolFactoryBase::TQNetworkProtocolFactoryBase() {
//
}
TQNetworkProtocolFactoryBase::~TQNetworkProtocolFactoryBase() {
//
}
/*!
Constructor of the network protocol base class. Does some
initialization and connecting of signals and slots.

@ -50,22 +50,107 @@
#include "ntqptrvector.h"
#ifdef QT_THREAD_SUPPORT
#include <ntqmutex.h>
#include "ntqmutex.h"
#include <private/qmutexpool_p.h>
#include "ntqthread.h"
#endif
#include <ctype.h>
#include <stdlib.h>
#ifndef QT_NO_USERDATA
class TQObjectPrivate : public TQPtrVector<TQObjectUserData>
#else
class TQObjectPrivate {
#endif
{
public:
#ifndef QT_NO_USERDATA
TQObjectPrivate( uint s ) : TQPtrVector<TQObjectUserData>(s){ setAutoDelete( TRUE ); }
#endif
TQThread* ownThread;
};
#else
class TQObjectPrivate {
#if defined(QT_THREAD_SUPPORT)
void TQObject::moveToThread_helper(TQThread *targetThread)
{
TQEvent e(TQEvent::ThreadChange);
TQApplication::sendEvent(this, &e);
if (childObjects) {
TQObject *child;
TQObjectListIt it(*childObjects);
while ( (child=it.current()) ) {
++it;
child->moveToThread_helper(targetThread);
}
}
}
void TQObject::setThreadObject_helper(TQThread *targetThread)
{
d->ownThread = targetThread;
if (childObjects) {
TQObject *child;
TQObjectListIt it(*childObjects);
while ( (child=it.current()) ) {
++it;
child->moveToThread_helper(targetThread);
}
}
}
/*!
Changes the thread affinity for this object and its children. The
object cannot be moved if it has a parent. Event processing will
continue in the \a targetThread. To move an object to the main
thread, pass TQApplication::guiThread() as the \a targetThread.
Note that all active timers for the object will be reset. The
timers are first stopped in the current thread and restarted (with
the same interval) in the \a targetThread. As a result, constantly
moving an object between threads can postpone timer events
indefinitely.
\sa contextThreadObject()
*/
void TQObject::moveToThread(TQThread *targetThread)
{
TQMutexLocker locker( TQApplication::tqt_mutex );
if (parentObj) {
#if defined(QT_DEBUG)
tqWarning( "TQObject::moveToThread: Cannot move objects with a parent" );
#endif
return;
}
if (isWidget) {
#if defined(QT_DEBUG)
tqWarning( "TQObject::moveToThread: Widgets cannot be moved to a new thread" );
#endif
return;
}
TQThread *objectThread = contextThreadObject();
TQThread *currentThread = TQThread::currentThreadObject();
if (objectThread != currentThread) {
#if defined(QT_DEBUG)
tqWarning( "TQObject::moveToThread: Current thread is not the object's thread" );
#endif
return;
}
if (objectThread == targetThread) {
return;
}
moveToThread_helper(targetThread);
setThreadObject_helper(targetThread);
}
#endif
class TQSenderObjectList : public TQObjectList, public TQShared
@ -75,6 +160,41 @@ public:
TQObject *currentSender;
};
class Q_EXPORT TQMetaCallEvent : public TQEvent
{
public:
enum MetaCallType {
MetaCallEmit = 0,
MetaCallInvoke = 1
};
public:
TQMetaCallEvent(int id, TQObject *sender, TQUObject *data, MetaCallType type);
~TQMetaCallEvent();
inline int id() const { return id_; }
inline TQObject *sender() const { return sender_; }
inline TQUObject *data() const { return data_; }
inline MetaCallType type() const { return type_; }
private:
const int id_;
TQObject *sender_;
TQUObject *data_;
const MetaCallType type_;
};
/*! \internal
*/
TQMetaCallEvent::TQMetaCallEvent(int id, TQObject *sender, TQUObject *data, MetaCallType type)
:TQEvent(MetaCall), id_(id), sender_(sender), data_(data), type_(type)
{ }
/*! \internal
*/
TQMetaCallEvent::~TQMetaCallEvent()
{ }
/*!
\class TQt ntqnamespace.h
@ -269,7 +389,21 @@ void *tqt_find_obj_child( TQObject *parent, const char *type, const char *name )
return 0;
}
#ifdef QT_THREAD_SUPPORT
/*!
Returns a pointer to the TQThread* associated with
the current thread affinity of this object.
\sa moveToThread()
*/
TQThread* TQObject::contextThreadObject() const
{
return d->ownThread;
}
#endif
#ifndef QT_NO_PRELIMINARY_SIGNAL_SPY
/*
@ -436,6 +570,11 @@ TQObject::TQObject( TQObject *parent, const char *name )
insert_tree( this );
isTree = TRUE;
}
if ( !d )
d = new TQObjectPrivate(0);
d->ownThread = TQThread::currentThreadObject();
}
@ -720,6 +859,36 @@ TQObject* TQObject::child( const char *objName, const char *inheritsClass,
return obj;
}
/*! \internal */
TQUObject* deepCopyTQUObjectArray(TQUObject* origArray)
{
TQUObject* newArray;
int count = 0;
while (!((origArray+count)->isLastObject)) {
count++;
}
count++;
newArray = (TQUObject*)malloc(sizeof(TQUObject)*count);
for (int i=0; i<count; i++) {
(origArray+i)->deepCopy(newArray+i);
}
return newArray;
}
/*! \internal */
void destroyDeepCopiedTQUObjectArray(TQUObject* uArray)
{
int count = 0;
while (!((uArray+count)->isLastObject)) {
count++;
}
count++;
for (int i=0; i<count; i++) {
(uArray+i)->~TQUObject();
}
free(uArray);
}
/*!
\fn bool TQObject::isWidgetType() const
@ -777,6 +946,40 @@ bool TQObject::event( TQEvent *e )
delete this;
return TRUE;
case TQEvent::MetaCall:
{
TQMetaCallEvent* metaEvent = dynamic_cast<TQMetaCallEvent*>(e);
if (metaEvent) {
if (d->ownThread == TQThread::currentThreadObject()) {
TQSenderObjectList* sol;
TQObject* oldSender = 0;
sol = senderObjects;
if ( sol ) {
oldSender = sol->currentSender;
sol->ref();
sol->currentSender = metaEvent->sender();
}
TQUObject *o = metaEvent->data();
if (metaEvent->type() == TQMetaCallEvent::MetaCallEmit) {
tqt_emit( metaEvent->id(), o );
}
if (metaEvent->type() == TQMetaCallEvent::MetaCallInvoke) {
tqt_invoke( metaEvent->id(), o );
}
if (sol ) {
sol->currentSender = oldSender;
if ( sol->deref() ) {
delete sol;
}
}
}
else {
tqWarning("TQObject: Ignoring metacall event from non-owning thread");
}
destroyDeepCopiedTQUObjectArray(metaEvent->data());
}
}
default:
if ( e->type() >= TQEvent::User ) {
customEvent( (TQCustomEvent*) e );
@ -2337,6 +2540,7 @@ void TQObject::activate_signal( int signal )
if ( !signalsBlocked() && signal >= 0 &&
( !connections || !connections->at( signal ) ) ) {
TQUObject o[1];
o[0].isLastObject = true;
qt_spy_signal( this, signal, o );
return;
}
@ -2349,6 +2553,7 @@ void TQObject::activate_signal( int signal )
if ( !clist )
return;
TQUObject o[1];
o[0].isLastObject = true;
activate_signal( clist, o );
}
@ -2364,6 +2569,8 @@ void TQObject::activate_signal( TQConnectionList *clist, TQUObject *o )
qt_spy_signal( this, connections->findRef( clist), o );
#endif
const TQThread *currentThread = TQThread::currentThreadObject();
TQObject *object;
TQSenderObjectList* sol;
TQObject* oldSender = 0;
@ -2377,10 +2584,26 @@ void TQObject::activate_signal( TQConnectionList *clist, TQUObject *o )
sol->ref();
sol->currentSender = this;
}
if ( c->memberType() == TQSIGNAL_CODE )
object->tqt_emit( c->member(), o );
else
object->tqt_invoke( c->member(), o );
if ( c->memberType() == TQSIGNAL_CODE ) {
if (object->d->ownThread == currentThread) {
object->tqt_emit( c->member(), o );
}
else {
if (object->d->ownThread && !object->d->ownThread->finished()) {
TQApplication::postEvent(object, new TQMetaCallEvent(c->member(), this, deepCopyTQUObjectArray(o), TQMetaCallEvent::MetaCallEmit));
}
}
}
else {
if (object->d->ownThread == currentThread) {
object->tqt_invoke( c->member(), o );
}
else {
if (object->d->ownThread && !object->d->ownThread->finished()) {
TQApplication::postEvent(object, new TQMetaCallEvent(c->member(), this, deepCopyTQUObjectArray(o), TQMetaCallEvent::MetaCallInvoke));
}
}
}
if ( sol ) {
sol->currentSender = oldSender;
if ( sol->deref() )
@ -2401,10 +2624,26 @@ void TQObject::activate_signal( TQConnectionList *clist, TQUObject *o )
sol->ref();
sol->currentSender = this;
}
if ( c->memberType() == TQSIGNAL_CODE )
object->tqt_emit( c->member(), o );
else
object->tqt_invoke( c->member(), o );
if ( c->memberType() == TQSIGNAL_CODE ) {
if (object->d->ownThread == currentThread) {
object->tqt_emit( c->member(), o );
}
else {
if (object->d->ownThread && !object->d->ownThread->finished()) {
TQApplication::postEvent(object, new TQMetaCallEvent(c->member(), this, deepCopyTQUObjectArray(o), TQMetaCallEvent::MetaCallEmit));
}
}
}
else {
if (object->d->ownThread == currentThread) {
object->tqt_invoke( c->member(), o );
}
else {
if (object->d->ownThread && !object->d->ownThread->finished()) {
TQApplication::postEvent(object, new TQMetaCallEvent(c->member(), this, deepCopyTQUObjectArray(o), TQMetaCallEvent::MetaCallInvoke));
}
}
}
if (sol ) {
sol->currentSender = oldSender;
if ( sol->deref() )
@ -2435,39 +2674,42 @@ void TQObject::activate_signal( TQConnectionList *clist, TQUObject *o )
*/
#ifndef QT_NO_PRELIMINARY_SIGNAL_SPY
#define ACTIVATE_SIGNAL_WITH_PARAM(FNAME,TYPE) \
void TQObject::FNAME( int signal, TYPE param ) \
{ \
if ( tqt_preliminary_signal_spy ) { \
if ( !signalsBlocked() && signal >= 0 && \
( !connections || !connections->at( signal ) ) ) { \
TQUObject o[2]; \
static_QUType_##TYPE.set( o+1, param ); \
qt_spy_signal( this, signal, o ); \
return; \
} \
} \
if ( !connections || signalsBlocked() || signal < 0 ) \
return; \
TQConnectionList *clist = connections->at( signal ); \
if ( !clist ) \
return; \
TQUObject o[2]; \
static_QUType_##TYPE.set( o+1, param ); \
activate_signal( clist, o ); \
#define ACTIVATE_SIGNAL_WITH_PARAM(FNAME,TYPE) \
void TQObject::FNAME( int signal, TYPE param ) \
{ \
if ( tqt_preliminary_signal_spy ) { \
if ( !signalsBlocked() && signal >= 0 && \
( !connections || !connections->at( signal ) ) ) { \
TQUObject o[2]; \
o[1].isLastObject = true; \
static_QUType_##TYPE.set( o+1, param ); \
qt_spy_signal( this, signal, o ); \
return; \
} \
} \
if ( !connections || signalsBlocked() || signal < 0 ) \
return; \
TQConnectionList *clist = connections->at( signal ); \
if ( !clist ) \
return; \
TQUObject o[2]; \
o[1].isLastObject = true; \
static_QUType_##TYPE.set( o+1, param ); \
activate_signal( clist, o ); \
}
#else
#define ACTIVATE_SIGNAL_WITH_PARAM(FNAME,TYPE) \
void TQObject::FNAME( int signal, TYPE param ) \
{ \
if ( !connections || signalsBlocked() || signal < 0 ) \
return; \
TQConnectionList *clist = connections->at( signal ); \
if ( !clist ) \
return; \
TQUObject o[2]; \
static_QUType_##TYPE.set( o+1, param ); \
activate_signal( clist, o ); \
#define ACTIVATE_SIGNAL_WITH_PARAM(FNAME,TYPE) \
void TQObject::FNAME( int signal, TYPE param ) \
{ \
if ( !connections || signalsBlocked() || signal < 0 ) \
return; \
TQConnectionList *clist = connections->at( signal ); \
if ( !clist ) \
return; \
TQUObject o[2]; \
o[1].isLastObject = true; \
static_QUType_##TYPE.set( o+1, param ); \
activate_signal( clist, o ); \
}
#endif

@ -529,11 +529,16 @@ static void create_dpis()
TQ_CHECK_PTR( dpisX );
TQ_CHECK_PTR( dpisY );
for ( i = 0; i < screens; i++ ) {
dpisX[ i ] = (DisplayWidth(dpy,i) * 254 + DisplayWidthMM(dpy,i)*5)
/ (DisplayWidthMM(dpy,i)*10);
dpisY[ i ] = (DisplayHeight(dpy,i) * 254 + DisplayHeightMM(dpy,i)*5)
/ (DisplayHeightMM(dpy,i)*10);
if (DisplayWidthMM(dpy,i) < 1)
dpisX[ i ] = 75; // default the dpi to 75.
else
dpisX[ i ] = (DisplayWidth(dpy,i) * 254 + DisplayWidthMM(dpy,i)*5)
/ (DisplayWidthMM(dpy,i)*10);
if (DisplayHeightMM(dpy,i) < 1)
dpisY[ i ] = 75; // default the dpi to 75.
else
dpisY[ i ] = (DisplayHeight(dpy,i) * 254 + DisplayHeightMM(dpy,i)*5)
/ (DisplayHeightMM(dpy,i)*10);
}
}

@ -379,7 +379,9 @@ void TQProcessManager::sigchldHnd( int fd )
}
char tmp;
::read( fd, &tmp, sizeof(tmp) );
if (::read( fd, &tmp, sizeof(tmp) ) < 0) {
tqWarning( "Could not read from file descriptor" );
}
#if defined(QT_QPROCESS_DEBUG)
tqDebug( "TQProcessManager::sigchldHnd()" );
#endif
@ -562,7 +564,9 @@ QT_SIGNAL_RETTYPE qt_C_sigchldHnd( QT_SIGNAL_ARGS )
return;
char a = 1;
::write( TQProcessPrivate::procManager->sigchldFd[0], &a, sizeof(a) );
if (::write( TQProcessPrivate::procManager->sigchldFd[0], &a, sizeof(a) ) < 0) {
tqWarning( "Could not write to file descriptor" );
}
}
@ -1131,7 +1135,7 @@ bool TQProcess::canReadLineStderr() const
This function always returns immediately. The data you
pass to writeToStdin() is copied into an internal memory buffer in
TQProcess, and when control goes back to the event loop, TQProcess will
starting transferring data from this buffer to the running process.  
starting transferring data from this buffer to the running process. <EFBFBD>
Sometimes the data will be transferred in several payloads, depending on
how much data is read at a time by the process itself. When TQProcess has
transferred all the data from its memory buffer to the running process, it

@ -2725,11 +2725,7 @@ static bool khmer_shape_syllable(TQOpenType *openType, TQShaperItem *item)
#ifndef QT_NO_XFTFREETYPE
if (openType) {
unsigned short logClusters[16];
for (int i = 0; i < len; ++i)
logClusters[i] = i;
uint where[16];
uint where[16];
for (int i = 0; i < len; ++i) {
where[i] = ~(PreSubstProperty
@ -3236,11 +3232,7 @@ static bool myanmar_shape_syllable(TQOpenType *openType, TQShaperItem *item, boo
#ifndef QT_NO_XFTFREETYPE
if (openType) {
unsigned short logClusters[32];
for (int i = 0; i < len; ++i)
logClusters[i] = i;
uint where[32];
uint where[32];
for (int i = 0; i < len; ++i) {
where[i] = ~(PreSubstProperty

@ -41,6 +41,7 @@
#include "qplatformdefs.h"
#include "ntqthread.h"
#include "ntqeventloop.h"
#include <private/qthreadinstance_p.h>
#ifndef QT_H
@ -238,4 +239,20 @@ void TQThread::postEvent( TQObject * receiver, TQEvent * event )
}
#endif
TQEventLoopThread::TQEventLoopThread() : TQThread()
{
//
}
TQEventLoopThread::~TQEventLoopThread()
{
//
}
void TQEventLoopThread::run()
{
TQEventLoop* eventLoop = TQApplication::eventLoop();
if (eventLoop) eventLoop->exec();
}
#endif // QT_THREAD_SUPPORT

@ -52,11 +52,6 @@ typedef pthread_mutex_t Q_MUTEX_T;
#include <sched.h>
static TQThreadInstance main_instance = {
0, { 0, &main_instance }, 0, 0, 1, 0, PTHREAD_COND_INITIALIZER, 0
};
static TQMutexPool *qt_thread_mutexpool = 0;
@ -82,10 +77,20 @@ static void create_storage_key()
** TQThreadInstance
*************************************************************************/
void TQThreadInstance::setCurrentThread(TQThread *thread)
{
pthread_once(&storage_key_once, create_storage_key);
pthread_setspecific(storage_key, thread);
}
TQThreadInstance *TQThreadInstance::current()
{
TQThreadInstance *ret = NULL;
pthread_once( &storage_key_once, create_storage_key );
TQThreadInstance *ret = (TQThreadInstance *) pthread_getspecific( storage_key );
TQThread *thread = (TQThread *) pthread_getspecific( storage_key );
if (thread) {
ret = thread->d;
}
return ret;
}
@ -101,6 +106,8 @@ void TQThreadInstance::init(unsigned int stackSize)
pthread_cond_init(&thread_done, NULL);
thread_id = 0;
eventLoop = 0;
// threads have not been initialized yet, do it now
if (! qt_thread_mutexpool) TQThread::initialize();
}
@ -114,8 +121,8 @@ void *TQThreadInstance::start( void *_arg )
{
void **arg = (void **) _arg;
pthread_once( &storage_key_once, create_storage_key );
pthread_setspecific( storage_key, arg[1] );
setCurrentThread( (TQThread *) arg[0] );
pthread_cleanup_push( TQThreadInstance::finish, arg[1] );
pthread_testcancel();
@ -192,9 +199,6 @@ void TQThread::initialize()
tqt_global_mutexpool = new TQMutexPool( TRUE, 73 );
if ( ! qt_thread_mutexpool )
qt_thread_mutexpool = new TQMutexPool( FALSE, 127 );
pthread_once( &storage_key_once, create_storage_key );
pthread_setspecific( storage_key, &main_instance );
}
/*! \internal
@ -206,11 +210,6 @@ void TQThread::cleanup()
delete qt_thread_mutexpool;
tqt_global_mutexpool = 0;
qt_thread_mutexpool = 0;
TQThreadInstance::finish(&main_instance);
pthread_once( &storage_key_once, create_storage_key );
pthread_setspecific( storage_key, 0 );
}
/*!
@ -470,5 +469,20 @@ bool TQThread::wait( unsigned long time )
return (ret == 0);
}
/*!
Returns a pointer to the currently executing TQThread. If the
current thread was not started using the TQThread API, this
function returns zero.
Note that TQApplication creates a TQThread object to represent the
main thread; calling this function from main() after creating
TQApplication will return a valid pointer.
*/
TQThread *TQThread::currentThreadObject()
{
pthread_once(&storage_key_once, create_storage_key);
return reinterpret_cast<TQThread *>(pthread_getspecific(storage_key));
}
#endif // QT_THREAD_SUPPORT

@ -56,6 +56,9 @@
#include "ntqstyle.h"
#include "ntqmetaobject.h"
#include "ntqguardedptr.h"
#if defined(QT_THREAD_SUPPORT)
#include "ntqthread.h"
#endif
#if defined(QT_ACCESSIBILITY_SUPPORT)
#include "ntqaccessible.h"
#endif
@ -887,6 +890,12 @@ TQWidget::TQWidget( TQWidget *parent, const char *name, WFlags f, NFlags n )
}
#endif
#if defined(QT_THREAD_SUPPORT) && defined(QT_CHECK_STATE)
if (TQThread::currentThreadObject() != TQApplication::guiThread()) {
tqFatal( "TQWidget: Cannot create a TQWidget outside of the main GUI thread" );
}
#endif
fstrut_dirty = 1;
isWidget = TRUE; // is a widget

@ -3193,6 +3193,7 @@ void generateClass() // generate C++ source code for a class
offset++;
}
}
fprintf( out, " o[%d].isLastObject = true;\n", f->args->count() + 0 );
fprintf( out, " activate_signal( clist, o );\n" );
// get return values from inOut parameters

@ -6019,6 +6019,7 @@ void generateClass() // generate C++ source code for a class
offset++;
}
}
fprintf( out, " o[%d].isLastObject = true;\n", f->args->count() + 0 );
fprintf( out, " activate_signal( clist, o );\n" );
// get return values from inOut parameters

@ -102,11 +102,17 @@ static TQ_UINT32 now()
return 0;
}
#if defined(__GLIBC__) && ((__GLIBC__ > 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 3)))
#define Q_MODERN_RES_API
#else
#endif
static TQPtrList<TQHostAddress> * ns = 0;
static TQStrList * domains = 0;
static bool ipv6support = FALSE;
#if defined(Q_MODERN_RES_API)
#else
static int qdns_res_init()
{
#ifdef Q_OS_MAC
@ -124,6 +130,7 @@ static int qdns_res_init()
return 0; // not called at all on Windows.
#endif
}
#endif
class TQDnsPrivate {
@ -2539,11 +2546,6 @@ void TQDns::doSynchronousLookup()
}
#endif
#if defined(__GLIBC__) && ((__GLIBC__ > 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 3)))
#define Q_MODERN_RES_API
#else
#endif
void TQDns::doResInit()
{
if ( ns )

@ -65,6 +65,9 @@ class TQSqlDatabasePrivate;
class TQM_EXPORT_SQL TQSqlDriverCreatorBase
{
public:
TQSqlDriverCreatorBase();
virtual ~TQSqlDriverCreatorBase();
public:
virtual TQSqlDriver* createObject() = 0;
};

@ -144,6 +144,12 @@ public:
TQSqlQuery createQuery() const { return TQSqlQuery( new TQNullResult(this) ); }
};
TQSqlDriverCreatorBase::TQSqlDriverCreatorBase() {
}
TQSqlDriverCreatorBase::~TQSqlDriverCreatorBase() {
}
typedef TQDict<TQSqlDriverCreatorBase> TQDriverDict;
class TQSqlDatabaseManager : public TQObject

@ -347,6 +347,11 @@ TQStyleControlElementData populateControlElementDataFromWidget(const TQWidget* w
const TQButton *button = dynamic_cast<const TQButton*>(widget);
if (button) {
ceData.text = button->text();
const TQPixmap* paletteBgPixmap = 0;
paletteBgPixmap = button->paletteBackgroundPixmap();
if (paletteBgPixmap) {
ceData.paletteBgPixmap = *paletteBgPixmap;
}
}
}
if (ceData.widgetObjectTypes.contains("TQTabBar")) {
@ -3215,6 +3220,13 @@ int TQCommonStyle::styleHint(StyleHint sh, const TQStyleControlElementData &ceDa
ret = 0;
break;
case SH_PopupMenu_SubMenuArrowColorActiveEnabled:
case SH_PopupMenu_SubMenuArrowColorActiveDisabled:
case SH_PopupMenu_SubMenuArrowColorInactiveEnabled:
case SH_PopupMenu_SubMenuArrowColorInactiveDisabled:
ret = -1;
break;
default:
ret = 0;
break;

@ -74,6 +74,9 @@ private:
TQMutex( const TQMutex & );
TQMutex &operator=( const TQMutex & );
#endif
public:
int level();
};
class Q_EXPORT TQMutexLocker

@ -67,6 +67,7 @@ public:
virtual bool locked() = 0;
virtual bool trylock() = 0;
virtual int type() const = 0;
virtual int level() = 0;
};

@ -74,7 +74,6 @@ typedef pthread_mutex_t Q_MUTEX_T;
#include <errno.h>
#include <string.h>
// Private class declarations
class TQRealMutexPrivate : public TQMutexPrivate {
@ -86,6 +85,7 @@ public:
bool locked();
bool trylock();
int type() const;
int level();
bool recursive;
};
@ -102,6 +102,7 @@ public:
bool locked();
bool trylock();
int type() const;
int level();
int count;
unsigned long owner;
@ -197,6 +198,11 @@ int TQRealMutexPrivate::type() const
return recursive ? Q_MUTEX_RECURSIVE : Q_MUTEX_NORMAL;
}
int TQRealMutexPrivate::level()
{
return locked();
}
#ifndef Q_RECURSIVE_MUTEX_TYPE
TQRecursiveMutexPrivate::TQRecursiveMutexPrivate()
@ -330,6 +336,11 @@ int TQRecursiveMutexPrivate::type() const
return Q_MUTEX_RECURSIVE;
}
int TQRecursiveMutexPrivate::level()
{
return count;
}
#endif // !Q_RECURSIVE_MUTEX_TYPE
@ -511,6 +522,22 @@ bool TQMutex::tryLock()
return d->trylock();
}
/*!
Returns the current lock level of the mutex.
0 means the mutex is unlocked
This method should only be called when the mutex has already been locked
by lock(), otherwise the lock level could change before the next line
of code is executed.
WARNING: Non-recursive mutexes will never exceed a lock level of 1!
\sa lock(), unlock(), locked()
*/
int TQMutex::level()
{
return d->level();
}
/*!
\class TQMutexLocker ntqmutex.h
\brief The TQMutexLocker class simplifies locking and unlocking TQMutexes.

@ -62,8 +62,12 @@
#include <pthread.h>
#endif
class TQThread;
class TQEventLoop;
class TQThreadInstance {
public:
static void setCurrentThread(TQThread *thread);
static TQThreadInstance *current();
void init(unsigned int stackSize);
@ -95,6 +99,8 @@ public:
static unsigned int __stdcall start( void * );
static void finish( TQThreadInstance * );
#endif // Q_OS_WIN32
TQEventLoop* eventLoop;
};
#endif // QT_THREAD_SUPPORT

@ -39,6 +39,9 @@
**********************************************************************/
#include "qucom_p.h"
#include "qucomextra_p.h"
#include "ntqvariant.h"
// Standard types
@ -545,3 +548,24 @@ void TQUType_TQString::clear( TQUObject *o )
delete (TQString*)o->payload.ptr;
o->payload.ptr = 0;
}
TQUObject* TQUObject::deepCopy(TQUObject* newLocation) {
TQUObject* ret;
if (newLocation) {
ret = new(newLocation) TQUObject(*this);
}
else {
ret = new TQUObject(*this);
}
// Any type that has a clear() method must be copied here!
if (*(type->uuid()) == TID_QUType_charstar) {
static_QUType_charstar.set( ret, (const char *)static_QUType_charstar.get(this), true );
}
if (*(type->uuid()) == TID_QUType_TQString) {
static_QUType_TQString.set( ret, (TQString)static_QUType_TQString.get(this) );
}
if (*(type->uuid()) == TID_QUType_TQVariant) {
static_QUType_TQVariant.set( ret, (TQVariant)static_QUType_TQVariant.get(this) );
}
return ret;
}

@ -127,7 +127,7 @@ extern Q_EXPORT TQUType_Null static_QUType_Null;
struct Q_EXPORT TQUObject
{
public: // scary MSVC bug makes this necessary
TQUObject() : type( &static_QUType_Null ) {}
TQUObject() : type( &static_QUType_Null ), isLastObject(false) {}
~TQUObject() { type->clear( this ); }
TQUType *type;
@ -184,6 +184,8 @@ public: // scary MSVC bug makes this necessary
} payload;
TQUObject* deepCopy(TQUObject*);
bool isLastObject;
};

@ -92,6 +92,7 @@ class Q_EXPORT TQToolTip: public TQt
{
public:
TQToolTip( TQWidget *, TQToolTipGroup * = 0 );
virtual ~TQToolTip();
//### add virtual d'tor for 4.0
static void add( TQWidget *, const TQString &);

@ -265,6 +265,7 @@ class TQListViewToolTip : public TQToolTip
{
public:
TQListViewToolTip( TQWidget *parent, TQListView *lv );
virtual ~TQListViewToolTip();
void maybeTip( const TQPoint &pos );
@ -278,6 +279,10 @@ TQListViewToolTip::TQListViewToolTip( TQWidget *parent, TQListView *lv )
{
}
TQListViewToolTip::~TQListViewToolTip()
{
}
void TQListViewToolTip::maybeTip( const TQPoint &pos )
{
if ( !parentWidget() || !view || !view->showToolTips() )

@ -1391,6 +1391,7 @@ void TQPopupMenu::show()
performDelayedChanges();
updateSize(TRUE);
TQWidget::show();
updateSize();
popupActive = -1;
if(style().styleHint(TQStyle::SH_PopupMenu_SubMenuPopupDelay, this))
d->mouseMoveBuffer = TQRegion();

@ -824,6 +824,10 @@ TQToolTip::TQToolTip( TQWidget * widget, TQToolTipGroup * group )
TQString::null, g, TQString::null, this, FALSE );
}
TQToolTip::~TQToolTip()
{
}
/*!
Adds a tool tip to \a widget. \a text is the text to be shown in

@ -0,0 +1,173 @@
/****************************************************************
**
** TQt threading tutorial
** (c) 2012 Timothy Pearson <kb9vqf@pearsoncomputing.net>
**
** This tutorial is released into the Public Domain and
** can therefore be modified and/or used for any purpose
**
****************************************************************/
#include "main.h"
#include <unistd.h>
#include <ntqtimer.h>
#include <ntqeventloop.h>
void WorkerObject::run()
{
tqDebug( "[%s] thread: %p event loop: %p", threadFriendlyName.ascii(), TQThread::currentThreadObject(), TQApplication::eventLoop() );
TQEventLoop* eventLoop = TQApplication::eventLoop();
if (!eventLoop) return;
TQTimer *t = new TQTimer(this);
connect( t, SIGNAL(timeout()), SLOT(timerHandler()) );
t->start( 1000, FALSE );
for( int count = 0; count < 5; count++ ) {
sleep( 1 );
tqDebug( "[%s] Ping!", threadFriendlyName.ascii() );
displayMessage("Hi", "There!");
eventLoop->processEvents(TQEventLoop::AllEvents);
}
eventLoop->exit(0);
}
void WorkerObject::timerHandler()
{
tqDebug( "[%s] Timer fired!", threadFriendlyName.ascii() );
}
void MainObject::emitMessage(TQString str1, TQString str2)
{
tqDebug( "%s", ("[MainObject] emitMessage: " + str1 + " " + str2).ascii() );
}
void MainObject::buttonClicked()
{
tqDebug( "[MainObject] Button clicked!" );
TQEventLoop* eventLoop = TQApplication::eventLoop();
if (!eventLoop) return;
eventLoop->exit(0);
}
#define SET_UP_WORKER(x, y, z) \
WorkerObject x; \
x.threadFriendlyName = y; \
x.moveToThread(&z); \
TQObject::connect(&x, SIGNAL(displayMessage(TQString,TQString)), &mainobject, SLOT(emitMessage(TQString,TQString))); \
TQTimer::singleShot(0, &x, SLOT(run()));
int main( int argc, char **argv )
{
TQApplication a( argc, argv );
tqDebug( "[MainObject] thread: %p event loop: %p", TQThread::currentThreadObject(), TQApplication::eventLoop() );
TQPushButton hello( "Exit", 0 );
hello.resize( 100, 30 );
MainObject mainobject;
TQEventLoopThread workerthread0;
TQEventLoopThread workerthread1;
TQEventLoopThread workerthread2;
TQEventLoopThread workerthread3;
TQEventLoopThread workerthread4;
TQEventLoopThread workerthread5;
TQEventLoopThread workerthread6;
TQEventLoopThread workerthread7;
TQEventLoopThread workerthread8;
TQEventLoopThread workerthread9;
TQEventLoopThread workerthread10;
TQEventLoopThread workerthread11;
TQEventLoopThread workerthread12;
TQEventLoopThread workerthread13;
TQEventLoopThread workerthread14;
TQEventLoopThread workerthread15;
TQEventLoopThread workerthread16;
TQEventLoopThread workerthread17;
TQEventLoopThread workerthread18;
TQEventLoopThread workerthread19;
SET_UP_WORKER(workerobject0, "WorkerObject0", workerthread0)
SET_UP_WORKER(workerobject1, "WorkerObject1", workerthread1)
SET_UP_WORKER(workerobject2, "WorkerObject2", workerthread2)
SET_UP_WORKER(workerobject3, "WorkerObject3", workerthread3)
SET_UP_WORKER(workerobject4, "WorkerObject4", workerthread4)
SET_UP_WORKER(workerobject5, "WorkerObject5", workerthread5)
SET_UP_WORKER(workerobject6, "WorkerObject6", workerthread6)
SET_UP_WORKER(workerobject7, "WorkerObject7", workerthread7)
SET_UP_WORKER(workerobject8, "WorkerObject8", workerthread8)
SET_UP_WORKER(workerobject9, "WorkerObject9", workerthread9)
SET_UP_WORKER(workerobject10, "WorkerObjec10", workerthread10)
SET_UP_WORKER(workerobject11, "WorkerObjec11", workerthread11)
SET_UP_WORKER(workerobject12, "WorkerObjec12", workerthread12)
SET_UP_WORKER(workerobject13, "WorkerObjec13", workerthread13)
SET_UP_WORKER(workerobject14, "WorkerObjec14", workerthread14)
SET_UP_WORKER(workerobject15, "WorkerObjec15", workerthread15)
SET_UP_WORKER(workerobject16, "WorkerObjec16", workerthread16)
SET_UP_WORKER(workerobject17, "WorkerObjec17", workerthread17)
SET_UP_WORKER(workerobject18, "WorkerObjec18", workerthread18)
SET_UP_WORKER(workerobject19, "WorkerObjec19", workerthread19)
workerthread0.start();
workerthread1.start();
workerthread2.start();
workerthread3.start();
workerthread4.start();
workerthread5.start();
workerthread6.start();
workerthread7.start();
workerthread8.start();
workerthread9.start();
workerthread10.start();
workerthread11.start();
workerthread12.start();
workerthread13.start();
workerthread14.start();
workerthread15.start();
workerthread16.start();
workerthread17.start();
workerthread18.start();
workerthread19.start();
a.setMainWidget( &hello );
TQObject::connect(&hello, SIGNAL(clicked()), &mainobject, SLOT(buttonClicked()));
hello.show();
a.exec();
hello.hide();
tqDebug( "[MainObject] Waiting for thread completion..." );
workerthread0.wait();
workerthread1.wait();
workerthread2.wait();
workerthread3.wait();
workerthread4.wait();
workerthread5.wait();
workerthread6.wait();
workerthread7.wait();
workerthread8.wait();
workerthread9.wait();
workerthread10.wait();
workerthread11.wait();
workerthread12.wait();
workerthread13.wait();
workerthread14.wait();
workerthread15.wait();
workerthread16.wait();
workerthread17.wait();
workerthread18.wait();
workerthread19.wait();
tqDebug( "[MainObject] Finished!" );
}

@ -0,0 +1,45 @@
/****************************************************************
**
** TQt threading tutorial
** (c) 2012 Timothy Pearson <kb9vqf@pearsoncomputing.net>
**
** This tutorial is released into the Public Domain and
** can therefore be modified and/or used for any purpose
**
****************************************************************/
#ifndef _MAIN_H_
#define _MAIN_H_
#include <ntqapplication.h>
#include <ntqobject.h>
#include <ntqpushbutton.h>
#include <ntqthread.h>
class MainObject;
class WorkerObject : public TQObject
{
TQ_OBJECT
public slots:
void run();
void timerHandler();
signals:
void displayMessage(TQString, TQString);
public:
TQString threadFriendlyName;
};
class MainObject : public TQObject
{
TQ_OBJECT
public slots:
void emitMessage(TQString, TQString);
void buttonClicked();
};
#endif // _MAIN_H_

@ -0,0 +1,5 @@
TEMPLATE = app
CONFIG += qt warn_on release
HEADERS = main.h
SOURCES = main.cpp
TARGET = t15

@ -1,2 +1,2 @@
TEMPLATE = subdirs
SUBDIRS = t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14
SUBDIRS = t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15

Loading…
Cancel
Save