@ -542,12 +542,19 @@ TQClipboard *tqt_clipboard = 0; // global clipboard object
TQWidgetList * tqt_modal_stack = 0 ; // stack of modal widgets
TQWidgetList * tqt_modal_stack = 0 ; // stack of modal widgets
# ifdef TQT_THREAD_SUPPORT
# ifdef TQT_THREAD_SUPPORT
// thread wrapper for the main() thread
// thread wrapper for the main() thread
class TQCoreApplicationThread : public TQThread
class TQCoreApplicationThread : public TQThread
{
{
public :
public :
inline TQCoreApplicationThread ( )
inline TQCoreApplicationThread ( )
{
{
# ifdef QT_CHECK_STATE
if ( tqt_gui_thread_self )
tqWarning ( " TQCoreApplicationThread: there should be exactly one main thread object " ) ;
# endif
tqt_gui_thread_self = this ;
TQThreadInstance : : setCurrentThread ( this ) ;
TQThreadInstance : : setCurrentThread ( this ) ;
// thread should be running and not finished for the lifetime
// thread should be running and not finished for the lifetime
@ -556,11 +563,19 @@ public:
d - > finished = false ;
d - > finished = false ;
d - > eventLoop = NULL ;
d - > eventLoop = NULL ;
}
}
inline ~ TQCoreApplicationThread ( )
inline ~ TQCoreApplicationThread ( )
{
{
tqt_gui_thread_self = nullptr ;
// avoid warning from TQThread
// avoid warning from TQThread
d - > running = false ;
d - > running = false ;
// do some cleanup, namely clean up the thread-local storage associated with the GUI thread
TQThreadInstance : : finishGuiThread ( d ) ;
}
}
static TQCoreApplicationThread * self ( ) { return tqt_gui_thread_self ; }
private :
private :
inline void run ( )
inline void run ( )
{
{
@ -568,10 +583,15 @@ private:
// only so that we can instantiate the object
// only so that we can instantiate the object
tqFatal ( " TQCoreApplicationThread: internal error " ) ;
tqFatal ( " TQCoreApplicationThread: internal error " ) ;
}
}
static TQCoreApplicationThread * tqt_gui_thread_self ;
} ;
} ;
TQCoreApplicationThread * TQCoreApplicationThread : : tqt_gui_thread_self = nullptr ;
// construct exactly one instance of the core thread with static storage duration. Do it static
// rather than in the heap as we need it to be properly destroyed on the exit from the program.
static TQCoreApplicationThread tqt_main_thread ;
static TQCoreApplicationThread tqt_main_thread ;
static TQThread * mainThread ( ) { return & tqt_main_thread ; }
# endif
# endif
// Definitions for posted events
// Definitions for posted events
@ -1035,7 +1055,7 @@ TQApplication::TQApplication(Display *dpy, int argc, char **argv,
# ifdef TQT_THREAD_SUPPORT
# ifdef TQT_THREAD_SUPPORT
TQThread * TQApplication : : guiThread ( ) {
TQThread * TQApplication : : guiThread ( ) {
return mainThread ( ) ;
return TQCoreApplicationThread : : self ( ) ;
}
}
bool TQApplication : : isGuiThread ( ) {
bool TQApplication : : isGuiThread ( ) {