summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qcoreapplication_win.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/kernel/qcoreapplication_win.cpp')
-rw-r--r--src/corelib/kernel/qcoreapplication_win.cpp112
1 files changed, 57 insertions, 55 deletions
diff --git a/src/corelib/kernel/qcoreapplication_win.cpp b/src/corelib/kernel/qcoreapplication_win.cpp
index 424ee3fdea..396d2f740a 100644
--- a/src/corelib/kernel/qcoreapplication_win.cpp
+++ b/src/corelib/kernel/qcoreapplication_win.cpp
@@ -1,8 +1,8 @@
/****************************************************************************
**
** Copyright (C) 2013 Samuel Gaist <samuel.gaist@edeltech.ch>
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
**
@@ -11,9 +11,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -24,8 +24,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -184,28 +184,6 @@ Q_CORE_EXPORT void __cdecl qWinMain(HINSTANCE instance, HINSTANCE prevInstance,
#ifndef QT_NO_QOBJECT
-void QCoreApplicationPrivate::removePostedTimerEvent(QObject *object, int timerId)
-{
- QThreadData *data = object->d_func()->threadData;
-
- QMutexLocker locker(&data->postEventList.mutex);
- if (data->postEventList.size() == 0)
- return;
- for (int i = 0; i < data->postEventList.size(); ++i) {
- const QPostEvent & pe = data->postEventList.at(i);
- if (pe.receiver == object
- && pe.event
- && (pe.event->type() == QEvent::Timer || pe.event->type() == QEvent::ZeroTimerEvent)
- && static_cast<QTimerEvent *>(pe.event)->timerId() == timerId) {
- --pe.receiver->d_func()->postedEvents;
- pe.event->posted = false;
- delete pe.event;
- const_cast<QPostEvent &>(pe).event = 0;
- return;
- }
- }
-}
-
#if defined(Q_OS_WIN) && !defined(QT_NO_DEBUG_STREAM)
/*****************************************************************************
Convenience functions for convert WM_* messages into human readable strings,
@@ -617,8 +595,7 @@ QString decodeMSG(const MSG& msg)
if (wmmsg.isEmpty())
wmmsg = QString::fromLatin1("WM_(%1)").arg(msg.message);
- QString rawParameters;
- rawParameters.sprintf("hwnd(0x%p) ", (void *)msg.hwnd);
+ const QString rawParameters = QString::asprintf("hwnd(0x%p) ", (void *)msg.hwnd);
// Custom WM_'s
if (msg.message > WM_APP)
@@ -636,13 +613,13 @@ QString decodeMSG(const MSG& msg)
FLAG_STRING(WA_INACTIVE, "Deactivate"),
FLAG_STRING(WA_CLICKACTIVE, "Activate by mouseclick"),
FLAG_STRING());
- parameters.sprintf("%s Hwnd (0x%p)", activation.toLatin1().data(), (void *)msg.hwnd);
+ parameters = QString::asprintf("%s Hwnd (0x%p)", activation.toLatin1().data(), (void *)msg.hwnd);
}
break;
#endif
#ifdef WM_CAPTURECHANGED
case WM_CAPTURECHANGED:
- parameters.sprintf("Hwnd gaining capture (0x%p)", (void *)lParam);
+ parameters = QString::asprintf("Hwnd gaining capture (0x%p)", (void *)lParam);
break;
#endif
#ifdef WM_CREATE
@@ -754,16 +731,16 @@ QString decodeMSG(const MSG& msg)
windowName = QString((QChar*)lpcs->lpszName,
(int)wcslen(reinterpret_cast<const wchar_t *>(lpcs->lpszName)));
- parameters.sprintf("x,y(%4d,%4d) w,h(%4d,%4d) className(%s) windowName(%s) parent(0x%p) style(%s) exStyle(%s)",
- lpcs->x, lpcs->y, lpcs->cx, lpcs->cy, className.toLatin1().data(),
- windowName.toLatin1().data(), (void *)lpcs->hwndParent,
- styles.toLatin1().data(), exStyles.toLatin1().data());
+ parameters = QString::asprintf("x,y(%4d,%4d) w,h(%4d,%4d) className(%s) windowName(%s) parent(0x%p) style(%s) exStyle(%s)",
+ lpcs->x, lpcs->y, lpcs->cx, lpcs->cy, className.toLatin1().data(),
+ windowName.toLatin1().data(), (void *)lpcs->hwndParent,
+ styles.toLatin1().data(), exStyles.toLatin1().data());
}
break;
#endif
#ifdef WM_DESTROY
case WM_DESTROY:
- parameters.sprintf("Destroy hwnd (0x%p)", (void *)msg.hwnd);
+ parameters = QString::asprintf("Destroy hwnd (0x%p)", (void *)msg.hwnd);
break;
#endif
#ifdef WM_IME_NOTIFY
@@ -784,7 +761,7 @@ QString decodeMSG(const MSG& msg)
FLGSTR(IMN_SETSENTENCEMODE),
FLGSTR(IMN_SETSTATUSWINDOWPOS),
FLAG_STRING());
- parameters.sprintf("Command(%s : 0x%p)", imnCommand.toLatin1().data(), (void *)lParam);
+ parameters = QString::asprintf("Command(%s : 0x%p)", imnCommand.toLatin1().data(), (void *)lParam);
}
break;
#endif
@@ -808,13 +785,13 @@ QString decodeMSG(const MSG& msg)
FLGSTR(ISC_SHOWUICANDIDATEWINDOW << 2),
FLGSTR(ISC_SHOWUICANDIDATEWINDOW << 3),
FLAG_STRING());
- parameters.sprintf("Input context(%s) Show flags(%s)", (fSet? "Active" : "Inactive"), showFlgs.toLatin1().data());
+ parameters = QString::asprintf("Input context(%s) Show flags(%s)", (fSet? "Active" : "Inactive"), showFlgs.toLatin1().data());
}
break;
#endif
#ifdef WM_KILLFOCUS
case WM_KILLFOCUS:
- parameters.sprintf("Hwnd gaining keyboard focus (0x%p)", (void *)wParam);
+ parameters = QString::asprintf("Hwnd gaining keyboard focus (0x%p)", (void *)wParam);
break;
#endif
#ifdef WM_CHAR
@@ -836,8 +813,8 @@ QString decodeMSG(const MSG& msg)
bool contextCode = !!(lKeyData & 0x20000000); // Bit 29
bool prevState = !!(lKeyData & 0x40000000); // Bit 30
bool transState = !!(lKeyData & 0x80000000); // Bit 31
- parameters.sprintf("Virual-key(0x%x) Scancode(%d) Rep(%d) Contextcode(%d), Prev state(%d), Trans state(%d)",
- nVirtKey, scanCode, repCount, contextCode, prevState, transState);
+ parameters = QString::asprintf("Virual-key(0x%x) Scancode(%d) Rep(%d) Contextcode(%d), Prev state(%d), Trans state(%d)",
+ nVirtKey, scanCode, repCount, contextCode, prevState, transState);
}
break;
#endif
@@ -857,7 +834,7 @@ QString decodeMSG(const MSG& msg)
case WM_MOUSEACTIVATE:
{
QString mouseMsg = QString::fromLatin1(findWMstr(HIWORD(lParam)));
- parameters.sprintf("TLW(0x%p) HittestCode(0x%x) MouseMsg(%s)", (void *)wParam, LOWORD(lParam), mouseMsg.toLatin1().data());
+ parameters = QString::asprintf("TLW(0x%p) HittestCode(0x%x) MouseMsg(%s)", (void *)wParam, LOWORD(lParam), mouseMsg.toLatin1().data());
}
break;
#endif
@@ -917,19 +894,19 @@ QString decodeMSG(const MSG& msg)
FLGSTR(MK_XBUTTON2),
#endif
FLAG_STRING());
- parameters.sprintf("x,y(%4d,%4d) Virtual Keys(%s)", GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), vrtKeys.toLatin1().data());
+ parameters = QString::asprintf("x,y(%4d,%4d) Virtual Keys(%s)", GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), vrtKeys.toLatin1().data());
}
break;
#endif
#ifdef WM_MOVE
case WM_MOVE:
- parameters.sprintf("x,y(%4d,%4d)", LOWORD(lParam), HIWORD(lParam));
+ parameters = QString::asprintf("x,y(%4d,%4d)", LOWORD(lParam), HIWORD(lParam));
break;
#endif
#if defined(WM_PAINT) && defined(WM_ERASEBKGND)
case WM_ERASEBKGND:
case WM_PAINT:
- parameters.sprintf("hdc(0x%p)", (void *)wParam);
+ parameters = QString::asprintf("hdc(0x%p)", (void *)wParam);
break;
#endif
#ifdef WM_QUERYNEWPALETTE
@@ -940,18 +917,18 @@ QString decodeMSG(const MSG& msg)
case WM_SETCURSOR:
{
QString mouseMsg = QString::fromLatin1(findWMstr(HIWORD(lParam)));
- parameters.sprintf("HitTestCode(0x%x) MouseMsg(%s)", LOWORD(lParam), mouseMsg.toLatin1().data());
+ parameters = QString::asprintf("HitTestCode(0x%x) MouseMsg(%s)", LOWORD(lParam), mouseMsg.toLatin1().data());
}
break;
#endif
#ifdef WM_SETFOCUS
case WM_SETFOCUS:
- parameters.sprintf("Lost Focus (0x%p)", (void *)wParam);
+ parameters = QString::asprintf("Lost Focus (0x%p)", (void *)wParam);
break;
#endif
#ifdef WM_SETTEXT
case WM_SETTEXT:
- parameters.sprintf("Set Text (%s)", QString((QChar*)lParam, (int)wcslen(reinterpret_cast<const wchar_t *>(lParam))).toLatin1().data()); //Unicode string
+ parameters = QString::asprintf("Set Text (%s)", QString((QChar*)lParam, (int)wcslen(reinterpret_cast<const wchar_t *>(lParam))).toLatin1().data()); //Unicode string
break;
#endif
#ifdef WM_SIZE
@@ -965,7 +942,7 @@ QString decodeMSG(const MSG& msg)
FLGSTR(SIZE_RESTORED),
FLAG_STRING());
- parameters.sprintf("w,h(%4d,%4d) showmode(%s)", LOWORD(lParam), HIWORD(lParam), showMode.toLatin1().data());
+ parameters = QString::asprintf("w,h(%4d,%4d) showmode(%s)", LOWORD(lParam), HIWORD(lParam), showMode.toLatin1().data());
}
break;
#endif
@@ -1002,7 +979,7 @@ QString decodeMSG(const MSG& msg)
FLGSTR(SWP_NOZORDER),
FLGSTR(SWP_SHOWWINDOW),
FLAG_STRING());
- parameters.sprintf("x,y(%4d,%4d) w,h(%4d,%4d) flags(%s) hwndAfter(%s)", winPos->x, winPos->y, winPos->cx, winPos->cy, flags.toLatin1().data(), hwndAfter.toLatin1().data());
+ parameters = QString::asprintf("x,y(%4d,%4d) w,h(%4d,%4d) flags(%s) hwndAfter(%s)", winPos->x, winPos->y, winPos->cx, winPos->cy, flags.toLatin1().data(), hwndAfter.toLatin1().data());
}
break;
#endif
@@ -1020,12 +997,12 @@ QString decodeMSG(const MSG& msg)
FLAG_STRING(ENDSESSION_CRITICAL, "Force application end"),
FLAG_STRING(ENDSESSION_LOGOFF, "User logoff"),
FLAG_STRING());
- parameters.sprintf("End session: %s", logoffOption.toLatin1().data());
+ parameters = QLatin1String("End session: ") + logoffOption;
}
break;
#endif
default:
- parameters.sprintf("wParam(0x%p) lParam(0x%p)", (void *)wParam, (void *)lParam);
+ parameters = QString::asprintf("wParam(0x%p) lParam(0x%p)", (void *)wParam, (void *)lParam);
break;
}
// Yes, we want to give the WM_ names 20 chars of space before showing the
@@ -1041,8 +1018,9 @@ QString decodeMSG(const MSG& msg)
QDebug operator<<(QDebug dbg, const MSG &msg)
{
+ QDebugStateSaver saver(dbg);
dbg << decodeMSG(msg);
- return dbg.nospace();
+ return dbg;
}
#endif
@@ -1050,4 +1028,28 @@ QDebug operator<<(QDebug dbg, const MSG &msg)
#endif // !defined(Q_OS_WINRT)
+#ifndef QT_NO_QOBJECT
+void QCoreApplicationPrivate::removePostedTimerEvent(QObject *object, int timerId)
+{
+ QThreadData *data = object->d_func()->threadData;
+
+ QMutexLocker locker(&data->postEventList.mutex);
+ if (data->postEventList.size() == 0)
+ return;
+ for (int i = 0; i < data->postEventList.size(); ++i) {
+ const QPostEvent &pe = data->postEventList.at(i);
+ if (pe.receiver == object
+ && pe.event
+ && (pe.event->type() == QEvent::Timer || pe.event->type() == QEvent::ZeroTimerEvent)
+ && static_cast<QTimerEvent *>(pe.event)->timerId() == timerId) {
+ --pe.receiver->d_func()->postedEvents;
+ pe.event->posted = false;
+ delete pe.event;
+ const_cast<QPostEvent &>(pe).event = 0;
+ return;
+ }
+ }
+}
+#endif // QT_NO_QOBJECT
+
QT_END_NAMESPACE