X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/cf1eeea343cda634290bb95432f75802aa9d2783..a51fb6427c1036779a67b92ff0976c0a735ab0c3:/src/msw/utils.cpp diff --git a/src/msw/utils.cpp b/src/msw/utils.cpp index f5217d22f9..e035e05457 100644 --- a/src/msw/utils.cpp +++ b/src/msw/utils.cpp @@ -437,7 +437,7 @@ bool wxDirExists(const wxString& dir) { #if defined(__WIN32__) DWORD attribs = GetFileAttributes(dir); - return ((attribs != -1) && (attribs & FILE_ATTRIBUTE_DIRECTORY)); + return ((attribs != (DWORD)-1) && (attribs & FILE_ATTRIBUTE_DIRECTORY)); #else // Win16 #ifdef __BORLANDC__ struct ffblk fileInfo; @@ -990,10 +990,22 @@ void wxGetMousePosition( int* x, int* y ) // Return TRUE if we have a colour display bool wxColourDisplay() { - ScreenHDC dc; - int noCols = GetDeviceCaps(dc, NUMCOLORS); + // this function is called from wxDC ctor so it is called a *lot* of times + // hence we optimize it a bit but doign the check only once + // + // this should be MT safe as only the GUI thread (holding the GUI mutex) + // can call us + static int s_isColour = -1; + + if ( s_isColour == -1 ) + { + ScreenHDC dc; + int noCols = ::GetDeviceCaps(dc, NUMCOLORS); + + s_isColour = (noCols == -1) || (noCols > 2); + } - return (noCols == -1) || (noCols > 2); + return s_isColour != 0; } // Returns depth of screen