- Timestamp:
- Jul 4, 2009, 2:21:28 PM (16 years ago)
- Location:
- trunk/src/corelib/kernel
- Files:
-
- 3 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/corelib/kernel/kernel.pri
r2 r68 68 68 } 69 69 70 71 72 73 74 75 76 70 77 71 78 wince*: { -
trunk/src/corelib/kernel/qcoreapplication.cpp
r2 r68 74 74 #endif 75 75 76 77 78 79 76 80 #ifdef Q_OS_MAC 77 81 # include "qcore_mac_p.h" … … 86 90 QT_BEGIN_NAMESPACE 87 91 88 #if defined(Q_WS_WIN) || defined(Q_WS_ MAC)92 #if defined(Q_WS_WIN) || defined(Q_WS_MAC) 89 93 extern QString qAppFileName(); 90 94 #endif 91 95 92 #if !defined(Q_OS_WIN) 96 #if !defined(Q_OS_WIN) 93 97 #ifdef Q_OS_MAC 94 98 QString QCoreApplicationPrivate::macMenuBarName() … … 278 282 #elif defined(Q_OS_WIN) 279 283 eventDispatcher = new QEventDispatcherWin32(q); 284 285 280 286 #else 281 287 # error "QEventDispatcher not yet ported to this platform" … … 378 384 setLibraryPaths(), addLibraryPath(), and removeLibraryPath(). 379 385 380 On Unix/Linux Qt is configured to use the system local settings by 381 default. This can cause a conflict when using POSIX functions, for 382 instance, when converting between data types such as floats and 383 strings, since the notation may differ between locales. To get 384 around this problem call the POSIX function setlocale(LC_NUMERIC,"C") 385 right after initializing QApplication or QCoreApplication to reset 386 On Unix/Linux Qt is configured to use the system local settings by 387 default. This can cause a conflict when using POSIX functions, for 388 instance, when converting between data types such as floats and 389 strings, since the notation may differ between locales. To get 390 around this problem call the POSIX function setlocale(LC_NUMERIC,"C") 391 right after initializing QApplication or QCoreApplication to reset 386 392 the locale that is used for number formatting to "C"-locale. 387 393 … … 1743 1749 1744 1750 d->cachedApplicationFilePath = filePath.filePath(); 1751 1752 1753 1754 1755 1756 1757 1745 1758 return d->cachedApplicationFilePath; 1746 1759 #elif defined(Q_WS_MAC) … … 1815 1828 #if defined(Q_OS_WIN32) || defined(Q_OS_WINCE) 1816 1829 return GetCurrentProcessId(); 1830 1831 1832 1833 1817 1834 #else 1818 1835 // UNIX … … 2068 2085 const QByteArray libPathEnv = qgetenv("QT_PLUGIN_PATH"); 2069 2086 if (!libPathEnv.isEmpty()) { 2070 #if def Q_OS_WIN2087 #if 2071 2088 QLatin1Char pathSep(';'); 2072 2089 #else … … 2218 2235 if (d->eventFilter) 2219 2236 return d->eventFilter(message, result); 2220 #if def Q_OS_WIN2237 #if 2221 2238 return winEventFilter(reinterpret_cast<MSG *>(message), result); 2239 2240 2222 2241 #else 2223 2242 return false; -
trunk/src/corelib/kernel/qcoreapplication.h
r2 r68 53 53 #if defined(Q_WS_WIN) && !defined(tagMSG) 54 54 typedef struct tagMSG MSG; 55 56 57 58 59 55 60 #endif 56 61 … … 164 169 #if defined(Q_WS_WIN) 165 170 virtual bool winEventFilter(MSG *message, long *result); 171 172 173 174 166 175 #endif 167 176 -
trunk/src/corelib/kernel/qcoreapplication_pm.cpp
r63 r68 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** Contact: Qt Software Information ([email protected]) 5 6 5 7 ** 6 8 ** This file is part of the QtCore module of the Qt Toolkit. … … 43 45 #include "qcoreapplication_p.h" 44 46 #include "qstringlist.h" 45 #include "qt_ windows.h"47 #include "qt_.h" 46 48 #include "qvector.h" 47 49 #include "qmutex.h" … … 52 54 QT_BEGIN_NAMESPACE 53 55 54 // ############### DON'T EXPORT HERE!!! 55 Q_CORE_EXPORT char appFileName[MAX_PATH+1]; // application file name 56 Q_CORE_EXPORT char theAppName[MAX_PATH+1]; // application name 57 Q_CORE_EXPORT HINSTANCE appInst = 0; // handle to app instance 58 Q_CORE_EXPORT HINSTANCE appPrevInst = 0; // handle to prev app instance 59 Q_CORE_EXPORT int appCmdShow = 0; 60 bool usingWinMain = false; // whether the qWinMain() is used or not 61 62 Q_CORE_EXPORT HINSTANCE qWinAppInst() // get Windows app handle 63 { 64 return appInst; 65 } 66 67 Q_CORE_EXPORT HINSTANCE qWinAppPrevInst() // get Windows prev app handle 68 { 69 return appPrevInst; 70 } 71 72 void set_winapp_name() 56 static char appFileName[CCHMAXPATH]; // application file name 57 static char theAppName[CCHMAXPATH]; // application name 58 59 static void set_app_name() 73 60 { 74 61 static bool already_set = false; 75 62 if (!already_set) { 76 63 already_set = true; 77 #ifndef Q_OS_WINCE 78 GetModuleFileNameA(0, appFileName, sizeof(appFileName)); 79 appFileName[sizeof(appFileName)-1] = 0; 80 #else 81 QString afm; 82 afm.resize(sizeof(appFileName)); 83 afm.resize(GetModuleFileName(0, (wchar_t *) (afm.unicode()), sizeof(appFileName))); 84 memcpy(appFileName, afm.toLatin1(), sizeof(appFileName)); 85 #endif 64 PPIB ppib; 65 DosGetInfoBlocks(NULL, &ppib); 66 DosQueryModuleName(ppib->pib_hmte, sizeof(appFileName), appFileName); 67 86 68 const char *p = strrchr(appFileName, '\\'); // skip path 87 69 if (p) … … 95 77 Q_CORE_EXPORT QString qAppFileName() // get application file name 96 78 { 97 return QString::fromLatin1(appFileName); 79 set_app_name(); 80 return QString::fromLocal8Bit(appFileName); 98 81 } 99 82 100 83 QString QCoreApplicationPrivate::appName() const 101 84 { 102 if (!theAppName[0]) 103 set_winapp_name(); 104 return QString::fromLatin1(theAppName); 105 } 106 107 class QWinMsgHandlerCriticalSection 108 { 109 CRITICAL_SECTION cs; 110 public: 111 QWinMsgHandlerCriticalSection() 112 { InitializeCriticalSection(&cs); } 113 ~QWinMsgHandlerCriticalSection() 114 { DeleteCriticalSection(&cs); } 115 116 void lock() 117 { EnterCriticalSection(&cs); } 118 void unlock() 119 { LeaveCriticalSection(&cs); } 120 }; 121 122 Q_CORE_EXPORT void qWinMsgHandler(QtMsgType t, const char* str) 123 { 124 Q_UNUSED(t); 125 // OutputDebugString is not threadsafe. 126 127 // cannot use QMutex here, because qWarning()s in the QMutex 128 // implementation may cause this function to recurse 129 static QWinMsgHandlerCriticalSection staticCriticalSection; 130 131 if (!str) 132 str = "(null)"; 133 134 staticCriticalSection.lock(); 135 QT_WA({ 136 QString s(QString::fromLocal8Bit(str)); 137 s += QLatin1String("\n"); 138 OutputDebugStringW((TCHAR*)s.utf16()); 139 }, { 140 QByteArray s(str); 141 s += "\n"; 142 OutputDebugStringA(s.data()); 143 }) 144 staticCriticalSection.unlock(); 145 } 146 147 148 /***************************************************************************** 149 qWinMain() - Initializes Windows. Called from WinMain() in qtmain_win.cpp 150 *****************************************************************************/ 151 152 #if defined(Q_OS_WINCE) 153 Q_CORE_EXPORT void __cdecl qWinMain(HINSTANCE instance, HINSTANCE prevInstance, LPSTR cmdParam, 154 int cmdShow, int &argc, QVector<char *> &argv) 155 #else 156 Q_CORE_EXPORT 157 void qWinMain(HINSTANCE instance, HINSTANCE prevInstance, LPSTR cmdParam, 158 int cmdShow, int &argc, QVector<char *> &argv) 159 #endif 160 { 161 static bool already_called = false; 162 163 if (already_called) { 164 qWarning("Qt: Internal error: qWinMain should be called only once"); 165 return; 166 } 167 already_called = true; 168 usingWinMain = true; 169 170 // Install default debug handler 171 172 qInstallMsgHandler(qWinMsgHandler); 173 174 // Create command line 175 176 set_winapp_name(); 177 178 argv = qWinCmdLine<char>(cmdParam, int(strlen(cmdParam)), argc); 179 // Get Windows parameters 180 181 appInst = instance; 182 appPrevInst = prevInstance; 183 appCmdShow = cmdShow; 85 set_app_name(); 86 return QString::fromLocal8Bit(theAppName); 184 87 } 185 88 … … 198 101 QAbstractEventDispatcher::instance(). 199 102 */ 200 bool QCoreApplication::winEventFilter(MSG *msg, long *result) // Windows event filter 201 { 202 Q_UNUSED(msg); 203 Q_UNUSED(result); 103 bool QCoreApplication::pmEventFilter(QMSG * /*msg*/, MRESULT * /*rc*/) 104 { 204 105 return false; 205 106 } 206 107 108 109 207 110 void QCoreApplicationPrivate::removePostedTimerEvent(QObject *object, int timerId) 208 111 { … … 226 129 } 227 130 } 228 229 #if defined(Q_WS_WIN) && !defined(QT_NO_DEBUG_STREAM) 131 #endif 132 133 // @todo later 134 #if 0 && !defined(QT_NO_DEBUG_STREAM) 230 135 /***************************************************************************** 231 136 Convenience functions for convert WM_* messages into human readable strings, … … 233 138 *****************************************************************************/ 234 139 QT_BEGIN_INCLUDE_NAMESPACE 235 #include <windowsx.h>236 140 #include "qdebug.h" 237 141 QT_END_INCLUDE_NAMESPACE
Note:
See TracChangeset
for help on using the changeset viewer.