summaryrefslogtreecommitdiff
path: root/qmake/tools/qglobal.cpp
Side-by-side diff
Diffstat (limited to 'qmake/tools/qglobal.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--qmake/tools/qglobal.cpp45
1 files changed, 39 insertions, 6 deletions
diff --git a/qmake/tools/qglobal.cpp b/qmake/tools/qglobal.cpp
index 47cd6bd..342005d 100644
--- a/qmake/tools/qglobal.cpp
+++ b/qmake/tools/qglobal.cpp
@@ -104,97 +104,118 @@ bool qSysInfo( int *wordSize, bool *bigEndian )
n /= 2;
}
*wordSize = si_wordSize;
if ( *wordSize != 64 &&
*wordSize != 32 &&
*wordSize != 16 ) { // word size: 16, 32 or 64
#if defined(QT_CHECK_RANGE)
qFatal( "qSysInfo: Unsupported system word size %d", *wordSize );
#endif
return FALSE;
}
if ( sizeof(Q_INT8) != 1 || sizeof(Q_INT16) != 2 || sizeof(Q_INT32) != 4 ||
sizeof(Q_ULONG)*8 != si_wordSize || sizeof(float) != 4 || sizeof(double) != 8 ) {
#if defined(QT_CHECK_RANGE)
qFatal( "qSysInfo: Unsupported system data type size" );
#endif
return FALSE;
}
bool be16, be32; // determine byte ordering
short ns = 0x1234;
int nl = 0x12345678;
unsigned char *p = (unsigned char *)(&ns); // 16-bit integer
be16 = *p == 0x12;
p = (unsigned char *)(&nl); // 32-bit integer
if ( p[0] == 0x12 && p[1] == 0x34 && p[2] == 0x56 && p[3] == 0x78 )
be32 = TRUE;
else
if ( p[0] == 0x78 && p[1] == 0x56 && p[2] == 0x34 && p[3] == 0x12 )
be32 = FALSE;
else
be32 = !be16;
if ( be16 != be32 ) { // strange machine!
#if defined(QT_CHECK_RANGE)
qFatal( "qSysInfo: Inconsistent system byte order" );
#endif
return FALSE;
}
*bigEndian = si_bigEndian = be32;
si_alreadyDone = TRUE;
return TRUE;
}
-#if defined(Q_OS_WIN32) || defined(Q_OS_CYGWIN)
+#if !defined(QWS) && defined(Q_OS_MAC)
+
+#include "qt_mac.h"
+
+int qMacVersion()
+{
+ static int macver = Qt::MV_Unknown;
+ static bool first = TRUE;
+ if(first) {
+ first = FALSE;
+ long gestalt_version;
+ if(Gestalt(gestaltSystemVersion, &gestalt_version) == noErr) {
+ if(gestalt_version >= 0x1020 && gestalt_version < 0x1030)
+ macver = Qt::MV_10_DOT_2;
+ else if(gestalt_version >= 0x1010 && gestalt_version < 0x1020)
+ macver = Qt::MV_10_DOT_1;
+ }
+ }
+ return macver;
+}
+Qt::MacintoshVersion qt_macver = (Qt::MacintoshVersion)qMacVersion();
+#elif defined(Q_OS_WIN32) || defined(Q_OS_CYGWIN)
bool qt_winunicode;
#include "qt_windows.h"
int qWinVersion()
{
#ifndef VER_PLATFORM_WIN32s
#define VER_PLATFORM_WIN32s 0
#endif
#ifndef VER_PLATFORM_WIN32_WINDOWS
#define VER_PLATFORM_WIN32_WINDOWS 1
#endif
#ifndef VER_PLATFORM_WIN32_NT
#define VER_PLATFORM_WIN32_NT 2
#endif
static int winver = Qt::WV_NT;
static int t=0;
if ( !t ) {
t=1;
#ifdef Q_OS_TEMP
OSVERSIONINFOW osver;
osver.dwOSVersionInfoSize = sizeof(osver);
GetVersionEx( &osver );
#else
OSVERSIONINFOA osver;
osver.dwOSVersionInfoSize = sizeof(osver);
GetVersionExA( &osver );
#endif
switch ( osver.dwPlatformId ) {
case VER_PLATFORM_WIN32s:
winver = Qt::WV_32s;
break;
case VER_PLATFORM_WIN32_WINDOWS:
// We treat Windows Me (minor 90) the same as Windows 98
if ( ( osver.dwMinorVersion == 10 ) || ( osver.dwMinorVersion == 90 ) )
winver = Qt::WV_98;
else
winver = Qt::WV_95;
break;
default: // VER_PLATFORM_WIN32_NT
if ( osver.dwMajorVersion < 5 ) {
winver = Qt::WV_NT;
} else if ( osver.dwMinorVersion == 0 ) {
winver = Qt::WV_2000;
} else {
winver = Qt::WV_XP;
}
@@ -276,113 +297,125 @@ Qt::WindowsVersion qt_winver = (Qt::WindowsVersion)qWinVersion();
\warning Passing (const char *)0 as argument to qWarning might lead
to crashes on certain platforms due to the platforms printf implementation.
\sa qDebug(), qFatal(), qInstallMsgHandler(),
\link debug.html Debugging\endlink
*/
/*!
\fn void qFatal( const char *msg, ... )
\relates QApplication
Prints a fatal error message \a msg and exits, or calls the
message handler (if it has been installed).
This function takes a format string and a list of arguments,
similar to the C printf() function.
Example:
\code
int divide( int a, int b )
{
if ( b == 0 ) // program error
qFatal( "divide: cannot divide by zero" );
return a/b;
}
\endcode
Under X11, the text is printed to stderr. Under Windows, the text
is sent to the debugger.
\warning The internal buffer is limited to 8196 bytes (including
the '\0'-terminator).
\warning Passing (const char *)0 as argument to qFatal might lead
to crashes on certain platforms due to the platforms printf implementation.
\sa qDebug(), qWarning(), qInstallMsgHandler(),
\link debug.html Debugging\endlink
*/
static QtMsgHandler handler = 0; // pointer to debug handler
static const int QT_BUFFER_LENGTH = 8196; // internal buffer length
#ifdef Q_OS_MAC
-const unsigned char * p_str(const char * c, int len=-1)
+QString cfstring2qstring(CFStringRef str)
+{
+ CFIndex length = CFStringGetLength(str);
+ if(const UniChar *chars = CFStringGetCharactersPtr(str))
+ return QString((QChar *)chars, length);
+ UniChar *buffer = (UniChar*)malloc(length * sizeof(UniChar));
+ CFStringGetCharacters(str, CFRangeMake(0, length), buffer);
+ QString ret((QChar *)buffer, length);
+ free(buffer);
+ return ret;
+}
+
+unsigned char * p_str(const char * c, int len=-1)
{
const int maxlen = 255;
if(len == -1)
len = qstrlen(c);
if(len > maxlen) {
qWarning( "p_str len must never exceed %d", maxlen );
len = maxlen;
}
unsigned char *ret = (unsigned char*)malloc(len+2);
*ret=len;
memcpy(((char *)ret)+1,c,len);
*(ret+len+1) = '\0';
return ret;
}
-const unsigned char * p_str(const QString &s)
+unsigned char * p_str(const QString &s)
{
return p_str(s, s.length());
}
QCString p2qstring(const unsigned char *c) {
char *arr = (char *)malloc(c[0] + 1);
memcpy(arr, c+1, c[0]);
arr[c[0]] = '\0';
QCString ret = arr;
delete arr;
return ret;
}
#endif
#ifdef Q_CC_MWERKS
#include "qt_mac.h"
extern bool qt_is_gui_used;
static void mac_default_handler( const char *msg )
{
if ( qt_is_gui_used ) {
const char *p = p_str(msg);
DebugStr(p);
free(p);
} else {
fprintf( stderr, msg );
}
}
#endif
void qDebug( const char *msg, ... )
{
char buf[QT_BUFFER_LENGTH];
va_list ap;
va_start( ap, msg ); // use variable arg list
if ( handler ) {
#if defined(QT_VSNPRINTF)
QT_VSNPRINTF( buf, QT_BUFFER_LENGTH, msg, ap );
#else
vsprintf( buf, msg, ap );
#endif
va_end( ap );
(*handler)( QtDebugMsg, buf );
} else {
@@ -596,108 +629,108 @@ void qSystemWarning( const char* msg, int code )
else
qWarning( msg );
#endif
#endif
}
/*!
\fn void Q_ASSERT( bool test )
\relates QApplication
Prints a warning message containing the source code file name and
line number if \a test is FALSE.
This is really a macro defined in \c qglobal.h.
Q_ASSERT is useful for testing pre- and post-conditions.
Example:
\code
//
// File: div.cpp
//
#include <qglobal.h>
int divide( int a, int b )
{
Q_ASSERT( b != 0 ); // this is line 9
return a/b;
}
\endcode
If \c b is zero, the Q_ASSERT statement will output the following
message using the qWarning() function:
\code
ASSERT: "b == 0" in div.cpp (9)
\endcode
\sa qWarning(), \link debug.html Debugging\endlink
*/
/*!
\fn void Q_CHECK_PTR( void *p )
\relates QApplication
- If \a p is null, a fatal messages says that the program ran out of
- memory and exits. If \e p is not null, nothing happens.
+ If \a p is 0, a fatal messages says that the program ran out of
+ memory and exits. If \e p is not 0, nothing happens.
This is really a macro defined in \c qglobal.h.
Example:
\code
int *a;
Q_CHECK_PTR( a = new int[80] ); // WRONG!
- a = new int[80]; // Right
+ a = new (nothrow) int[80]; // Right
Q_CHECK_PTR( a );
\endcode
\sa qFatal(), \link debug.html Debugging\endlink
*/
//
// The Q_CHECK_PTR macro calls this function to check if an allocation went ok.
//
#if (QT_VERSION-0 >= 0x040000)
#if defined(Q_CC_GNU)
#warning "Change Q_CHECK_PTR to '{if ((p)==0) qt_check_pointer(__FILE__,__LINE__);}'"
#warning "No need for qt_check_pointer() to return a value - make it void!"
#endif
#endif
bool qt_check_pointer( bool c, const char *n, int l )
{
if ( c )
qWarning( "In file %s, line %d: Out of memory", n, l );
return TRUE;
}
static bool firstObsoleteWarning(const char *obj, const char *oldfunc )
{
static QAsciiDict<int> *obsoleteDict = 0;
if ( !obsoleteDict ) { // first time func is called
obsoleteDict = new QAsciiDict<int>;
#if defined(QT_DEBUG)
qDebug(
"You are using obsolete functions in the Qt library. Call the function\n"
"qSuppressObsoleteWarnings() to suppress obsolete warnings.\n"
);
#endif
}
QCString s( obj );
s += "::";
s += oldfunc;
if ( obsoleteDict->find(s.data()) == 0 ) {
obsoleteDict->insert( s.data(), (int*)1 ); // anything different from 0
return TRUE;
}
return FALSE;
}
static bool suppressObsolete = FALSE;