wxUsleep() introduced (and documented) to try to work around usleep() bug in

MT programs under Solaris


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1852 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
1999-03-03 17:11:14 +00:00
parent ba6f401d45
commit afb7489128
14 changed files with 643 additions and 503 deletions

460
configure vendored

File diff suppressed because it is too large Load Diff

View File

@@ -450,7 +450,10 @@ AC_SUBST(GTK_JOYSTICK)
dnl check for vprintf/vsprintf() which are GNU extensions dnl check for vprintf/vsprintf() which are GNU extensions
AC_FUNC_VPRINTF AC_FUNC_VPRINTF
dnl check for vsnprintf() which is another GNU extension dnl check for vsnprintf() which is another GNU extension
AC_CHECK_FUNC(vsnprintf, AC_DEFINE(HAVE_VSNPRINTF)) AC_CHECK_FUNCS(vsnprintf)
dnl check for usleep() and nanosleep() which is better in MT programs
AC_CHECK_FUNCS(nanosleep usleep)
AC_LANG_SAVE AC_LANG_SAVE
AC_LANG_CPLUSPLUS AC_LANG_CPLUSPLUS

View File

@@ -1434,6 +1434,18 @@ This function is now obsolete, replaced by \helpref{Log functions}{logfunctions}
<wx/memory.h> <wx/memory.h>
\membersection{::wxUsleep}\label{wxusleep}
\func{void}{wxUsleep}{\param{unsigned long}{ milliseconds}}
Sleeps for the specified number of milliseconds. Notice that usage of this
function is encouraged instead of calling usleep(3) directly because the
standard usleep() function is not MT safe.
\wxheading{Include files}
<wx/utils.h>
\membersection{::wxWriteResource}\label{wxwriteresource} \membersection{::wxWriteResource}\label{wxwriteresource}
\func{bool}{wxWriteResource}{\param{const wxString\& }{section}, \param{const wxString\& }{entry}, \func{bool}{wxWriteResource}{\param{const wxString\& }{section}, \param{const wxString\& }{entry},

View File

@@ -49,13 +49,13 @@ class WXDLLEXPORT wxFrame;
#define wxToLower(C) (((C) >= 'A' && (C) <= 'Z')? (C) - 'A' + 'a': (C)) #define wxToLower(C) (((C) >= 'A' && (C) <= 'Z')? (C) - 'A' + 'a': (C))
// Return a string with the current date/time // Return a string with the current date/time
WXDLLEXPORT wxString wxNow(void); WXDLLEXPORT wxString wxNow();
// Make a copy of this string using 'new' // Make a copy of this string using 'new'
WXDLLEXPORT char* copystring(const char *s); WXDLLEXPORT char* copystring(const char *s);
// Generate a unique ID // Generate a unique ID
WXDLLEXPORT long wxNewId(void); WXDLLEXPORT long wxNewId();
#define NewId wxNewId #define NewId wxNewId
// Ensure subsequent IDs don't clash with this one // Ensure subsequent IDs don't clash with this one
@@ -63,7 +63,7 @@ WXDLLEXPORT void wxRegisterId(long id);
#define RegisterId wxRegisterId #define RegisterId wxRegisterId
// Return the current ID // Return the current ID
WXDLLEXPORT long wxGetCurrentId(void); WXDLLEXPORT long wxGetCurrentId();
// Useful buffer // Useful buffer
WXDLLEXPORT_DATA(extern char*) wxBuffer; WXDLLEXPORT_DATA(extern char*) wxBuffer;
@@ -111,11 +111,14 @@ WXDLLEXPORT bool wxShell(const wxString& command = wxEmptyString);
// Sleep for nSecs seconds under UNIX, do nothing under Windows // Sleep for nSecs seconds under UNIX, do nothing under Windows
WXDLLEXPORT void wxSleep(int nSecs); WXDLLEXPORT void wxSleep(int nSecs);
// Sleep for a given amount of milliseconds
WXDLLEXPORT void wxUsleep(unsigned long milliseconds);
// Get free memory in bytes, or -1 if cannot determine amount (e.g. on UNIX) // Get free memory in bytes, or -1 if cannot determine amount (e.g. on UNIX)
WXDLLEXPORT long wxGetFreeMemory(void); WXDLLEXPORT long wxGetFreeMemory();
// Consume all events until no more left // Consume all events until no more left
WXDLLEXPORT void wxFlushEvents(void); WXDLLEXPORT void wxFlushEvents();
/* /*
* Network and username functions. * Network and username functions.
@@ -166,7 +169,7 @@ WXDLLEXPORT int wxFindMenuItemId(wxFrame *frame, const wxString& menuString, con
#define wxMin(a,b) (((a) < (b)) ? (a) : (b)) #define wxMin(a,b) (((a) < (b)) ? (a) : (b))
// Yield to other apps/messages // Yield to other apps/messages
WXDLLEXPORT bool wxYield(void); WXDLLEXPORT bool wxYield();
// Format a message on the standard error (UNIX) or the debugging // Format a message on the standard error (UNIX) or the debugging
// stream (Windows) // stream (Windows)
@@ -184,20 +187,22 @@ WXDLLEXPORT_DATA(extern wxCursor*) wxHOURGLASS_CURSOR;
WXDLLEXPORT void wxBeginBusyCursor(wxCursor *cursor = wxHOURGLASS_CURSOR); WXDLLEXPORT void wxBeginBusyCursor(wxCursor *cursor = wxHOURGLASS_CURSOR);
// Restore cursor to normal // Restore cursor to normal
WXDLLEXPORT void wxEndBusyCursor(void); WXDLLEXPORT void wxEndBusyCursor();
// TRUE if we're between the above two calls // TRUE if we're between the above two calls
WXDLLEXPORT bool wxIsBusy(void); WXDLLEXPORT bool wxIsBusy();
// Convenience class so we can just create a wxBusyCursor object on the stack // Convenience class so we can just create a wxBusyCursor object on the stack
class WXDLLEXPORT wxBusyCursor class WXDLLEXPORT wxBusyCursor
{ {
public: public:
inline wxBusyCursor(wxCursor* cursor = wxHOURGLASS_CURSOR) { wxBeginBusyCursor(cursor); } wxBusyCursor(wxCursor* cursor = wxHOURGLASS_CURSOR)
inline ~wxBusyCursor() { wxEndBusyCursor(); } { wxBeginBusyCursor(cursor); }
~wxBusyCursor()
{ wxEndBusyCursor(); }
}; };
/* Error message functions used by wxWindows */ // Error message functions used by wxWindows
// Non-fatal error (continues) // Non-fatal error (continues)
WXDLLEXPORT_DATA(extern const char*) wxInternalErrorStr; WXDLLEXPORT_DATA(extern const char*) wxInternalErrorStr;

View File

@@ -374,6 +374,18 @@
/* Define if you have vsnprintf() */ /* Define if you have vsnprintf() */
#undef HAVE_VSNPRINTF #undef HAVE_VSNPRINTF
/* Define if you have usleep() */
#undef HAVE_USLEEP
/* Define if you have nanosleep() */
#undef HAVE_NANOSLEEP
/* Define if you have usleep() */
#undef HAVE_USLEEP
/* Define if you have nanosleep() */
#undef HAVE_NANOSLEEP
/* Define if your system has its own `getloadavg' function. */ /* Define if your system has its own `getloadavg' function. */
#undef HAVE_GETLOADAVG #undef HAVE_GETLOADAVG

View File

@@ -54,20 +54,20 @@ wxHashTable* wxClassInfo::sm_classTable = (wxHashTable*) NULL;
* wxWindows root object. * wxWindows root object.
*/ */
wxObject::wxObject(void) wxObject::wxObject()
{ {
m_refData = (wxObjectRefData *) NULL; m_refData = (wxObjectRefData *) NULL;
#if wxUSE_SERIAL #if wxUSE_SERIAL
m_serialObj = (wxObject_Serialize *)NULL; m_serialObj = (wxObject_Serialize *)NULL;
#endif #endif
} }
wxObject::~wxObject(void) wxObject::~wxObject()
{ {
UnRef(); UnRef();
#if wxUSE_SERIAL #if wxUSE_SERIAL
if (m_serialObj) if (m_serialObj)
delete m_serialObj; delete m_serialObj;
#endif #endif
} }
@@ -77,23 +77,23 @@ wxObject::~wxObject(void)
* Go from this class to superclass, taking into account * Go from this class to superclass, taking into account
* two possible base classes. * two possible base classes.
*/ */
bool wxObject::IsKindOf(wxClassInfo *info) const bool wxObject::IsKindOf(wxClassInfo *info) const
{ {
wxClassInfo *thisInfo = GetClassInfo(); wxClassInfo *thisInfo = GetClassInfo();
if (thisInfo) if (thisInfo)
return thisInfo->IsKindOf(info); return thisInfo->IsKindOf(info);
else else
return FALSE; return FALSE;
} }
#if defined(__WXDEBUG__) || wxUSE_DEBUG_CONTEXT #if defined(__WXDEBUG__) || wxUSE_DEBUG_CONTEXT
void wxObject::Dump(ostream& str) void wxObject::Dump(ostream& str)
{ {
if (GetClassInfo() && GetClassInfo()->GetClassName()) if (GetClassInfo() && GetClassInfo()->GetClassName())
str << GetClassInfo()->GetClassName(); str << GetClassInfo()->GetClassName();
else else
str << "unknown object class"; str << "unknown object class";
} }
#endif #endif
@@ -103,21 +103,21 @@ void wxObject::Dump(ostream& str)
#undef new #undef new
#endif #endif
void * wxObject::operator new (size_t size, char * fileName, int lineNum) void *wxObject::operator new (size_t size, char * fileName, int lineNum)
{ {
return wxDebugAlloc(size, fileName, lineNum, TRUE); return wxDebugAlloc(size, fileName, lineNum, TRUE);
} }
void wxObject::operator delete (void * buf) void wxObject::operator delete (void * buf)
{ {
wxDebugFree(buf); wxDebugFree(buf);
} }
// VC++ 6.0 // VC++ 6.0
#if defined(__VISUALC__) && (__VISUALC__ >= 1200) #if defined(__VISUALC__) && (__VISUALC__ >= 1200)
void wxObject::operator delete(void* pData, char* /* fileName */, int /* lineNum */) void wxObject::operator delete(void* pData, char* /* fileName */, int /* lineNum */)
{ {
::operator delete(pData); ::operator delete(pData);
} }
#endif #endif
@@ -125,12 +125,12 @@ void wxObject::operator delete(void* pData, char* /* fileName */, int /* lineNum
#if !defined(__VISUALC__) && wxUSE_ARRAY_MEMORY_OPERATORS #if !defined(__VISUALC__) && wxUSE_ARRAY_MEMORY_OPERATORS
void * wxObject::operator new[] (size_t size, char * fileName, int lineNum) void * wxObject::operator new[] (size_t size, char * fileName, int lineNum)
{ {
return wxDebugAlloc(size, fileName, lineNum, TRUE, TRUE); return wxDebugAlloc(size, fileName, lineNum, TRUE, TRUE);
} }
void wxObject::operator delete[] (void * buf) void wxObject::operator delete[] (void * buf)
{ {
wxDebugFree(buf, TRUE); wxDebugFree(buf, TRUE);
} }
#endif #endif
@@ -142,97 +142,97 @@ void wxObject::operator delete[] (void * buf)
wxClassInfo::wxClassInfo(char *cName, char *baseName1, char *baseName2, int sz, wxObjectConstructorFn constr) wxClassInfo::wxClassInfo(char *cName, char *baseName1, char *baseName2, int sz, wxObjectConstructorFn constr)
{ {
m_className = cName; m_className = cName;
m_baseClassName1 = baseName1; m_baseClassName1 = baseName1;
m_baseClassName2 = baseName2; m_baseClassName2 = baseName2;
m_objectSize = sz; m_objectSize = sz;
m_objectConstructor = constr; m_objectConstructor = constr;
m_next = sm_first;
sm_first = this;
m_baseInfo1 = (wxClassInfo *) NULL; m_next = sm_first;
m_baseInfo2 = (wxClassInfo *) NULL; sm_first = this;
m_baseInfo1 = (wxClassInfo *) NULL;
m_baseInfo2 = (wxClassInfo *) NULL;
} }
wxObject *wxClassInfo::CreateObject(void) wxObject *wxClassInfo::CreateObject()
{ {
if (m_objectConstructor) if (m_objectConstructor)
return (wxObject *)(*m_objectConstructor)(); return (wxObject *)(*m_objectConstructor)();
else else
return (wxObject *) NULL; return (wxObject *) NULL;
} }
wxClassInfo *wxClassInfo::FindClass(char *c) wxClassInfo *wxClassInfo::FindClass(char *c)
{ {
wxClassInfo *p = sm_first; wxClassInfo *p = sm_first;
while (p) while (p)
{ {
if (p && p->GetClassName() && strcmp(p->GetClassName(), c) == 0) if (p && p->GetClassName() && strcmp(p->GetClassName(), c) == 0)
return p; return p;
p = p->m_next; p = p->m_next;
} }
return (wxClassInfo *) NULL; return (wxClassInfo *) NULL;
} }
// Climb upwards through inheritance hierarchy. // Climb upwards through inheritance hierarchy.
// Dual inheritance is catered for. // Dual inheritance is catered for.
bool wxClassInfo::IsKindOf(wxClassInfo *info) const bool wxClassInfo::IsKindOf(wxClassInfo *info) const
{ {
if (info == NULL) if (info == NULL)
return FALSE; return FALSE;
// For some reason, when making/using a DLL, static data has to be included // For some reason, when making/using a DLL, static data has to be included
// in both the DLL and the application. This can lead to duplicate // in both the DLL and the application. This can lead to duplicate
// wxClassInfo objects, so we have to test the name instead of the pointers. // wxClassInfo objects, so we have to test the name instead of the pointers.
// PROBABLY NO LONGER TRUE now I've done DLL creation right. // PROBABLY NO LONGER TRUE now I've done DLL creation right.
/* /*
#if WXMAKINGDLL #if WXMAKINGDLL
if (GetClassName() && info->GetClassName() && (strcmp(GetClassName(), info->GetClassName()) == 0)) if (GetClassName() && info->GetClassName() && (strcmp(GetClassName(), info->GetClassName()) == 0))
return TRUE; return TRUE;
#else #else
*/ */
if (this == info) if (this == info)
return TRUE; return TRUE;
if (m_baseInfo1) if (m_baseInfo1)
if (m_baseInfo1->IsKindOf(info)) if (m_baseInfo1->IsKindOf(info))
return TRUE; return TRUE;
if (m_baseInfo2) if (m_baseInfo2)
return m_baseInfo2->IsKindOf(info); return m_baseInfo2->IsKindOf(info);
return FALSE; return FALSE;
} }
// Set pointers to base class(es) to speed up IsKindOf // Set pointers to base class(es) to speed up IsKindOf
void wxClassInfo::InitializeClasses(void) void wxClassInfo::InitializeClasses()
{ {
wxClassInfo::sm_classTable = new wxHashTable(wxKEY_STRING); wxClassInfo::sm_classTable = new wxHashTable(wxKEY_STRING);
// Index all class infos by their class name // Index all class infos by their class name
wxClassInfo *info = sm_first; wxClassInfo *info = sm_first;
while (info) while (info)
{ {
if (info->m_className) if (info->m_className)
sm_classTable->Put(info->m_className, (wxObject *)info); sm_classTable->Put(info->m_className, (wxObject *)info);
info = info->m_next; info = info->m_next;
} }
// Set base pointers for each wxClassInfo // Set base pointers for each wxClassInfo
info = sm_first; info = sm_first;
while (info) while (info)
{ {
if (info->GetBaseClassName1()) if (info->GetBaseClassName1())
info->m_baseInfo1 = (wxClassInfo *)sm_classTable->Get(info->GetBaseClassName1()); info->m_baseInfo1 = (wxClassInfo *)sm_classTable->Get(info->GetBaseClassName1());
if (info->GetBaseClassName2()) if (info->GetBaseClassName2())
info->m_baseInfo2 = (wxClassInfo *)sm_classTable->Get(info->GetBaseClassName2()); info->m_baseInfo2 = (wxClassInfo *)sm_classTable->Get(info->GetBaseClassName2());
info = info->m_next; info = info->m_next;
} }
} }
void wxClassInfo::CleanUpClasses(void) void wxClassInfo::CleanUpClasses()
{ {
delete wxClassInfo::sm_classTable; delete wxClassInfo::sm_classTable;
wxClassInfo::sm_classTable = NULL; wxClassInfo::sm_classTable = NULL;
@@ -270,54 +270,54 @@ wxObject *wxCreateDynamicObject(const char *name)
wxObject* wxCreateStoredObject( wxInputStream &stream ) wxObject* wxCreateStoredObject( wxInputStream &stream )
{ {
wxObjectInputStream obj_s(stream); wxObjectInputStream obj_s(stream);
return obj_s.LoadObject(); return obj_s.LoadObject();
}; };
void wxObject::StoreObject( wxObjectOutputStream& stream ) void wxObject::StoreObject( wxObjectOutputStream& stream )
{ {
wxString obj_name = wxString(GetClassInfo()->GetClassName()) + "_Serialize"; wxString obj_name = wxString(GetClassInfo()->GetClassName()) + "_Serialize";
wxLibrary *lib = wxTheLibraries.LoadLibrary("wxserial"); wxLibrary *lib = wxTheLibraries.LoadLibrary("wxserial");
if (!lib) { if (!lib) {
wxLogError(_("Can't load wxSerial dynamic library.")); wxLogError(_("Can't load wxSerial dynamic library."));
return; return;
}
if (!m_serialObj) {
m_serialObj = (WXSERIAL(wxObject) *)lib->CreateObject( obj_name );
if (!m_serialObj) {
wxLogError(_("Can't find the serialization object '%s' "
"for the object '%s'."),
obj_name.c_str(),
GetClassInfo()->GetClassName());
return;
} }
m_serialObj->SetObject(this); if (!m_serialObj) {
} m_serialObj = (WXSERIAL(wxObject) *)lib->CreateObject( obj_name );
m_serialObj->StoreObject(stream); if (!m_serialObj) {
wxLogError(_("Can't find the serialization object '%s' "
"for the object '%s'."),
obj_name.c_str(),
GetClassInfo()->GetClassName());
return;
}
m_serialObj->SetObject(this);
}
m_serialObj->StoreObject(stream);
} }
void wxObject::LoadObject( wxObjectInputStream& stream ) void wxObject::LoadObject( wxObjectInputStream& stream )
{ {
wxString obj_name = wxString(GetClassInfo()->GetClassName()) + "_Serialize"; wxString obj_name = wxString(GetClassInfo()->GetClassName()) + "_Serialize";
wxLibrary *lib = wxTheLibraries.LoadLibrary("wxserial"); wxLibrary *lib = wxTheLibraries.LoadLibrary("wxserial");
if (!m_serialObj) {
m_serialObj = (WXSERIAL(wxObject) *)lib->CreateObject( obj_name );
if (!m_serialObj) { if (!m_serialObj) {
wxLogError(_("Can't find the serialization object '%s' " m_serialObj = (WXSERIAL(wxObject) *)lib->CreateObject( obj_name );
"for the object '%s'."),
obj_name.c_str(),
GetClassInfo()->GetClassName());
return;
}
m_serialObj->SetObject(this);
}
m_serialObj->LoadObject(stream); if (!m_serialObj) {
wxLogError(_("Can't find the serialization object '%s' "
"for the object '%s'."),
obj_name.c_str(),
GetClassInfo()->GetClassName());
return;
}
m_serialObj->SetObject(this);
}
m_serialObj->LoadObject(stream);
} }
#endif // wxUSE_SERIAL #endif // wxUSE_SERIAL
@@ -337,7 +337,7 @@ void wxObject::Ref(const wxObject& clone)
} }
} }
void wxObject::UnRef(void) void wxObject::UnRef()
{ {
if (m_refData) { if (m_refData) {
assert(m_refData->m_count > 0); assert(m_refData->m_count > 0);
@@ -356,7 +356,7 @@ wxObjectRefData::wxObjectRefData(void) : m_count(1)
{ {
} }
wxObjectRefData::~wxObjectRefData(void) wxObjectRefData::~wxObjectRefData()
{ {
} }

View File

@@ -8,7 +8,7 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ #ifdef __GNUG__
#pragma implementation "app.h" #pragma implementation "app.h"
#endif #endif
#include "wx/app.h" #include "wx/app.h"
@@ -20,35 +20,24 @@
#include "wx/font.h" #include "wx/font.h"
#include "wx/settings.h" #include "wx/settings.h"
#include "wx/dialog.h" #include "wx/dialog.h"
#if wxUSE_WX_RESOURCES #if wxUSE_WX_RESOURCES
#include "wx/resource.h" #include "wx/resource.h"
#endif #endif
#include "wx/module.h" #include "wx/module.h"
#include "wx/image.h" #include "wx/image.h"
#if wxUSE_THREADS
#include "wx/thread.h" #include "wx/thread.h"
#endif
#include "unistd.h" #include "unistd.h"
// many versions of Unices have this function, but it is not defined in system #include <glib.h>
// headers - please add your system here if it is the case for your OS. #include <gdk/gdk.h>
// SunOS < 5.6 (i.e. Solaris < 2.6) and DG-UX are like this. #include <gtk/gtk.h>
#if (defined(__SUN__) && !defined(__SunOs_5_6) && \
!defined(__SunOs_5_7) && !defined(__SUNPRO_CC)) || \
defined(__osf__)
extern "C"
{
void usleep(unsigned long usec);
};
#endif // Unices without usleep()
#include "glib.h"
#include "gdk/gdk.h"
#include "gtk/gtk.h"
#include "wx/gtk/win_gtk.h" #include "wx/gtk/win_gtk.h"
#include <unistd.h> // usleep() on solaris
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// global data // global data
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -160,14 +149,17 @@ END_EVENT_TABLE()
gint wxapp_idle_callback( gpointer WXUNUSED(data) ) gint wxapp_idle_callback( gpointer WXUNUSED(data) )
{ {
if (wxTheApp) while (wxTheApp->ProcessIdle()) {} if (wxTheApp)
#if wxUSE_THREADS {
while (wxTheApp->ProcessIdle())
{
}
}
wxMutexGuiLeave(); wxMutexGuiLeave();
#endif wxUsleep(10);
usleep(10000);
#if wxUSE_THREADS
wxMutexGuiEnter(); wxMutexGuiEnter();
#endif
return TRUE; return TRUE;
} }

View File

@@ -410,9 +410,7 @@ void wxThread::Yield()
void wxThread::Sleep(unsigned long milliseconds) void wxThread::Sleep(unsigned long milliseconds)
{ {
// FIXME how to test for nanosleep() availability? wxUsleep(milliseconds);
usleep(milliseconds * 1000); // usleep(3) wants microseconds
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------

View File

@@ -7,11 +7,6 @@
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
//#ifdef __GNUG__
//#pragma implementation "utils.h"
//#endif
#include "wx/utils.h" #include "wx/utils.h"
#include "wx/string.h" #include "wx/string.h"
@@ -32,17 +27,30 @@
#include <netdb.h> #include <netdb.h>
#include <signal.h> #include <signal.h>
#include <fcntl.h> // for O_WRONLY and friends #include <fcntl.h> // for O_WRONLY and friends
#include <time.h> // nanosleep() and/or usleep()
#include "glib.h" #include <glib.h>
#include "gdk/gdk.h" #include <gdk/gdk.h>
#include "gtk/gtk.h" #include <gtk/gtk.h>
#include "gtk/gtkfeatures.h" #include <gtk/gtkfeatures.h>
#include "gdk/gdkx.h" #include <gdk/gdkx.h>
#ifdef __SVR4__ #ifdef __SVR4__
#include <sys/systeminfo.h> #include <sys/systeminfo.h>
#endif #endif
// many versions of Unices have this function, but it is not defined in system
// headers - please add your system here if it is the case for your OS.
// SunOS < 5.6 (i.e. Solaris < 2.6) and DG-UX are like this.
#if (defined(__SUN__) && !defined(__SunOs_5_6) && \
!defined(__SunOs_5_7) && !defined(__SUNPRO_CC)) || \
defined(__osf__)
extern "C"
{
void usleep(unsigned long usec);
};
#endif // Unices without usleep()
// many versions of Unices have this function, but it is not defined in system // many versions of Unices have this function, but it is not defined in system
// headers - please add your system here if it is the case for your OS. // headers - please add your system here if it is the case for your OS.
// SunOS (and Solaris) and DG-UX are like this. // SunOS (and Solaris) and DG-UX are like this.
@@ -78,6 +86,30 @@ void wxSleep(int nSecs)
sleep(nSecs); sleep(nSecs);
} }
void wxUsleep(unsigned long milliseconds)
{
#if defined(HAVE_NANOSLEEP)
timespec tmReq;
tmReq.tv_sec = milliseconds / 1000;
tmReq.tv_nsec = (milliseconds % 1000) * 1000 * 1000;
// we're not interested in remaining time nor in return value
(void)nanosleep(&tmReq, (timespec *)NULL);
#elif defined(HAVE_USLEEP)
// uncomment this if you feel brave or if you are sure that your version
// of Solaris has a safe usleep() function but please notice that usleep()
// is known to lead to crashes in MT programs in Solaris 2.[67] and is not
// documented as MT-Safe
#if defined(__SUN__) && defined(wxUSE_THREADS)
#error "usleep() cannot be used in MT programs under Solaris."
#endif // Sun
usleep(milliseconds * 1000); // usleep(3) wants microseconds
#else // !sleep function
#error "usleep() or nanosleep() function required for wxUsleep"
#endif // sleep function
}
int wxKill(long pid, int sig) int wxKill(long pid, int sig)
{ {
return kill(pid, sig); return kill(pid, sig);

View File

@@ -8,7 +8,7 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ #ifdef __GNUG__
#pragma implementation "app.h" #pragma implementation "app.h"
#endif #endif
#include "wx/app.h" #include "wx/app.h"
@@ -20,35 +20,24 @@
#include "wx/font.h" #include "wx/font.h"
#include "wx/settings.h" #include "wx/settings.h"
#include "wx/dialog.h" #include "wx/dialog.h"
#if wxUSE_WX_RESOURCES #if wxUSE_WX_RESOURCES
#include "wx/resource.h" #include "wx/resource.h"
#endif #endif
#include "wx/module.h" #include "wx/module.h"
#include "wx/image.h" #include "wx/image.h"
#if wxUSE_THREADS
#include "wx/thread.h" #include "wx/thread.h"
#endif
#include "unistd.h" #include "unistd.h"
// many versions of Unices have this function, but it is not defined in system #include <glib.h>
// headers - please add your system here if it is the case for your OS. #include <gdk/gdk.h>
// SunOS < 5.6 (i.e. Solaris < 2.6) and DG-UX are like this. #include <gtk/gtk.h>
#if (defined(__SUN__) && !defined(__SunOs_5_6) && \
!defined(__SunOs_5_7) && !defined(__SUNPRO_CC)) || \
defined(__osf__)
extern "C"
{
void usleep(unsigned long usec);
};
#endif // Unices without usleep()
#include "glib.h"
#include "gdk/gdk.h"
#include "gtk/gtk.h"
#include "wx/gtk/win_gtk.h" #include "wx/gtk/win_gtk.h"
#include <unistd.h> // usleep() on solaris
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// global data // global data
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -160,14 +149,17 @@ END_EVENT_TABLE()
gint wxapp_idle_callback( gpointer WXUNUSED(data) ) gint wxapp_idle_callback( gpointer WXUNUSED(data) )
{ {
if (wxTheApp) while (wxTheApp->ProcessIdle()) {} if (wxTheApp)
#if wxUSE_THREADS {
while (wxTheApp->ProcessIdle())
{
}
}
wxMutexGuiLeave(); wxMutexGuiLeave();
#endif wxUsleep(10);
usleep(10000);
#if wxUSE_THREADS
wxMutexGuiEnter(); wxMutexGuiEnter();
#endif
return TRUE; return TRUE;
} }

View File

@@ -410,9 +410,7 @@ void wxThread::Yield()
void wxThread::Sleep(unsigned long milliseconds) void wxThread::Sleep(unsigned long milliseconds)
{ {
// FIXME how to test for nanosleep() availability? wxUsleep(milliseconds);
usleep(milliseconds * 1000); // usleep(3) wants microseconds
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------

View File

@@ -7,11 +7,6 @@
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
//#ifdef __GNUG__
//#pragma implementation "utils.h"
//#endif
#include "wx/utils.h" #include "wx/utils.h"
#include "wx/string.h" #include "wx/string.h"
@@ -32,17 +27,30 @@
#include <netdb.h> #include <netdb.h>
#include <signal.h> #include <signal.h>
#include <fcntl.h> // for O_WRONLY and friends #include <fcntl.h> // for O_WRONLY and friends
#include <time.h> // nanosleep() and/or usleep()
#include "glib.h" #include <glib.h>
#include "gdk/gdk.h" #include <gdk/gdk.h>
#include "gtk/gtk.h" #include <gtk/gtk.h>
#include "gtk/gtkfeatures.h" #include <gtk/gtkfeatures.h>
#include "gdk/gdkx.h" #include <gdk/gdkx.h>
#ifdef __SVR4__ #ifdef __SVR4__
#include <sys/systeminfo.h> #include <sys/systeminfo.h>
#endif #endif
// many versions of Unices have this function, but it is not defined in system
// headers - please add your system here if it is the case for your OS.
// SunOS < 5.6 (i.e. Solaris < 2.6) and DG-UX are like this.
#if (defined(__SUN__) && !defined(__SunOs_5_6) && \
!defined(__SunOs_5_7) && !defined(__SUNPRO_CC)) || \
defined(__osf__)
extern "C"
{
void usleep(unsigned long usec);
};
#endif // Unices without usleep()
// many versions of Unices have this function, but it is not defined in system // many versions of Unices have this function, but it is not defined in system
// headers - please add your system here if it is the case for your OS. // headers - please add your system here if it is the case for your OS.
// SunOS (and Solaris) and DG-UX are like this. // SunOS (and Solaris) and DG-UX are like this.
@@ -78,6 +86,30 @@ void wxSleep(int nSecs)
sleep(nSecs); sleep(nSecs);
} }
void wxUsleep(unsigned long milliseconds)
{
#if defined(HAVE_NANOSLEEP)
timespec tmReq;
tmReq.tv_sec = milliseconds / 1000;
tmReq.tv_nsec = (milliseconds % 1000) * 1000 * 1000;
// we're not interested in remaining time nor in return value
(void)nanosleep(&tmReq, (timespec *)NULL);
#elif defined(HAVE_USLEEP)
// uncomment this if you feel brave or if you are sure that your version
// of Solaris has a safe usleep() function but please notice that usleep()
// is known to lead to crashes in MT programs in Solaris 2.[67] and is not
// documented as MT-Safe
#if defined(__SUN__) && defined(wxUSE_THREADS)
#error "usleep() cannot be used in MT programs under Solaris."
#endif // Sun
usleep(milliseconds * 1000); // usleep(3) wants microseconds
#else // !sleep function
#error "usleep() or nanosleep() function required for wxUsleep"
#endif // sleep function
}
int wxKill(long pid, int sig) int wxKill(long pid, int sig)
{ {
return kill(pid, sig); return kill(pid, sig);

View File

@@ -6,7 +6,7 @@
// Created: 17/09/98 // Created: 17/09/98
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) Julian Smart // Copyright: (c) Julian Smart
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ #ifdef __GNUG__
@@ -70,19 +70,19 @@ bool wxApp::Initialize()
#else #else
wxBuffer = new char[BUFSIZ + 512]; wxBuffer = new char[BUFSIZ + 512];
#endif #endif
wxClassInfo::InitializeClasses(); wxClassInfo::InitializeClasses();
wxTheColourDatabase = new wxColourDatabase(wxKEY_STRING); wxTheColourDatabase = new wxColourDatabase(wxKEY_STRING);
wxTheColourDatabase->Initialize(); wxTheColourDatabase->Initialize();
wxInitializeStockLists(); wxInitializeStockLists();
wxInitializeStockObjects(); wxInitializeStockObjects();
#if wxUSE_WX_RESOURCES #if wxUSE_WX_RESOURCES
wxInitializeResourceSystem(); wxInitializeResourceSystem();
#endif #endif
// For PostScript printing // For PostScript printing
#if wxUSE_POSTSCRIPT #if wxUSE_POSTSCRIPT
/* Done using wxModule now /* Done using wxModule now
@@ -91,14 +91,14 @@ bool wxApp::Initialize()
wxThePrintPaperDatabase->CreateDatabase(); wxThePrintPaperDatabase->CreateDatabase();
*/ */
#endif #endif
wxBitmap::InitStandardHandlers(); wxBitmap::InitStandardHandlers();
wxWidgetHashTable = new wxHashTable(wxKEY_INTEGER); wxWidgetHashTable = new wxHashTable(wxKEY_INTEGER);
wxModule::RegisterModules(); wxModule::RegisterModules();
if (!wxModule::InitializeModules()) return FALSE; if (!wxModule::InitializeModules()) return FALSE;
return TRUE; return TRUE;
} }
@@ -106,32 +106,32 @@ void wxApp::CleanUp()
{ {
delete wxWidgetHashTable; delete wxWidgetHashTable;
wxWidgetHashTable = NULL; wxWidgetHashTable = NULL;
wxModule::CleanUpModules(); wxModule::CleanUpModules();
#if wxUSE_WX_RESOURCES #if wxUSE_WX_RESOURCES
wxCleanUpResourceSystem(); wxCleanUpResourceSystem();
#endif #endif
wxDeleteStockObjects() ; wxDeleteStockObjects() ;
// Destroy all GDI lists, etc. // Destroy all GDI lists, etc.
delete wxTheBrushList; delete wxTheBrushList;
wxTheBrushList = NULL; wxTheBrushList = NULL;
delete wxThePenList; delete wxThePenList;
wxThePenList = NULL; wxThePenList = NULL;
delete wxTheFontList; delete wxTheFontList;
wxTheFontList = NULL; wxTheFontList = NULL;
delete wxTheBitmapList; delete wxTheBitmapList;
wxTheBitmapList = NULL; wxTheBitmapList = NULL;
delete wxTheColourDatabase; delete wxTheColourDatabase;
wxTheColourDatabase = NULL; wxTheColourDatabase = NULL;
#if wxUSE_POSTSCRIPT #if wxUSE_POSTSCRIPT
/* Done using wxModule now /* Done using wxModule now
wxInitializePrintSetupData(FALSE); wxInitializePrintSetupData(FALSE);
@@ -139,17 +139,17 @@ void wxApp::CleanUp()
wxThePrintPaperDatabase = NULL; wxThePrintPaperDatabase = NULL;
*/ */
#endif #endif
wxBitmap::CleanUpHandlers(); wxBitmap::CleanUpHandlers();
delete[] wxBuffer; delete[] wxBuffer;
wxBuffer = NULL; wxBuffer = NULL;
wxClassInfo::CleanUpClasses(); wxClassInfo::CleanUpClasses();
delete wxTheApp; delete wxTheApp;
wxTheApp = NULL; wxTheApp = NULL;
#if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT #if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT
// At this point we want to check if there are any memory // At this point we want to check if there are any memory
// blocks that aren't part of the wxDebugContext itself, // blocks that aren't part of the wxDebugContext itself,
@@ -162,7 +162,7 @@ void wxApp::CleanUp()
wxDebugContext::PrintStatistics(); wxDebugContext::PrintStatistics();
} }
#endif #endif
// do it as the very last thing because everything else can log messages // do it as the very last thing because everything else can log messages
wxLog::DontCreateOnDemand(); wxLog::DontCreateOnDemand();
// do it as the very last thing because everything else can log messages // do it as the very last thing because everything else can log messages
@@ -180,10 +180,10 @@ int wxEntry( int argc, char *argv[] )
// checked, but this is a reasonable compromise. // checked, but this is a reasonable compromise.
wxDebugContext::SetCheckpoint(); wxDebugContext::SetCheckpoint();
#endif #endif
if (!wxApp::Initialize()) if (!wxApp::Initialize())
return FALSE; return FALSE;
if (!wxTheApp) if (!wxTheApp)
{ {
if (!wxApp::GetInitializerFunction()) if (!wxApp::GetInitializerFunction())
@@ -191,55 +191,55 @@ int wxEntry( int argc, char *argv[] )
printf( "wxWindows error: No initializer - use IMPLEMENT_APP macro.\n" ); printf( "wxWindows error: No initializer - use IMPLEMENT_APP macro.\n" );
return 0; return 0;
}; };
wxTheApp = (wxApp*) (* wxApp::GetInitializerFunction()) (); wxTheApp = (wxApp*) (* wxApp::GetInitializerFunction()) ();
}; };
if (!wxTheApp) if (!wxTheApp)
{ {
printf( "wxWindows error: wxTheApp == NULL\n" ); printf( "wxWindows error: wxTheApp == NULL\n" );
return 0; return 0;
}; };
wxTheApp->SetClassName(wxFileNameFromPath(argv[0])); wxTheApp->SetClassName(wxFileNameFromPath(argv[0]));
wxTheApp->SetAppName(wxFileNameFromPath(argv[0])); wxTheApp->SetAppName(wxFileNameFromPath(argv[0]));
wxTheApp->argc = argc; wxTheApp->argc = argc;
wxTheApp->argv = argv; wxTheApp->argv = argv;
// GUI-specific initialization, such as creating an app context. // GUI-specific initialization, such as creating an app context.
wxTheApp->OnInitGui(); wxTheApp->OnInitGui();
// Here frames insert themselves automatically // Here frames insert themselves automatically
// into wxTopLevelWindows by getting created // into wxTopLevelWindows by getting created
// in OnInit(). // in OnInit().
int retValue = 0; int retValue = 0;
if (wxTheApp->OnInit()) if (wxTheApp->OnInit())
{ {
if (wxTheApp->Initialized()) retValue = wxTheApp->OnRun(); if (wxTheApp->Initialized()) retValue = wxTheApp->OnRun();
} }
// flush the logged messages if any // flush the logged messages if any
wxLog *pLog = wxLog::GetActiveTarget(); wxLog *pLog = wxLog::GetActiveTarget();
if ( pLog != NULL && pLog->HasPendingMessages() ) if ( pLog != NULL && pLog->HasPendingMessages() )
pLog->Flush(); pLog->Flush();
delete wxLog::SetActiveTarget(new wxLogStderr); // So dialog boxes aren't used delete wxLog::SetActiveTarget(new wxLogStderr); // So dialog boxes aren't used
// for further messages // for further messages
if (wxTheApp->GetTopWindow()) if (wxTheApp->GetTopWindow())
{ {
delete wxTheApp->GetTopWindow(); delete wxTheApp->GetTopWindow();
wxTheApp->SetTopWindow(NULL); wxTheApp->SetTopWindow(NULL);
} }
wxTheApp->DeletePendingObjects(); wxTheApp->DeletePendingObjects();
wxTheApp->OnExit(); wxTheApp->OnExit();
wxApp::CleanUp(); wxApp::CleanUp();
return retValue; return retValue;
}; };
@@ -258,7 +258,7 @@ wxApp::wxApp()
m_printMode = wxPRINT_POSTSCRIPT; m_printMode = wxPRINT_POSTSCRIPT;
m_exitOnFrameDelete = TRUE; m_exitOnFrameDelete = TRUE;
m_auto3D = TRUE; m_auto3D = TRUE;
m_mainColormap = (WXColormap) NULL; m_mainColormap = (WXColormap) NULL;
m_appContext = (WXAppContext) NULL; m_appContext = (WXAppContext) NULL;
m_topLevelWidget = (WXWidget) NULL; m_topLevelWidget = (WXWidget) NULL;
@@ -277,42 +277,41 @@ bool wxApp::Initialized()
int wxApp::MainLoop() int wxApp::MainLoop()
{ {
m_keepGoing = TRUE; m_keepGoing = TRUE;
/* /*
* Sit around forever waiting to process X-events. Property Change * Sit around forever waiting to process X-events. Property Change
* event are handled special, because they have to refer to * event are handled special, because they have to refer to
* the root window rather than to a widget. therefore we can't * the root window rather than to a widget. therefore we can't
* use an Xt-eventhandler. * use an Xt-eventhandler.
*/ */
XSelectInput(XtDisplay((Widget) wxTheApp->GetTopLevelWidget()), XSelectInput(XtDisplay((Widget) wxTheApp->GetTopLevelWidget()),
XDefaultRootWindow(XtDisplay((Widget) wxTheApp->GetTopLevelWidget())), XDefaultRootWindow(XtDisplay((Widget) wxTheApp->GetTopLevelWidget())),
PropertyChangeMask); PropertyChangeMask);
XEvent event; XEvent event;
// Use this flag to allow breaking the loop via wxApp::ExitMainLoop() // Use this flag to allow breaking the loop via wxApp::ExitMainLoop()
while (m_keepGoing) while (m_keepGoing)
{ {
XtAppNextEvent( (XtAppContext) wxTheApp->GetAppContext(), &event); XtAppNextEvent( (XtAppContext) wxTheApp->GetAppContext(), &event);
ProcessXEvent((WXEvent*) & event); ProcessXEvent((WXEvent*) & event);
if (XtAppPending( (XtAppContext) wxTheApp->GetAppContext() ) == 0) if (XtAppPending( (XtAppContext) wxTheApp->GetAppContext() ) == 0)
{ {
if (!ProcessIdle()) if (!ProcessIdle())
{ {
// TODO: Robert, what's this for? // leave the main loop to give other threads a chance to
#if wxUSE_THREADS // perform their GUI work
wxMutexGuiLeave(); wxMutexGuiLeave();
usleep(20); wxUsleep(20);
wxMutexGuiEnter(); wxMutexGuiEnter();
#endif
} }
} }
} }
return 0; return 0;
} }
@@ -320,7 +319,7 @@ int wxApp::MainLoop()
void wxApp::ProcessXEvent(WXEvent* _event) void wxApp::ProcessXEvent(WXEvent* _event)
{ {
XEvent* event = (XEvent*) _event; XEvent* event = (XEvent*) _event;
if ((event->type == KeyPress) && CheckForAccelerator(_event)) if ((event->type == KeyPress) && CheckForAccelerator(_event))
{ {
// Do nothing! We intercepted and processed the event as an accelerator. // Do nothing! We intercepted and processed the event as an accelerator.
@@ -337,18 +336,18 @@ void wxApp::ProcessXEvent(WXEvent* _event)
* If resize event, don't resize until the last resize event for this * If resize event, don't resize until the last resize event for this
* window is recieved. Prevents flicker as windows are resized. * window is recieved. Prevents flicker as windows are resized.
*/ */
Display *disp = XtDisplay((Widget) wxTheApp->GetTopLevelWidget()); Display *disp = XtDisplay((Widget) wxTheApp->GetTopLevelWidget());
Window win = event->xany.window; Window win = event->xany.window;
XEvent report; XEvent report;
// to avoid flicker // to avoid flicker
report = * event; report = * event;
while( XCheckTypedWindowEvent (disp, win, ResizeRequest, &report)); while( XCheckTypedWindowEvent (disp, win, ResizeRequest, &report));
// TODO: when implementing refresh optimization, we can use // TODO: when implementing refresh optimization, we can use
// XtAddExposureToRegion to expand the window's paint region. // XtAddExposureToRegion to expand the window's paint region.
XtDispatchEvent(event); XtDispatchEvent(event);
} }
else else
@@ -363,7 +362,7 @@ bool wxApp::ProcessIdle()
wxIdleEvent event; wxIdleEvent event;
event.SetEventObject(this); event.SetEventObject(this);
ProcessEvent(event); ProcessEvent(event);
return event.MoreRequested(); return event.MoreRequested();
} }
@@ -376,7 +375,7 @@ void wxApp::ExitMainLoop()
bool wxApp::Pending() bool wxApp::Pending()
{ {
XFlush(XtDisplay( (Widget) wxTheApp->GetTopLevelWidget() )); XFlush(XtDisplay( (Widget) wxTheApp->GetTopLevelWidget() ));
// Fix by Doug from STI, to prevent a stall if non-X event // Fix by Doug from STI, to prevent a stall if non-X event
// is found. // is found.
return ((XtAppPending( (XtAppContext) GetAppContext() ) & XtIMXEvent) != 0) ; return ((XtAppPending( (XtAppContext) GetAppContext() ) & XtIMXEvent) != 0) ;
@@ -386,7 +385,7 @@ bool wxApp::Pending()
void wxApp::Dispatch() void wxApp::Dispatch()
{ {
// XtAppProcessEvent( (XtAppContext) wxTheApp->GetAppContext(), XtIMAll); // XtAppProcessEvent( (XtAppContext) wxTheApp->GetAppContext(), XtIMAll);
XEvent event; XEvent event;
XtAppNextEvent((XtAppContext) GetAppContext(), &event); XtAppNextEvent((XtAppContext) GetAppContext(), &event);
ProcessXEvent((WXEvent*) & event); ProcessXEvent((WXEvent*) & event);
@@ -403,27 +402,27 @@ void wxApp::HandlePropertyChange(WXEvent *event)
void wxApp::OnIdle(wxIdleEvent& event) void wxApp::OnIdle(wxIdleEvent& event)
{ {
static bool inOnIdle = FALSE; static bool inOnIdle = FALSE;
// Avoid recursion (via ProcessEvent default case) // Avoid recursion (via ProcessEvent default case)
if (inOnIdle) if (inOnIdle)
return; return;
inOnIdle = TRUE; inOnIdle = TRUE;
// 'Garbage' collection of windows deleted with Close(). // 'Garbage' collection of windows deleted with Close().
DeletePendingObjects(); DeletePendingObjects();
// flush the logged messages if any // flush the logged messages if any
wxLog *pLog = wxLog::GetActiveTarget(); wxLog *pLog = wxLog::GetActiveTarget();
if ( pLog != NULL && pLog->HasPendingMessages() ) if ( pLog != NULL && pLog->HasPendingMessages() )
pLog->Flush(); pLog->Flush();
// Send OnIdle events to all windows // Send OnIdle events to all windows
bool needMore = SendIdleEvents(); bool needMore = SendIdleEvents();
if (needMore) if (needMore)
event.RequestMore(TRUE); event.RequestMore(TRUE);
inOnIdle = FALSE; inOnIdle = FALSE;
} }
@@ -437,7 +436,7 @@ bool wxApp::SendIdleEvents()
wxWindow* win = (wxWindow*) node->Data(); wxWindow* win = (wxWindow*) node->Data();
if (SendIdleEvents(win)) if (SendIdleEvents(win))
needMore = TRUE; needMore = TRUE;
node = node->Next(); node = node->Next();
} }
return needMore; return needMore;
@@ -447,21 +446,21 @@ bool wxApp::SendIdleEvents()
bool wxApp::SendIdleEvents(wxWindow* win) bool wxApp::SendIdleEvents(wxWindow* win)
{ {
bool needMore = FALSE; bool needMore = FALSE;
wxIdleEvent event; wxIdleEvent event;
event.SetEventObject(win); event.SetEventObject(win);
win->ProcessEvent(event); win->ProcessEvent(event);
if (event.MoreRequested()) if (event.MoreRequested())
needMore = TRUE; needMore = TRUE;
wxNode* node = win->GetChildren().First(); wxNode* node = win->GetChildren().First();
while (node) while (node)
{ {
wxWindow* win = (wxWindow*) node->Data(); wxWindow* win = (wxWindow*) node->Data();
if (SendIdleEvents(win)) if (SendIdleEvents(win))
needMore = TRUE; needMore = TRUE;
node = node->Next(); node = node->Next();
} }
return needMore ; return needMore ;
@@ -473,12 +472,12 @@ void wxApp::DeletePendingObjects()
while (node) while (node)
{ {
wxObject *obj = (wxObject *)node->Data(); wxObject *obj = (wxObject *)node->Data();
delete obj; delete obj;
if (wxPendingDelete.Member(obj)) if (wxPendingDelete.Member(obj))
delete node; delete node;
// Deleting one object may have deleted other pending // Deleting one object may have deleted other pending
// objects, so start from beginning of list again. // objects, so start from beginning of list again.
node = wxPendingDelete.First(); node = wxPendingDelete.First();
@@ -517,20 +516,20 @@ bool wxApp::OnInitGui()
exit(-1); exit(-1);
} }
m_initialDisplay = (WXDisplay*) dpy; m_initialDisplay = (WXDisplay*) dpy;
wxTheApp->m_topLevelWidget = (WXWidget) XtAppCreateShell((String)NULL, (const char*) wxTheApp->GetClassName(), wxTheApp->m_topLevelWidget = (WXWidget) XtAppCreateShell((String)NULL, (const char*) wxTheApp->GetClassName(),
applicationShellWidgetClass,dpy, applicationShellWidgetClass,dpy,
NULL,0) ; NULL,0) ;
// Add general resize proc // Add general resize proc
XtActionsRec rec; XtActionsRec rec;
rec.string = "resize"; rec.string = "resize";
rec.proc = (XtActionProc)wxWidgetResizeProc; rec.proc = (XtActionProc)wxWidgetResizeProc;
XtAppAddActions((XtAppContext) wxTheApp->m_appContext, &rec, 1); XtAppAddActions((XtAppContext) wxTheApp->m_appContext, &rec, 1);
GetMainColormap(dpy); GetMainColormap(dpy);
m_maxRequestSize = XMaxRequestSize((Display*) dpy); m_maxRequestSize = XMaxRequestSize((Display*) dpy);
return TRUE; return TRUE;
} }
@@ -541,12 +540,12 @@ WXColormap wxApp::GetMainColormap(WXDisplay* display)
int defaultScreen = DefaultScreen((Display*) display); int defaultScreen = DefaultScreen((Display*) display);
Screen* screen = XScreenOfDisplay((Display*) display, defaultScreen); Screen* screen = XScreenOfDisplay((Display*) display, defaultScreen);
Colormap c = DefaultColormapOfScreen(screen); Colormap c = DefaultColormapOfScreen(screen);
if (!m_mainColormap) if (!m_mainColormap)
m_mainColormap = (WXColormap) c; m_mainColormap = (WXColormap) c;
return (WXColormap) c; return (WXColormap) c;
} }
@@ -560,17 +559,17 @@ bool wxApp::CheckForAccelerator(WXEvent* event)
// TODO: should get display for the window, not the current display // TODO: should get display for the window, not the current display
Widget widget = XtWindowToWidget((Display*) wxGetDisplay(), xEvent->xany.window); Widget widget = XtWindowToWidget((Display*) wxGetDisplay(), xEvent->xany.window);
wxWindow* win = NULL; wxWindow* win = NULL;
// Find the first wxWindow that corresponds to this event window // Find the first wxWindow that corresponds to this event window
while (widget && !(win = wxGetWindowFromTable(widget))) while (widget && !(win = wxGetWindowFromTable(widget)))
widget = XtParent(widget); widget = XtParent(widget);
if (!widget || !win) if (!widget || !win)
return FALSE; return FALSE;
wxKeyEvent keyEvent(wxEVT_CHAR); wxKeyEvent keyEvent(wxEVT_CHAR);
wxTranslateKeyEvent(keyEvent, win, (Widget) 0, xEvent); wxTranslateKeyEvent(keyEvent, win, (Widget) 0, xEvent);
// Now we have a wxKeyEvent and we have a wxWindow. // Now we have a wxKeyEvent and we have a wxWindow.
// Go up the hierarchy until we find a matching accelerator, // Go up the hierarchy until we find a matching accelerator,
// or we get to the top. // or we get to the top.
@@ -590,7 +589,7 @@ void wxExit()
int retValue = 0; int retValue = 0;
if (wxTheApp) if (wxTheApp)
retValue = wxTheApp->OnExit(); retValue = wxTheApp->OnExit();
wxApp::CleanUp(); wxApp::CleanUp();
/* /*
* Exit in some platform-specific way. Not recommended that the app calls this: * Exit in some platform-specific way. Not recommended that the app calls this:

View File

@@ -299,6 +299,11 @@ class wxSleepTimer: public wxTimer
static wxTimer *wxTheSleepTimer = NULL; static wxTimer *wxTheSleepTimer = NULL;
void wxUsleep(unsigned long milliseconds)
{
::Sleep(milliseconds);
}
void wxSleep(int nSecs) void wxSleep(int nSecs)
{ {
#if 0 // WIN32 hangs app #if 0 // WIN32 hangs app