Qt 4.8
qglobal.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtCore module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #include "qplatformdefs.h"
43 #include "qstring.h"
44 #include "qvector.h"
45 #include "qlist.h"
46 #include "qthreadstorage.h"
47 #include "qdir.h"
48 #include "qstringlist.h"
49 #include "qdatetime.h"
50 
51 #ifndef QT_NO_QOBJECT
52 #include <private/qthread_p.h>
53 #endif
54 
55 #include <stdio.h>
56 #include <stdlib.h>
57 #include <limits.h>
58 #include <stdarg.h>
59 #include <string.h>
60 
61 #ifndef QT_NO_EXCEPTIONS
62 # include <string>
63 # include <exception>
64 #endif
65 
66 #if !defined(Q_OS_WINCE)
67 # include <errno.h>
68 # if defined(Q_CC_MSVC)
69 # include <crtdbg.h>
70 # endif
71 #endif
72 
73 #if defined(Q_OS_VXWORKS) && defined(_WRS_KERNEL)
74 # include <envLib.h>
75 #endif
76 
77 #if defined(Q_OS_MACX) && !defined(Q_OS_IOS)
78 #include <CoreServices/CoreServices.h>
79 #endif
80 
81 #ifdef QT_USE_SLOG2
82 #include <slog2.h>
83 #endif
84 
85 
86 #if defined(Q_OS_SYMBIAN)
87 #include <e32def.h>
88 #include <e32debug.h>
89 #include <f32file.h>
90 #include <e32math.h>
91 # include "private/qcore_symbian_p.h"
92 
93 _LIT(qt_S60Filter, "Series60v?.*.sis");
94 _LIT(qt_symbianSystemInstallDir, "z:\\system\\install\\");
95 #endif
96 
98 
99 
1223 const char *qVersion()
1224 {
1225  return QT_VERSION_STR;
1226 }
1227 
1229 {
1230 #ifdef QT_SHARED
1231  return true;
1232 #else
1233  return false;
1234 #endif
1235 }
1236 
1237 /*****************************************************************************
1238  System detection routines
1239  *****************************************************************************/
1240 
2064 #if defined(QT_BUILD_QMAKE)
2065 // needed to bootstrap qmake
2066 static const unsigned int qt_one = 1;
2067 const int QSysInfo::ByteOrder = ((*((unsigned char *) &qt_one) == 0) ? BigEndian : LittleEndian);
2068 #endif
2069 
2070 #if !defined(QWS) && defined(Q_OS_MAC)
2071 
2073 #include "private/qcore_mac_p.h"
2074 #include "qnamespace.h"
2076 
2078 {
2079 #if !defined(Q_OS_IOS)
2080  SInt32 gestalt_version;
2081  if (Gestalt(gestaltSystemVersion, &gestalt_version) == noErr) {
2082  return QSysInfo::MacVersion(((gestalt_version & 0x00F0) >> 4) + 2);
2083  }
2084 #endif
2085  return QSysInfo::MV_Unknown;
2086 }
2088 
2089 #elif defined(Q_OS_WIN32) || defined(Q_OS_CYGWIN) || defined(Q_OS_WINCE)
2090 
2092 #include "qt_windows.h"
2094 
2095 static inline OSVERSIONINFO winOsVersion()
2096 {
2097  OSVERSIONINFO result = { sizeof(OSVERSIONINFO), 0, 0, 0, 0, {'\0'}};
2098  // GetVersionEx() has been deprecated in Windows 8.1 and will return
2099  // only Windows 8 from that version on.
2100 # if defined(_MSC_VER) && _MSC_VER >= 1800
2101 # pragma warning( push )
2102 # pragma warning( disable : 4996 )
2103 # endif
2104  GetVersionEx(&result);
2105 # if defined(_MSC_VER) && _MSC_VER >= 1800
2106 # pragma warning( pop )
2107 # endif
2108 # ifndef Q_OS_WINCE
2109  if (result.dwMajorVersion == 6 && result.dwMinorVersion == 2) {
2110  // This could be Windows 8.1 or higher. Note that as of Windows 9,
2111  // the major version needs to be checked as well.
2112  DWORDLONG conditionMask = 0;
2113  VER_SET_CONDITION(conditionMask, VER_MAJORVERSION, VER_GREATER_EQUAL);
2114  VER_SET_CONDITION(conditionMask, VER_MINORVERSION, VER_GREATER_EQUAL);
2115  VER_SET_CONDITION(conditionMask, VER_PLATFORMID, VER_EQUAL);
2116  OSVERSIONINFOEX checkVersion = { sizeof(OSVERSIONINFOEX), result.dwMajorVersion, result.dwMinorVersion,
2117  result.dwBuildNumber, result.dwPlatformId, {'\0'}, 0, 0, 0, 0, 0 };
2118  for ( ; VerifyVersionInfo(&checkVersion, VER_MAJORVERSION | VER_MINORVERSION | VER_PLATFORMID, conditionMask); ++checkVersion.dwMinorVersion)
2119  result.dwMinorVersion = checkVersion.dwMinorVersion;
2120  }
2121 # endif // !Q_OS_WINCE
2122  return result;
2123 }
2124 
2126 {
2127 #ifndef VER_PLATFORM_WIN32s
2128 #define VER_PLATFORM_WIN32s 0
2129 #endif
2130 #ifndef VER_PLATFORM_WIN32_WINDOWS
2131 #define VER_PLATFORM_WIN32_WINDOWS 1
2132 #endif
2133 #ifndef VER_PLATFORM_WIN32_NT
2134 #define VER_PLATFORM_WIN32_NT 2
2135 #endif
2136 #ifndef VER_PLATFORM_WIN32_CE
2137 #define VER_PLATFORM_WIN32_CE 3
2138 #endif
2139 
2140  static QSysInfo::WinVersion winver;
2141  if (winver)
2142  return winver;
2143  winver = QSysInfo::WV_NT;
2144  const OSVERSIONINFO osver = winOsVersion();
2145 #ifdef Q_OS_WINCE
2146  DWORD qt_cever = 0;
2147  qt_cever = osver.dwMajorVersion * 100;
2148  qt_cever += osver.dwMinorVersion * 10;
2149 #endif
2150  switch (osver.dwPlatformId) {
2151  case VER_PLATFORM_WIN32s:
2152  winver = QSysInfo::WV_32s;
2153  break;
2154  case VER_PLATFORM_WIN32_WINDOWS:
2155  // We treat Windows Me (minor 90) the same as Windows 98
2156  if (osver.dwMinorVersion == 90)
2157  winver = QSysInfo::WV_Me;
2158  else if (osver.dwMinorVersion == 10)
2159  winver = QSysInfo::WV_98;
2160  else
2161  winver = QSysInfo::WV_95;
2162  break;
2163 #ifdef Q_OS_WINCE
2164  case VER_PLATFORM_WIN32_CE:
2165  if (qt_cever >= 600)
2166  winver = QSysInfo::WV_CE_6;
2167  if (qt_cever >= 500)
2168  winver = QSysInfo::WV_CE_5;
2169  else if (qt_cever >= 400)
2170  winver = QSysInfo::WV_CENET;
2171  else
2172  winver = QSysInfo::WV_CE;
2173  break;
2174 #endif
2175  default: // VER_PLATFORM_WIN32_NT
2176  if (osver.dwMajorVersion < 5) {
2177  winver = QSysInfo::WV_NT;
2178  } else if (osver.dwMajorVersion == 5 && osver.dwMinorVersion == 0) {
2179  winver = QSysInfo::WV_2000;
2180  } else if (osver.dwMajorVersion == 5 && osver.dwMinorVersion == 1) {
2181  winver = QSysInfo::WV_XP;
2182  } else if (osver.dwMajorVersion == 5 && osver.dwMinorVersion == 2) {
2183  winver = QSysInfo::WV_2003;
2184  } else if (osver.dwMajorVersion == 6 && osver.dwMinorVersion == 0) {
2185  winver = QSysInfo::WV_VISTA;
2186  } else if (osver.dwMajorVersion == 6 && osver.dwMinorVersion == 1) {
2187  winver = QSysInfo::WV_WINDOWS7;
2188  } else if (osver.dwMajorVersion == 6 && osver.dwMinorVersion == 2) {
2189  winver = QSysInfo::WV_WINDOWS8;
2190  } else if (osver.dwMajorVersion == 6 && osver.dwMinorVersion == 3) {
2191  winver = QSysInfo::WV_WINDOWS8_1;
2192  } else {
2193  qWarning("Qt: Untested Windows version %d.%d detected!",
2194  int(osver.dwMajorVersion), int(osver.dwMinorVersion));
2195  winver = QSysInfo::WV_NT_based;
2196  }
2197  }
2198 
2199 #ifdef QT_DEBUG
2200  {
2201  QByteArray override = qgetenv("QT_WINVER_OVERRIDE");
2202  if (override.isEmpty())
2203  return winver;
2204 
2205  if (override == "Me")
2206  winver = QSysInfo::WV_Me;
2207  if (override == "95")
2208  winver = QSysInfo::WV_95;
2209  else if (override == "98")
2210  winver = QSysInfo::WV_98;
2211  else if (override == "NT")
2212  winver = QSysInfo::WV_NT;
2213  else if (override == "2000")
2214  winver = QSysInfo::WV_2000;
2215  else if (override == "2003")
2216  winver = QSysInfo::WV_2003;
2217  else if (override == "XP")
2218  winver = QSysInfo::WV_XP;
2219  else if (override == "VISTA")
2220  winver = QSysInfo::WV_VISTA;
2221  else if (override == "WINDOWS7")
2222  winver = QSysInfo::WV_WINDOWS7;
2223  else if (override == "WINDOWS8")
2224  winver = QSysInfo::WV_WINDOWS8;
2225  }
2226 #endif
2227 
2228  return winver;
2229 }
2230 
2232 
2233 #endif
2234 
2235 #ifdef Q_OS_SYMBIAN
2236 static QSysInfo::SymbianVersion cachedSymbianVersion = QSysInfo::SymbianVersion(-1);
2237 static QSysInfo::S60Version cachedS60Version = QSysInfo::S60Version(-1);
2238 
2239 static void symbianInitVersions()
2240 {
2241  // Use pure Symbian code, because if done using QDir, there will be a call back
2242  // to this method, resulting doing this expensive operation twice before the cache kicks in.
2243  // Pure Symbian code also makes this method ~10x faster, speeding up the application launch.
2244  RFs rfs = qt_s60GetRFs();
2245  TFindFile fileFinder(rfs);
2246  CDir* contents;
2247 
2248  // Check for platform version
2249  TInt err = fileFinder.FindWildByDir(qt_S60Filter, qt_symbianSystemInstallDir, contents);
2250  if (err == KErrNone) {
2251  QScopedPointer<CDir> contentsDeleter(contents);
2252  err = contents->Sort(EDescending|ESortByName);
2253  if (err == KErrNone && contents->Count() > 0 && (*contents)[0].iName.Length() >= 12) {
2254  TInt major = (*contents)[0].iName[9] - '0';
2255  TInt minor = (*contents)[0].iName[11] - '0';
2256  if (major == 3) {
2257  if (minor == 1) {
2258  cachedS60Version = QSysInfo::SV_S60_3_1;
2259  cachedSymbianVersion = QSysInfo::SV_9_2;
2260  } else if (minor == 2) {
2261  cachedS60Version = QSysInfo::SV_S60_3_2;
2262  cachedSymbianVersion = QSysInfo::SV_9_3;
2263  }
2264  } else if (major == 5) {
2265  if (minor == 0) {
2266  cachedS60Version = QSysInfo::SV_S60_5_0;
2267  cachedSymbianVersion = QSysInfo::SV_9_4;
2268  } else if (minor == 1) {
2269  cachedS60Version = QSysInfo::SV_S60_5_1;
2270  cachedSymbianVersion = QSysInfo::SV_SF_2;
2271  } else if (minor == 2) {
2272  cachedS60Version = QSysInfo::SV_S60_5_2;
2273  cachedSymbianVersion = QSysInfo::SV_SF_3;
2274  } else if (minor == 3) {
2275  cachedS60Version = QSysInfo::SV_S60_5_3;
2276  cachedSymbianVersion = QSysInfo::SV_API_5_3;
2277  } else if (minor == 4) {
2278  cachedS60Version = QSysInfo::SV_S60_5_4;
2279  cachedSymbianVersion = QSysInfo::SV_API_5_4;
2280  } else if (minor >= 5) {
2281  cachedS60Version = QSysInfo::SV_S60_5_5;
2282  cachedSymbianVersion = QSysInfo::SV_API_5_5;
2283  }
2284  }
2285  }
2286  }
2287 
2288 # ifdef Q_CC_NOKIAX86
2289  if (cachedS60Version == -1) {
2290  // Some emulator environments may not contain the version specific .sis files, so
2291  // simply hardcode the version on those environments. Note that can't use
2292  // S60_VERSION_* defines for S60 3.x/5.0 platforms, as they do not define them
2293  // right anyway in case .sis files are not found.
2294 # if defined(__SERIES60_31__)
2295  cachedS60Version = QSysInfo::SV_S60_3_1;
2296  cachedSymbianVersion = QSysInfo::SV_9_2;
2297 # elif defined(__S60_32__)
2298  cachedS60Version = QSysInfo::SV_S60_3_2;
2299  cachedSymbianVersion = QSysInfo::SV_9_3;
2300 # elif defined(__S60_50__)
2301  cachedS60Version = QSysInfo::SV_S60_5_0;
2302  cachedSymbianVersion = QSysInfo::SV_9_4;
2303 # elif defined(S60_VERSION_5_2)
2304  cachedS60Version = QSysInfo::SV_S60_5_2;
2305  cachedSymbianVersion = QSysInfo::SV_SF_3;
2306 # elif defined(S60_VERSION_5_3)
2307  cachedS60Version = QSysInfo::SV_S60_5_3;
2308  cachedSymbianVersion = QSysInfo::SV_API_5_3;
2309 # elif defined(S60_VERSION_5_4)
2310  cachedS60Version = QSysInfo::SV_S60_5_4;
2311  cachedSymbianVersion = QSysInfo::SV_API_5_4;
2312 # elif defined(S60_VERSION_5_5)
2313  cachedS60Version = QSysInfo::SV_S60_5_5;
2314  cachedSymbianVersion = QSysInfo::SV_API_5_5;
2315 # endif
2316  }
2317 # endif
2318 
2319  if (cachedS60Version == -1) {
2320  //If reaching here, it was not possible to determine the version
2321  cachedS60Version = QSysInfo::SV_S60_Unknown;
2322  cachedSymbianVersion = QSysInfo::SV_Unknown;
2323  }
2324 }
2325 
2326 QSysInfo::SymbianVersion QSysInfo::symbianVersion()
2327 {
2328  if (cachedSymbianVersion == -1)
2329  symbianInitVersions();
2330 
2331  return cachedSymbianVersion;
2332 }
2333 
2334 QSysInfo::S60Version QSysInfo::s60Version()
2335 {
2336  if (cachedS60Version == -1)
2337  symbianInitVersions();
2338 
2339  return cachedS60Version;
2340 }
2341 #endif // ifdef Q_OS_SYMBIAN
2342 
2438 /*
2439  The Q_CHECK_PTR macro calls this function if an allocation check
2440  fails.
2441 */
2442 void qt_check_pointer(const char *n, int l)
2443 {
2444  qFatal("In file %s, line %d: Out of memory", n, l);
2445 }
2446 
2447 /* \internal
2448  Allows you to throw an exception without including <new>
2449  Called internally from Q_CHECK_PTR on certain OS combinations
2450 */
2452 {
2453  QT_THROW(std::bad_alloc());
2454 }
2455 
2456 /*
2457  The Q_ASSERT macro calls this function when the test fails.
2458 */
2459 void qt_assert(const char *assertion, const char *file, int line)
2460 {
2461  qFatal("ASSERT: \"%s\" in file %s, line %d", assertion, file, line);
2462 }
2463 
2464 /*
2465  The Q_ASSERT_X macro calls this function when the test fails.
2466 */
2467 void qt_assert_x(const char *where, const char *what, const char *file, int line)
2468 {
2469  qFatal("ASSERT failure in %s: \"%s\", file %s, line %d", where, what, file, line);
2470 }
2471 
2472 
2473 /*
2474  Dijkstra's bisection algorithm to find the square root of an integer.
2475  Deliberately not exported as part of the Qt API, but used in both
2476  qsimplerichtext.cpp and qgfxraster_qws.cpp
2477 */
2478 Q_CORE_EXPORT unsigned int qt_int_sqrt(unsigned int n)
2479 {
2480  // n must be in the range 0...UINT_MAX/2-1
2481  if (n >= (UINT_MAX>>2)) {
2482  unsigned int r = 2 * qt_int_sqrt(n / 4);
2483  unsigned int r2 = r + 1;
2484  return (n >= r2 * r2) ? r2 : r;
2485  }
2486  uint h, p= 0, q= 1, r= n;
2487  while (q <= n)
2488  q <<= 2;
2489  while (q != 1) {
2490  q >>= 2;
2491  h= p + q;
2492  p >>= 1;
2493  if (r >= h) {
2494  p += q;
2495  r -= h;
2496  }
2497  }
2498  return p;
2499 }
2500 
2501 #if defined(qMemCopy)
2502 # undef qMemCopy
2503 #endif
2504 #if defined(qMemSet)
2505 # undef qMemSet
2506 #endif
2507 
2508 void *qMemCopy(void *dest, const void *src, size_t n) { return memcpy(dest, src, n); }
2509 void *qMemSet(void *dest, int c, size_t n) { return memset(dest, c, n); }
2510 
2511 static QtMsgHandler handler = 0; // pointer to debug handler
2512 
2513 #if defined(Q_CC_MWERKS) && defined(Q_OS_MACX)
2514 extern bool qt_is_gui_used;
2515 static void mac_default_handler(const char *msg)
2516 {
2517  if (qt_is_gui_used) {
2518  Str255 pmsg;
2520  DebugStr(pmsg);
2521  } else {
2522  fprintf(stderr, msg);
2523  }
2524 }
2525 #endif // Q_CC_MWERKS && Q_OS_MACX
2526 
2527 #if defined(QT_USE_SLOG2)
2528 #ifndef QT_LOG_CODE
2529 #define QT_LOG_CODE 9000
2530 #endif
2531 
2532 extern char *__progname;
2533 
2534 static void slog2_default_handler(QtMsgType msgType, const char *message)
2535 {
2536  if (slog2_set_default_buffer((slog2_buffer_t)-1) == 0) {
2537  slog2_buffer_set_config_t buffer_config;
2538  slog2_buffer_t buffer_handle;
2539 
2540  buffer_config.buffer_set_name = __progname;
2541  buffer_config.num_buffers = 1;
2542  buffer_config.verbosity_level = SLOG2_INFO;
2543  buffer_config.buffer_config[0].buffer_name = "default";
2544  buffer_config.buffer_config[0].num_pages = 8;
2545 
2546  if (slog2_register(&buffer_config, &buffer_handle, 0) == -1) {
2547  fprintf(stderr, "Error registering slogger2 buffer!\n");
2548  fprintf(stderr, "%s", message);
2549  fflush(stderr);
2550  return;
2551  }
2552 
2553  // Set as the default buffer
2554  slog2_set_default_buffer(buffer_handle);
2555  }
2556  int severity;
2557  //Determines the severity level
2558  switch (msgType) {
2559  case QtDebugMsg:
2560  severity = SLOG2_INFO;
2561  break;
2562  case QtWarningMsg:
2563  severity = SLOG2_NOTICE;
2564  break;
2565  case QtCriticalMsg:
2566  severity = SLOG2_WARNING;
2567  break;
2568  case QtFatalMsg:
2569  severity = SLOG2_ERROR;
2570  break;
2571  }
2572  //writes to the slog2 buffer
2573  slog2c(NULL, QT_LOG_CODE, severity, message);
2574 }
2575 #endif // QT_USE_SLOG2
2576 
2577 #if !defined(Q_OS_WIN) && !defined(QT_NO_THREAD) && !defined(Q_OS_INTEGRITY) && !defined(Q_OS_QNX) && \
2578  defined(_POSIX_THREAD_SAFE_FUNCTIONS) && _POSIX_VERSION >= 200112L
2579 namespace {
2580  // There are two incompatible versions of strerror_r:
2581  // a) the XSI/POSIX.1 version, which returns an int,
2582  // indicating success or not
2583  // b) the GNU version, which returns a char*, which may or may not
2584  // be the beginning of the buffer we used
2585  // The GNU libc manpage for strerror_r says you should use the the XSI
2586  // version in portable code. However, it's impossible to do that if
2587  // _GNU_SOURCE is defined so we use C++ overloading to decide what to do
2588  // depending on the return type
2589  static inline QString fromstrerror_helper(int, const QByteArray &buf)
2590  {
2591  return QString::fromLocal8Bit(buf);
2592  }
2593  static inline QString fromstrerror_helper(const char *str, const QByteArray &)
2594  {
2595  return QString::fromLocal8Bit(str);
2596  }
2597 }
2598 #endif
2599 
2600 QString qt_error_string(int errorCode)
2601 {
2602  const char *s = 0;
2603  QString ret;
2604  if (errorCode == -1) {
2605 #if defined(Q_OS_WIN)
2606  errorCode = GetLastError();
2607 #else
2608  errorCode = errno;
2609 #endif
2610  }
2611  switch (errorCode) {
2612  case 0:
2613  break;
2614  case EACCES:
2615  s = QT_TRANSLATE_NOOP("QIODevice", "Permission denied");
2616  break;
2617  case EMFILE:
2618  s = QT_TRANSLATE_NOOP("QIODevice", "Too many open files");
2619  break;
2620  case ENOENT:
2621  s = QT_TRANSLATE_NOOP("QIODevice", "No such file or directory");
2622  break;
2623  case ENOSPC:
2624  s = QT_TRANSLATE_NOOP("QIODevice", "No space left on device");
2625  break;
2626  default: {
2627 #ifdef Q_OS_WIN
2628  wchar_t *string = 0;
2629  FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM,
2630  NULL,
2631  errorCode,
2632  MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
2633  (LPWSTR)&string,
2634  0,
2635  NULL);
2636  ret = QString::fromWCharArray(string);
2637  LocalFree((HLOCAL)string);
2638 
2639  if (ret.isEmpty() && errorCode == ERROR_MOD_NOT_FOUND)
2640  ret = QString::fromLatin1("The specified module could not be found.");
2641 #elif !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && _POSIX_VERSION >= 200112L && !defined(Q_OS_INTEGRITY) && !defined(Q_OS_QNX)
2642  QByteArray buf(1024, '\0');
2643  ret = fromstrerror_helper(strerror_r(errorCode, buf.data(), buf.size()), buf);
2644 #else
2645  ret = QString::fromLocal8Bit(strerror(errorCode));
2646 #endif
2647  break; }
2648  }
2649  if (s)
2650  // ######## this breaks moc build currently
2651 // ret = QCoreApplication::translate("QIODevice", s);
2652  ret = QString::fromLatin1(s);
2653  return ret.trimmed();
2654 }
2655 
2656 
2693 #if defined(Q_OS_WIN) && defined(QT_BUILD_CORE_LIB)
2694 extern bool usingWinMain;
2695 extern Q_CORE_EXPORT void qWinMsgHandler(QtMsgType t, const char* str);
2696 #endif
2697 
2699 {
2700  QtMsgHandler old = handler;
2701  handler = h;
2702 #if defined(Q_OS_WIN) && defined(QT_BUILD_CORE_LIB)
2703  if (!handler && usingWinMain)
2705 #endif
2706  return old;
2707 }
2708 
2712 void qt_message_output(QtMsgType msgType, const char *buf)
2713 {
2714  if (handler) {
2715  (*handler)(msgType, buf);
2716  } else {
2717 #if defined(Q_CC_MWERKS) && defined(Q_OS_MACX)
2718  mac_default_handler(buf);
2719 #elif defined(QT_USE_SLOG2)
2720  slog2_default_handler(msgType, buf);
2721 #elif defined(Q_OS_WINCE)
2722  QString fstr = QString::fromLatin1(buf);
2723  fstr += QLatin1Char('\n');
2724  OutputDebugString(reinterpret_cast<const wchar_t *> (fstr.utf16()));
2725 #elif defined(Q_OS_SYMBIAN)
2726  // RDebug::Print has a cap of 256 characters so break it up
2727  char format[] = "[Qt Message] %S";
2728  const int maxBlockSize = 256 - sizeof(format);
2729  const TPtrC8 ptr(reinterpret_cast<const TUint8*>(buf));
2730  for (int i = 0; i < ptr.Length(); i += maxBlockSize) {
2731  TPtrC8 part(ptr.Mid(i, qMin(maxBlockSize, ptr.Length()-i)));
2732  RDebug::Printf(format, &part);
2733  }
2734 #else
2735  fprintf(stderr, "%s\n", buf);
2736  fflush(stderr);
2737 #endif
2738  }
2739 
2740  if (msgType == QtFatalMsg
2741  || (msgType == QtWarningMsg
2742  && (!qgetenv("QT_FATAL_WARNINGS").isNull())) ) {
2743 
2744 #if defined(Q_CC_MSVC) && defined(QT_DEBUG) && defined(_DEBUG) && defined(_CRT_ERROR)
2745  // get the current report mode
2746  int reportMode = _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_WNDW);
2747  _CrtSetReportMode(_CRT_ERROR, reportMode);
2748 #if !defined(Q_OS_WINCE)
2749  int ret = _CrtDbgReport(_CRT_ERROR, __FILE__, __LINE__, QT_VERSION_STR, buf);
2750 #else
2751  int ret = _CrtDbgReportW(_CRT_ERROR, _CRT_WIDE(__FILE__),
2752  __LINE__, _CRT_WIDE(QT_VERSION_STR), reinterpret_cast<const wchar_t *> (QString::fromLatin1(buf).utf16()));
2753 #endif
2754  if (ret == 0 && reportMode & _CRTDBG_MODE_WNDW)
2755  return; // ignore
2756  else if (ret == 1)
2757  _CrtDbgBreak();
2758 #endif
2759 
2760 #if defined(Q_OS_SYMBIAN)
2761  __DEBUGGER(); // on the emulator, get the debugger to kick in if there's one around
2762  TBuf<256> tmp;
2763  TPtrC8 ptr(reinterpret_cast<const TUint8*>(buf));
2764  TInt len = Min(tmp.MaxLength(), ptr.Length());
2765  tmp.Copy(ptr.Left(len));
2766  // Panic the current thread. We don't use real panic codes, so 0 has no special meaning.
2767  User::Panic(tmp, 0);
2768 #elif (defined(Q_OS_UNIX) || defined(Q_CC_MINGW))
2769  abort(); // trap; generates core dump
2770 #else
2771  exit(1); // goodbye cruel world
2772 #endif
2773  }
2774 }
2775 
2776 #if !defined(QT_NO_EXCEPTIONS)
2777 
2785 static void qEmergencyOut(QtMsgType msgType, const char *msg, va_list ap)
2786 {
2787  char emergency_buf[256] = { '\0' };
2788  emergency_buf[255] = '\0';
2789  if (msg)
2790  qvsnprintf(emergency_buf, 255, msg, ap);
2791  qt_message_output(msgType, emergency_buf);
2792 }
2793 #endif
2794 
2798 static void qt_message(QtMsgType msgType, const char *msg, va_list ap)
2799 {
2800 #if !defined(QT_NO_EXCEPTIONS)
2801  if (std::uncaught_exception()) {
2802  qEmergencyOut(msgType, msg, ap);
2803  return;
2804  }
2805 #endif
2806  QByteArray buf;
2807  if (msg) {
2808  QT_TRY {
2809  buf = QString().vsprintf(msg, ap).toLocal8Bit();
2810  } QT_CATCH(const std::bad_alloc &) {
2811 #if !defined(QT_NO_EXCEPTIONS)
2812  qEmergencyOut(msgType, msg, ap);
2813  // don't rethrow - we use qWarning and friends in destructors.
2814  return;
2815 #endif
2816  }
2817  }
2818  qt_message_output(msgType, buf.constData());
2819 }
2820 
2821 #undef qDebug
2822 
2859 void qDebug(const char *msg, ...)
2860 {
2861  va_list ap;
2862  va_start(ap, msg); // use variable arg list
2863  qt_message(QtDebugMsg, msg, ap);
2864  va_end(ap);
2865 }
2866 
2867 #undef qWarning
2868 
2902 void qWarning(const char *msg, ...)
2903 {
2904  va_list ap;
2905  va_start(ap, msg); // use variable arg list
2906  qt_message(QtWarningMsg, msg, ap);
2907  va_end(ap);
2908 }
2909 
2941 void qCritical(const char *msg, ...)
2942 {
2943  va_list ap;
2944  va_start(ap, msg); // use variable arg list
2945  qt_message(QtCriticalMsg, msg, ap);
2946  va_end(ap);
2947 }
2948 
2949 #ifdef QT3_SUPPORT
2950 void qSystemWarning(const char *msg, int code)
2951  { qCritical("%s (%s)", msg, qt_error_string(code).toLocal8Bit().constData()); }
2952 #endif // QT3_SUPPORT
2953 
2954 void qErrnoWarning(const char *msg, ...)
2955 {
2956  // qt_error_string() will allocate anyway, so we don't have
2957  // to be careful here (like we do in plain qWarning())
2958  QString buf;
2959  va_list ap;
2960  va_start(ap, msg);
2961  if (msg)
2962  buf.vsprintf(msg, ap);
2963  va_end(ap);
2964 
2965  qCritical("%s (%s)", buf.toLocal8Bit().constData(), qt_error_string(-1).toLocal8Bit().constData());
2966 }
2967 
2968 void qErrnoWarning(int code, const char *msg, ...)
2969 {
2970  // qt_error_string() will allocate anyway, so we don't have
2971  // to be careful here (like we do in plain qWarning())
2972  QString buf;
2973  va_list ap;
2974  va_start(ap, msg);
2975  if (msg)
2976  buf.vsprintf(msg, ap);
2977  va_end(ap);
2978 
2979  qCritical("%s (%s)", buf.toLocal8Bit().constData(), qt_error_string(code).toLocal8Bit().constData());
2980 }
2981 
3009 void qFatal(const char *msg, ...)
3010 {
3011  va_list ap;
3012  va_start(ap, msg); // use variable arg list
3013  qt_message(QtFatalMsg, msg, ap);
3014  va_end(ap);
3015 }
3016 
3017 // getenv is declared as deprecated in VS2005. This function
3018 // makes use of the new secure getenv function.
3035 QByteArray qgetenv(const char *varName)
3036 {
3037 #if defined(_MSC_VER) && _MSC_VER >= 1400
3038  size_t requiredSize = 0;
3039  QByteArray buffer;
3040  getenv_s(&requiredSize, 0, 0, varName);
3041  if (requiredSize == 0)
3042  return buffer;
3043  buffer.resize(int(requiredSize));
3044  getenv_s(&requiredSize, buffer.data(), requiredSize, varName);
3045  // requiredSize includes the terminating null, which we don't want.
3046  Q_ASSERT(buffer.endsWith('\0'));
3047  buffer.chop(1);
3048  return buffer;
3049 #else
3050  return QByteArray(::getenv(varName));
3051 #endif
3052 }
3053 
3071 bool qputenv(const char *varName, const QByteArray& value)
3072 {
3073 #if defined(_MSC_VER) && _MSC_VER >= 1400
3074  return _putenv_s(varName, value.constData()) == 0;
3075 #else
3076  QByteArray buffer(varName);
3077  buffer += '=';
3078  buffer += value;
3079  char* envVar = qstrdup(buffer.constData());
3080  int result = putenv(envVar);
3081  if (result != 0) // error. we have to delete the string.
3082  delete[] envVar;
3083  return result == 0;
3084 #endif
3085 }
3086 
3087 #if defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN) && !defined(QT_NO_THREAD)
3088 
3089 # if defined(Q_OS_INTEGRITY) && defined(__GHS_VERSION_NUMBER) && (__GHS_VERSION_NUMBER < 500)
3090 // older versions of INTEGRITY used a long instead of a uint for the seed.
3091 typedef long SeedStorageType;
3092 # else
3094 # endif
3095 
3097 Q_GLOBAL_STATIC(SeedStorage, randTLS) // Thread Local Storage for seed value
3098 
3099 #endif
3100 
3119 void qsrand(uint seed)
3120 {
3121 #if defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN) && !defined(QT_NO_THREAD)
3122  SeedStorage *seedStorage = randTLS();
3123  if (seedStorage) {
3124  SeedStorageType *pseed = seedStorage->localData();
3125  if (!pseed)
3126  seedStorage->setLocalData(pseed = new SeedStorageType);
3127  *pseed = seed;
3128  } else {
3129  //global static seed storage should always exist,
3130  //except after being deleted by QGlobalStaticDeleter.
3131  //But since it still can be called from destructor of another
3132  //global static object, fallback to srand(seed)
3133  srand(seed);
3134  }
3135 #else
3136  // On Windows and Symbian srand() and rand() already use Thread-Local-Storage
3137  // to store the seed between calls
3138  // this is also valid for QT_NO_THREAD
3139  srand(seed);
3140 #endif
3141 }
3142 
3161 int qrand()
3162 {
3163 #if defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN) && !defined(QT_NO_THREAD)
3164  SeedStorage *seedStorage = randTLS();
3165  if (seedStorage) {
3166  SeedStorageType *pseed = seedStorage->localData();
3167  if (!pseed) {
3168  seedStorage->setLocalData(pseed = new SeedStorageType);
3169  *pseed = 1;
3170  }
3171  return rand_r(pseed);
3172  } else {
3173  //global static seed storage should always exist,
3174  //except after being deleted by QGlobalStaticDeleter.
3175  //But since it still can be called from destructor of another
3176  //global static object, fallback to rand()
3177  return rand();
3178  }
3179 #else
3180  // On Windows and Symbian srand() and rand() already use Thread-Local-Storage
3181  // to store the seed between calls
3182  // this is also valid for QT_NO_THREAD
3183  return rand();
3184 #endif
3185 }
3186 
3578 #if defined(QT3_SUPPORT) && !defined(QT_NO_SETTINGS)
3580 #include <qlibraryinfo.h>
3582 
3583 static const char *qInstallLocation(QLibraryInfo::LibraryLocation loc)
3584 {
3585  static QByteArray ret;
3586  ret = QLibraryInfo::location(loc).toLatin1();
3587  return ret.constData();
3588 }
3589 const char *qInstallPath()
3590 {
3591  return qInstallLocation(QLibraryInfo::PrefixPath);
3592 }
3593 const char *qInstallPathDocs()
3594 {
3595  return qInstallLocation(QLibraryInfo::DocumentationPath);
3596 }
3597 const char *qInstallPathHeaders()
3598 {
3599  return qInstallLocation(QLibraryInfo::HeadersPath);
3600 }
3601 const char *qInstallPathLibs()
3602 {
3603  return qInstallLocation(QLibraryInfo::LibrariesPath);
3604 }
3605 const char *qInstallPathBins()
3606 {
3607  return qInstallLocation(QLibraryInfo::BinariesPath);
3608 }
3609 const char *qInstallPathPlugins()
3610 {
3611  return qInstallLocation(QLibraryInfo::PluginsPath);
3612 }
3613 const char *qInstallPathData()
3614 {
3615  return qInstallLocation(QLibraryInfo::DataPath);
3616 }
3617 const char *qInstallPathTranslations()
3618 {
3619  return qInstallLocation(QLibraryInfo::TranslationsPath);
3620 }
3621 const char *qInstallPathSysconf()
3622 {
3623  return qInstallLocation(QLibraryInfo::SettingsPath);
3624 }
3625 #endif
3626 
3629 };
3630 
3631 Q_GLOBAL_STATIC(QInternal_CallBackTable, global_callback_table)
3632 
3633 bool QInternal::registerCallback(Callback cb, qInternalCallback callback)
3634 {
3635  if (cb >= 0 && cb < QInternal::LastCallback) {
3636  QInternal_CallBackTable *cbt = global_callback_table();
3637  cbt->callbacks.resize(cb + 1);
3638  cbt->callbacks[cb].append(callback);
3639  return true;
3640  }
3641  return false;
3642 }
3643 
3645 {
3646  if (cb >= 0 && cb < QInternal::LastCallback) {
3647  QInternal_CallBackTable *cbt = global_callback_table();
3648  return (bool) cbt->callbacks[cb].removeAll(callback);
3649  }
3650  return false;
3651 }
3652 
3653 bool QInternal::activateCallbacks(Callback cb, void **parameters)
3654 {
3655  Q_ASSERT_X(cb >= 0, "QInternal::activateCallback()", "Callback id must be a valid id");
3656 
3657  QInternal_CallBackTable *cbt = global_callback_table();
3658  if (cbt && cb < cbt->callbacks.size()) {
3659  QList<qInternalCallback> callbacks = cbt->callbacks[cb];
3660  bool ret = false;
3661  for (int i=0; i<callbacks.size(); ++i)
3662  ret |= (callbacks.at(i))(parameters);
3663  return ret;
3664  }
3665  return false;
3666 }
3667 
3669 
3671 {
3672  Q_ASSERT_X(func >= 0,
3673  "QInternal::callFunction()", "Callback id must be a valid id");
3674 #ifndef QT_NO_QOBJECT
3675  switch (func) {
3676 #ifndef QT_NO_THREAD
3679  return true;
3680 #endif
3682  QThreadData::get2((QThread *) *args)->ref();
3683  return true;
3685  QThreadData::get2((QThread *) *args)->deref();
3686  return true;
3689  return true;
3691  QObject *receiver = (QObject *) args[0];
3693  sender->sender = (QObject *) args[1];
3694  sender->signal = *(int *) args[2];
3695  sender->ref = 1;
3696 
3697  // Store the old sender as "return value"
3698  args[3] = QObjectPrivate::setCurrentSender(receiver, sender);
3699  args[4] = sender;
3700  return true;
3701  }
3703  QObject *receiver = (QObject *) args[0];
3704  QObjectPrivate *d = QObjectPrivate::get(receiver);
3705  args[1] = d->currentSender ? d->currentSender->sender : 0;
3706  return true;
3707  }
3709  QObject *receiver = (QObject *) args[0];
3710  QObjectPrivate::Sender *oldSender = (QObjectPrivate::Sender *) args[1];
3711  QObjectPrivate::Sender *sender = (QObjectPrivate::Sender *) args[2];
3712  QObjectPrivate::resetCurrentSender(receiver, sender, oldSender);
3713  delete sender;
3714  return true;
3715  }
3716 
3717  default:
3718  break;
3719  }
3720 #else
3721  Q_UNUSED(args);
3722  Q_UNUSED(func);
3723 #endif
3724 
3725  return false;
3726 }
3727 
4060 #if defined(Q_OS_SYMBIAN)
4061 
4062 #include <typeinfo>
4063 
4155 #include <stdexcept>
4156 
4157 class QSymbianLeaveException : public std::exception
4158 {
4159 public:
4160  inline QSymbianLeaveException(int err) : error(err) {}
4161  inline const char* what() const throw() { return "Symbian leave exception"; }
4162 
4163 public:
4164  int error;
4165 };
4166 
4180 void qt_symbian_throwIfError(int error)
4181 {
4182  if (error >= KErrNone)
4183  return; // do nothing - not an exception
4184  switch (error) {
4185  case KErrNoMemory:
4186  throw std::bad_alloc();
4187  case KErrArgument:
4188  throw std::invalid_argument("from Symbian error");
4189  case KErrOverflow:
4190  throw std::overflow_error("from Symbian error");
4191  case KErrUnderflow:
4192  throw std::underflow_error("from Symbian error");
4193  default:
4194  throw QSymbianLeaveException(error);
4195  }
4196 }
4197 
4210 void qt_symbian_exception2LeaveL(const std::exception& aThrow)
4211 {
4212  User::Leave(qt_symbian_exception2Error(aThrow));
4213 }
4214 
4227 int qt_symbian_exception2Error(const std::exception& aThrow)
4228 {
4229  const std::type_info& atype = typeid(aThrow);
4230  int err = KErrGeneral;
4231 
4232  if(atype == typeid (std::bad_alloc))
4233  err = KErrNoMemory;
4234  else if(atype == typeid(QSymbianLeaveException))
4235  err = static_cast<const QSymbianLeaveException&>(aThrow).error;
4236  else {
4237  if(atype == typeid(std::invalid_argument))
4238  err = KErrArgument;
4239  else if(atype == typeid(std::out_of_range))
4240  // std::out_of_range is of type logic_error which by definition means that it is
4241  // "presumably detectable before the program executes".
4242  // std::out_of_range is used to report an argument is not within the expected range.
4243  // The description of KErrArgument says an argument is out of range. Hence the mapping.
4244  err = KErrArgument;
4245  else if(atype == typeid(std::overflow_error))
4246  err = KErrOverflow;
4247  else if(atype == typeid(std::underflow_error))
4248  err = KErrUnderflow;
4249  qWarning("translation from std exception \"%s\" to %d", aThrow.what(), err);
4250  }
4251 
4252  return err;
4253 }
4254 #endif
4255 
static QString fromWCharArray(const wchar_t *, int size=-1)
Returns a copy of the string, where the encoding of string depends on the size of wchar...
Definition: qstring.cpp:1019
double d
Definition: qnumeric_p.h:62
QString qt_error_string(int errorCode)
Definition: qglobal.cpp:2600
void chop(int n)
Removes n bytes from the end of the byte array.
static Sender * setCurrentSender(QObject *receiver, Sender *sender)
Definition: qobject_p.h:269
static void callback(AuServer *, AuEventHandlerRec *, AuEvent *e, AuPointer p)
Definition: qsound_x11.cpp:170
Q_CORE_EXPORT QByteArray qgetenv(const char *varName)
void qBadAlloc()
Definition: qglobal.cpp:2451
static QString fromLocal8Bit(const char *, int size=-1)
Returns a QString initialized with the first size characters of the 8-bit string str.
Definition: qstring.cpp:4245
static void qt_message(QtMsgType msgType, const char *msg, va_list ap)
Definition: qglobal.cpp:2798
uint SeedStorageType
Definition: qglobal.cpp:3093
unsigned char c[8]
Definition: qnumeric_p.h:62
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
static QString fromAscii(const char *, int size=-1)
Returns a QString initialized with the first size characters from the string str. ...
Definition: qstring.cpp:4276
char * data()
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:429
DWORD qt_cever
static void qEmergencyOut(QtMsgType msgType, const char *msg, va_list ap)
Uses a local buffer to output the message.
Definition: qglobal.cpp:2785
#define error(msg)
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
#define getenv_s(a, b, c, d)
static WinVersion windowsVersion()
Returns the version of the Windows operating system on which the application is run (Windows only)...
#define QT_TRANSLATE_NOOP(scope, x)
Marks the string literal sourceText for dynamic translation in the given context; i...
Definition: qglobal.h:2487
#define QT_END_INCLUDE_NAMESPACE
This macro is equivalent to QT_BEGIN_NAMESPACE.
Definition: qglobal.h:92
void(* QtMsgHandler)(QtMsgType, const char *)
Definition: qglobal.h:1885
static bool callFunction(InternalFunction func, void **)
Definition: qglobal.cpp:3670
static const WinVersion WindowsVersion
the version of the Windows operating system on which the application is run (Windows only) ...
Definition: qglobal.h:1613
The QString class provides a Unicode character string.
Definition: qstring.h:83
static QSysInfo::MacVersion macVersion()
Use QSysInfo::MacintoshVersion instead.
Definition: qglobal.cpp:2077
Q_CORE_EXPORT int qrand()
QString & vsprintf(const char *format, va_list ap)
Equivalent method to sprintf(), but takes a va_list ap instead a list of variable arguments...
Definition: qstring.cpp:5587
static QtMsgHandler handler
Definition: qglobal.cpp:2511
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
The QVector class is a template class that provides a dynamic array.
Definition: qdatastream.h:64
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
Sender * currentSender
Definition: qobject_p.h:200
QtMsgType
This enum describes the messages that can be sent to a message handler (QtMsgHandler).
Definition: qglobal.h:1881
static bool unregisterCallback(Callback, qInternalCallback)
Definition: qglobal.cpp:3644
static QObjectPrivate * get(QObject *o)
Definition: qobject_p.h:177
void deref()
Definition: qthread.cpp:125
void resize(int size)
Sets the size of the vector to size.
Definition: qvector.h:342
The QScopedPointer class stores a pointer to a dynamically allocated object, and deletes it upon dest...
bool usingWinMain
Q_CORE_EXPORT const char * qVersion()
Q_CORE_EXPORT void qDebug(const char *,...)
static QThreadData * get2(QThread *thread)
Definition: qthread_p.h:219
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
LibraryLocation
This enum type is used to specify a specific location specifier:
Definition: qlibraryinfo.h:67
static bool isEmpty(const char *str)
void qWinMsgHandler(QtMsgType t, const char *str)
#define QT_THROW(A)
Definition: qglobal.h:1538
static bool activateCallbacks(Callback, void **)
Definition: qglobal.cpp:3653
QString trimmed() const Q_REQUIRED_RESULT
Returns a string that has whitespace removed from the start and the end.
Definition: qstring.cpp:4506
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
#define Q_GLOBAL_STATIC(TYPE, NAME)
Declares a global static variable with the given type and name.
Definition: qglobal.h:1968
void qt_assert(const char *assertion, const char *file, int line)
Definition: qglobal.cpp:2459
T & localData()
Returns a reference to the data that was set by the calling thread.
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
void append(const T &t)
Inserts value at the end of the vector.
Definition: qvector.h:573
QVector< QList< qInternalCallback > > callbacks
Definition: qglobal.cpp:3628
Q_CORE_EXPORT void qWarning(const char *,...)
unsigned int uint
Definition: qglobal.h:996
#define QT_VERSION_STR
This macro expands to a string that specifies Qt&#39;s version number (for example, "4.
Definition: qglobal.h:47
static void resetCurrentSender(QObject *receiver, Sender *currentSender, Sender *previousSender)
Definition: qobject_p.h:277
const T * ptr(const T &t)
Q_CORE_EXPORT int qvsnprintf(char *str, size_t n, const char *fmt, va_list ap)
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
Definition: qstring.cpp:3993
void qt_check_pointer(const char *n, int l)
Definition: qglobal.cpp:2442
bool qSharedBuild()
Definition: qglobal.cpp:1228
#define QT_CATCH(A)
Definition: qglobal.h:1537
QByteArray toLocal8Bit() const Q_REQUIRED_RESULT
Returns the local 8-bit representation of the string as a QByteArray.
Definition: qstring.cpp:4049
void * qMemCopy(void *dest, const void *src, size_t n)
Definition: qglobal.cpp:2508
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
Q_CORE_EXPORT unsigned int qt_int_sqrt(unsigned int n)
Definition: qglobal.cpp:2478
void qt_message_output(QtMsgType msgType, const char *buf)
Definition: qglobal.cpp:2712
Q_CORE_EXPORT void qFatal(const char *,...)
#define Q_ASSERT_X(cond, where, what)
Definition: qglobal.h:1837
void * qMemSet(void *dest, int c, size_t n)
Definition: qglobal.cpp:2509
MacVersion
This enum provides symbolic names for the various versions of the OS X operating system.
Definition: qglobal.h:1618
void ref()
Definition: qthread.cpp:117
#define Q_CORE_EXPORT
Definition: qglobal.h:1449
QtMsgHandler qInstallMsgHandler(QtMsgHandler h)
Definition: qglobal.cpp:2698
Q_CORE_EXPORT char * qstrdup(const char *)
void qt_set_current_thread_to_main_thread()
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
static unsigned int seed
Definition: qtestcase.cpp:943
void setLocalData(T t)
Sets the local data for the calling thread to data.
static QString location(LibraryLocation)
Returns the location specified by loc.
QThreadStorage< SeedStorageType * > SeedStorage
Definition: qglobal.cpp:3096
void resize(int size)
Sets the size of the byte array to size bytes.
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
QFactoryLoader * l
bool(* qInternalCallback)(void **)
Definition: qnamespace.h:1818
int size() const
Returns the number of bytes in this byte array.
Definition: qbytearray.h:402
Q_CORE_EXPORT bool qputenv(const char *varName, const QByteArray &value)
#define QT_BEGIN_INCLUDE_NAMESPACE
This macro is equivalent to QT_END_NAMESPACE.
Definition: qglobal.h:91
#define _putenv_s(a, b)
static QThread * createThreadForAdoption()
Definition: qthread.cpp:156
static const MacVersion MacintoshVersion
the version of the Macintosh operating system on which the application is run (Mac only)...
Definition: qglobal.h:1646
WinVersion
This enum provides symbolic names for the various versions of the Windows operating system...
Definition: qglobal.h:1579
bool qt_is_gui_used
Q_CORE_EXPORT void qsrand(uint seed)
void qt_mac_to_pascal_string(const QString &s, Str255 str, TextEncoding encoding, int len)
Definition: qcore_mac.cpp:91
The QThread class provides a platform-independent way to manage threads.
Definition: qthread.h:59
The QThreadStorage class provides per-thread data storage.
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
#define QT_TRY
Definition: qglobal.h:1536
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
static bool isNull(const QVariant::Private *d)
Definition: qvariant.cpp:300
Q_CORE_EXPORT void qCritical(const char *,...)
int errno
bool endsWith(const QByteArray &a) const
Returns true if this byte array ends with byte array ba; otherwise returns false. ...
The QList class is a template class that provides lists.
Definition: qdatastream.h:62
const ushort * utf16() const
Returns the QString as a &#39;\0\&#39;-terminated array of unsigned shorts.
Definition: qstring.cpp:5290
void qErrnoWarning(const char *msg,...)
Definition: qglobal.cpp:2954
void qt_assert_x(const char *where, const char *what, const char *file, int line)
Definition: qglobal.cpp:2467