diff options
Diffstat (limited to 'src')
27 files changed, 515 insertions, 70 deletions
diff --git a/src/3rdparty/xkbcommon.pri b/src/3rdparty/xkbcommon.pri index d437c6b8b6..21a3e78e1c 100644 --- a/src/3rdparty/xkbcommon.pri +++ b/src/3rdparty/xkbcommon.pri @@ -1,7 +1,7 @@ QMAKE_CFLAGS += -std=gnu99 -w INCLUDEPATH += $$PWD/xkbcommon $$PWD/xkbcommon/src $$PWD/xkbcommon/src/xkbcomp -DEFINES += DFLT_XKB_CONFIG_ROOT='\\"/usr/share/X11/xkb\\"' +DEFINES += DFLT_XKB_CONFIG_ROOT='\\"$$QMAKE_X11_PREFIX/share/X11/xkb\\"' ### RMLVO names can be overwritten with environmental variables (See libxkbcommon documentation) DEFINES += DEFAULT_XKB_RULES='\\"evdev\\"' diff --git a/src/corelib/doc/snippets/code/qlogging/qlogging.cpp b/src/corelib/doc/snippets/code/qlogging/qlogging.cpp index 774610a3c0..d3b9e1fd14 100644 --- a/src/corelib/doc/snippets/code/qlogging/qlogging.cpp +++ b/src/corelib/doc/snippets/code/qlogging/qlogging.cpp @@ -52,3 +52,7 @@ } } //! [1] + +//! [2] + QLoggingCategory &category(); +//! [2] diff --git a/src/corelib/doc/snippets/qloggingcategory/main.cpp b/src/corelib/doc/snippets/qloggingcategory/main.cpp index c1dad7f43a..628243dbdd 100644 --- a/src/corelib/doc/snippets/qloggingcategory/main.cpp +++ b/src/corelib/doc/snippets/qloggingcategory/main.cpp @@ -128,6 +128,27 @@ oldCategoryFilter = QLoggingCategory::installFilter(myCategoryFilter); //![12] } + { +//![13] + QLoggingCategory category("qt.driver.usb"); + qCDebug(category, "a debug message logged into category %s", category.categoryName()); +//![13] + } + + { +//![14] + QLoggingCategory category("qt.driver.usb"); + qCWarning(category, "a warning message logged into category %s", category.categoryName()); +//![14] + } + + { +//![15] + QLoggingCategory category("qt.driver.usb"); + qCCritical(category, "a critical message logged into category %s", category.categoryName()); +//![15] + } + return 0; } diff --git a/src/corelib/global/global.pri b/src/corelib/global/global.pri index fd031469f6..789f500cab 100644 --- a/src/corelib/global/global.pri +++ b/src/corelib/global/global.pri @@ -51,3 +51,9 @@ slog2 { LIBS_PRIVATE += -lslog2 DEFINES += QT_USE_SLOG2 } + +journald { + CONFIG += link_pkgconfig + PKGCONFIG_PRIVATE += libsystemd-journal + DEFINES += QT_USE_JOURNALD +} diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp index 28493311fb..dbe28da120 100644 --- a/src/corelib/global/qlogging.cpp +++ b/src/corelib/global/qlogging.cpp @@ -46,10 +46,10 @@ #include "qvarlengtharray.h" #include "qdebug.h" #include "qmutex.h" +#include "qloggingcategory.h" #ifndef QT_BOOTSTRAPPED #include "qcoreapplication.h" #include "qthread.h" -#include "qloggingcategory.h" #include "private/qloggingregistry_p.h" #endif #ifdef Q_OS_WIN @@ -63,6 +63,11 @@ #include <android/log.h> #endif +#if defined(QT_USE_JOURNALD) && !defined(QT_BOOTSTRAPPED) +# include <systemd/sd-journal.h> +# include <unistd.h> +#endif + #include <stdio.h> QT_BEGIN_NAMESPACE @@ -265,6 +270,74 @@ void QMessageLogger::debug(const char *msg, ...) const qt_message_fatal(QtDebugMsg, context, message); } +/*! + \typedef QMessageLogger::CategoryFunction + + This is a typedef for a pointer to a function with the following + signature: + + \snippet code/qlogging/qlogging.cpp 2 + + A function which this signature is generated by Q_DECLARE_LOGGING_CATEGORY, + Q_LOGGING_CATEGORY. + + \since 5.3 +*/ + +/*! + Logs a debug message specified with format \a msg for the context \a cat. + Additional parameters, specified by \a msg, may be used. + + \since 5.3 + \sa qCDebug() +*/ +void QMessageLogger::debug(const QLoggingCategory &cat, const char *msg, ...) const +{ + if (!cat.isDebugEnabled()) + return; + + QMessageLogContext ctxt; + ctxt.copy(context); + ctxt.category = cat.categoryName(); + + QString message; + + va_list ap; + va_start(ap, msg); // use variable arg list + qt_message(QtDebugMsg, ctxt, msg, ap, message); + va_end(ap); + + if (isFatal(QtDebugMsg)) + qt_message_fatal(QtDebugMsg, ctxt, message); +} + +/*! + Logs a debug message specified with format \a msg for the context returned + by \a catFunc. Additional parameters, specified by \a msg, may be used. + + \since 5.3 + \sa qCDebug() +*/ +void QMessageLogger::debug(QMessageLogger::CategoryFunction catFunc, + const char *msg, ...) const +{ + const QLoggingCategory &cat = (*catFunc)(); + + QMessageLogContext ctxt; + ctxt.copy(context); + ctxt.category = cat.categoryName(); + + QString message; + + va_list ap; + va_start(ap, msg); // use variable arg list + qt_message(QtDebugMsg, ctxt, msg, ap, message); + va_end(ap); + + if (isFatal(QtDebugMsg)) + qt_message_fatal(QtDebugMsg, ctxt, message); +} + #ifndef QT_NO_DEBUG_STREAM /*! @@ -281,6 +354,36 @@ QDebug QMessageLogger::debug() const } /*! + Logs a debug message into category \a cat using a QDebug stream. + + \since 5.3 + \sa qCDebug(), QDebug +*/ +QDebug QMessageLogger::debug(const QLoggingCategory &cat) const +{ + QDebug dbg = QDebug(QtDebugMsg); + if (!cat.isDebugEnabled()) + dbg.stream->message_output = false; + + QMessageLogContext &ctxt = dbg.stream->context; + ctxt.copy(context); + ctxt.category = cat.categoryName(); + + return dbg; +} + +/*! + Logs a debug message into category returned by \a catFunc using a QDebug stream. + + \since 5.3 + \sa qCDebug(), QDebug +*/ +QDebug QMessageLogger::debug(QMessageLogger::CategoryFunction catFunc) const +{ + return debug((*catFunc)()); +} + +/*! \internal Returns a QNoDebug object, which is used to ignore debugging output. @@ -314,9 +417,65 @@ void QMessageLogger::warning(const char *msg, ...) const qt_message_fatal(QtWarningMsg, context, message); } +/*! + Logs a warning message specified with format \a msg for the context \a cat. + Additional parameters, specified by \a msg, may be used. + + \since 5.3 + \sa qCWarning() +*/ +void QMessageLogger::warning(const QLoggingCategory &cat, const char *msg, ...) const +{ + if (!cat.isWarningEnabled()) + return; + + QMessageLogContext ctxt; + ctxt.copy(context); + ctxt.category = cat.categoryName(); + + QString message; + + va_list ap; + va_start(ap, msg); // use variable arg list + qt_message(QtWarningMsg, ctxt, msg, ap, message); + va_end(ap); + + if (isFatal(QtWarningMsg)) + qt_message_fatal(QtWarningMsg, ctxt, message); +} + +/*! + Logs a warning message specified with format \a msg for the context returned + by \a catFunc. Additional parameters, specified by \a msg, may be used. + + \since 5.3 + \sa qCWarning() +*/ +void QMessageLogger::warning(QMessageLogger::CategoryFunction catFunc, + const char *msg, ...) const +{ + const QLoggingCategory &cat = (*catFunc)(); + if (!cat.isWarningEnabled()) + return; + + QMessageLogContext ctxt; + ctxt.copy(context); + ctxt.category = cat.categoryName(); + + QString message; + + va_list ap; + va_start(ap, msg); // use variable arg list + qt_message(QtWarningMsg, ctxt, msg, ap, message); + va_end(ap); + + if (isFatal(QtWarningMsg)) + qt_message_fatal(QtWarningMsg, ctxt, message); +} + #ifndef QT_NO_DEBUG_STREAM /*! - Logs a debug message using a QDebug stream + Logs a warning message using a QDebug stream \sa qWarning(), QDebug */ @@ -327,6 +486,36 @@ QDebug QMessageLogger::warning() const ctxt.copy(context); return dbg; } + +/*! + Logs a warning message into category \a cat using a QDebug stream. + + \sa qCWarning(), QDebug +*/ +QDebug QMessageLogger::warning(const QLoggingCategory &cat) const +{ + QDebug dbg = QDebug(QtWarningMsg); + if (!cat.isWarningEnabled()) + dbg.stream->message_output = false; + + QMessageLogContext &ctxt = dbg.stream->context; + ctxt.copy(context); + ctxt.category = cat.categoryName(); + + return dbg; +} + +/*! + Logs a warning message into category returned by \a catFunc using a QDebug stream. + + \since 5.3 + \sa qCWarning(), QDebug +*/ +QDebug QMessageLogger::warning(QMessageLogger::CategoryFunction catFunc) const +{ + return warning((*catFunc)()); +} + #endif #undef qCritical @@ -350,6 +539,62 @@ void QMessageLogger::critical(const char *msg, ...) const qt_message_fatal(QtCriticalMsg, context, message); } +/*! + Logs a critical message specified with format \a msg for the context \a cat. + Additional parameters, specified by \a msg, may be used. + + \since 5.3 + \sa qCCritical() +*/ +void QMessageLogger::critical(const QLoggingCategory &cat, const char *msg, ...) const +{ + if (!cat.isCriticalEnabled()) + return; + + QMessageLogContext ctxt; + ctxt.copy(context); + ctxt.category = cat.categoryName(); + + QString message; + + va_list ap; + va_start(ap, msg); // use variable arg list + qt_message(QtCriticalMsg, ctxt, msg, ap, message); + va_end(ap); + + if (isFatal(QtCriticalMsg)) + qt_message_fatal(QtCriticalMsg, ctxt, message); +} + +/*! + Logs a critical message specified with format \a msg for the context returned + by \a catFunc. Additional parameters, specified by \a msg, may be used. + + \since 5.3 + \sa qCCritical() +*/ +void QMessageLogger::critical(QMessageLogger::CategoryFunction catFunc, + const char *msg, ...) const +{ + const QLoggingCategory &cat = (*catFunc)(); + if (!cat.isCriticalEnabled()) + return; + + QMessageLogContext ctxt; + ctxt.copy(context); + ctxt.category = cat.categoryName(); + + QString message; + + va_list ap; + va_start(ap, msg); // use variable arg list + qt_message(QtCriticalMsg, ctxt, msg, ap, message); + va_end(ap); + + if (isFatal(QtCriticalMsg)) + qt_message_fatal(QtCriticalMsg, ctxt, message); +} + #ifndef QT_NO_DEBUG_STREAM /*! Logs a critical message using a QDebug stream @@ -363,6 +608,37 @@ QDebug QMessageLogger::critical() const ctxt.copy(context); return dbg; } + +/*! + Logs a critical message into category \a cat using a QDebug stream. + + \since 5.3 + \sa qCCritical(), QDebug +*/ +QDebug QMessageLogger::critical(const QLoggingCategory &cat) const +{ + QDebug dbg = QDebug(QtCriticalMsg); + if (!cat.isCriticalEnabled()) + dbg.stream->message_output = false; + + QMessageLogContext &ctxt = dbg.stream->context; + ctxt.copy(context); + ctxt.category = cat.categoryName(); + + return dbg; +} + +/*! + Logs a critical message into category returned by \a catFunc using a QDebug stream. + + \since 5.3 + \sa qCCritical(), QDebug +*/ +QDebug QMessageLogger::critical(QMessageLogger::CategoryFunction catFunc) const +{ + return critical((*catFunc)()); +} + #endif #undef qFatal @@ -866,6 +1142,37 @@ Q_CORE_EXPORT QtMsgHandler qInstallMsgHandler(QtMsgHandler); static QtMsgHandler msgHandler = 0; // pointer to debug handler (without context) static QtMessageHandler messageHandler = 0; // pointer to debug handler (with context) +#if defined(QT_USE_JOURNALD) && !defined(QT_BOOTSTRAPPED) +static void systemd_default_message_handler(QtMsgType type, + const QMessageLogContext &context, + const QString &message) +{ + int priority = LOG_INFO; // Informational + switch (type) { + case QtDebugMsg: + priority = LOG_DEBUG; // Debug-level messages + break; + case QtWarningMsg: + priority = LOG_WARNING; // Warning conditions + break; + case QtCriticalMsg: + priority = LOG_CRIT; // Critical conditions + break; + case QtFatalMsg: + priority = LOG_ALERT; // Action must be taken immediately + break; + } + + char filebuf[PATH_MAX + sizeof("CODE_FILE=")]; + snprintf(filebuf, sizeof(filebuf), "CODE_FILE=%s", context.file ? context.file : "unknown"); + + char linebuf[20]; + snprintf(linebuf, sizeof(linebuf), "CODE_LINE=%d", context.line); + + sd_journal_print_with_location(priority, filebuf, linebuf, context.function ? context.function : "unknown", "%s", message.toUtf8().constData()); +} +#endif + #ifdef Q_OS_ANDROID static void android_default_message_handler(QtMsgType type, const QMessageLogContext &context, @@ -902,6 +1209,18 @@ static void qDefaultMessageHandler(QtMsgType type, const QMessageLogContext &con #if defined(QT_USE_SLOG2) slog2_default_handler(type, logMessage.toLocal8Bit().constData()); +#elif defined(QT_USE_JOURNALD) && !defined(QT_BOOTSTRAPPED) + // We use isatty to catch the obvious case of someone running something interactively. + // We also support an environment variable for Qt Creator use, or more complicated cases like subprocesses. + static bool logToConsole = isatty(fileno(stdin)) || !qEnvironmentVariableIsEmpty("QT_NO_JOURNALD_LOG"); + if (Q_LIKELY(!logToConsole)) { + // remove trailing \n, systemd appears to want them newline-less + logMessage.chop(1); + systemd_default_message_handler(type, context, logMessage); + } else { + fprintf(stderr, "%s", logMessage.toUtf8().constData()); + fflush(stderr); + } #elif defined(Q_OS_ANDROID) static bool logToAndroid = qEnvironmentVariableIsEmpty("QT_ANDROID_PLAIN_LOG"); if (logToAndroid) { diff --git a/src/corelib/global/qlogging.h b/src/corelib/global/qlogging.h index 5ae1fb3205..6d651ee8a0 100644 --- a/src/corelib/global/qlogging.h +++ b/src/corelib/global/qlogging.h @@ -82,6 +82,8 @@ private: friend class QDebug; }; +class QLoggingCategory; + class Q_CORE_EXPORT QMessageLogger { Q_DISABLE_COPY(QMessageLogger) @@ -98,6 +100,15 @@ public: void warning(const char *msg, ...) const Q_ATTRIBUTE_FORMAT_PRINTF(2, 3); void critical(const char *msg, ...) const Q_ATTRIBUTE_FORMAT_PRINTF(2, 3); + typedef QLoggingCategory &(*CategoryFunction)(); + + void debug(const QLoggingCategory &cat, const char *msg, ...) const Q_ATTRIBUTE_FORMAT_PRINTF(3, 4); + void debug(CategoryFunction catFunc, const char *msg, ...) const Q_ATTRIBUTE_FORMAT_PRINTF(3, 4); + void warning(const QLoggingCategory &cat, const char *msg, ...) const Q_ATTRIBUTE_FORMAT_PRINTF(3, 4); + void warning(CategoryFunction catFunc, const char *msg, ...) const Q_ATTRIBUTE_FORMAT_PRINTF(3, 4); + void critical(const QLoggingCategory &cat, const char *msg, ...) const Q_ATTRIBUTE_FORMAT_PRINTF(3, 4); + void critical(CategoryFunction catFunc, const char *msg, ...) const Q_ATTRIBUTE_FORMAT_PRINTF(3, 4); + #ifndef Q_CC_MSVC Q_NORETURN #endif @@ -105,8 +116,14 @@ public: #ifndef QT_NO_DEBUG_STREAM QDebug debug() const; + QDebug debug(const QLoggingCategory &cat) const; + QDebug debug(CategoryFunction catFunc) const; QDebug warning() const; + QDebug warning(const QLoggingCategory &cat) const; + QDebug warning(CategoryFunction catFunc) const; QDebug critical() const; + QDebug critical(const QLoggingCategory &cat) const; + QDebug critical(CategoryFunction catFunc) const; QNoDebug noDebug() const Q_DECL_NOTHROW; #endif // QT_NO_DEBUG_STREAM diff --git a/src/corelib/io/qloggingcategory.cpp b/src/corelib/io/qloggingcategory.cpp index 93a98b1835..8c3ca5fd65 100644 --- a/src/corelib/io/qloggingcategory.cpp +++ b/src/corelib/io/qloggingcategory.cpp @@ -326,6 +326,25 @@ void QLoggingCategory::setFilterRules(const QString &rules) */ /*! + \macro qCDebug(category, const char *message, ...) + \relates QLoggingCategory + \since 5.3 + + Logs a debug message \a message in the logging category \a category. + \a message might contain place holders that are replaced by additional + arguments, similar to the C printf() function. + + Example: + + \snippet qloggingcategory/main.cpp 13 + + \note Arguments might not be processed if debug output for the category is + not enabled, so do not rely on any side effects. + + \sa qDebug() +*/ + +/*! \macro qCWarning(category) \relates QLoggingCategory \since 5.2 @@ -348,6 +367,25 @@ void QLoggingCategory::setFilterRules(const QString &rules) */ /*! + \macro qCWarning(category, const char *message, ...) + \relates QLoggingCategory + \since 5.3 + + Logs a warning message \a message in the logging category \a category. + \a message might contain place holders that are replaced by additional + arguments, similar to the C printf() function. + + Example: + + \snippet qloggingcategory/main.cpp 14 + + \note Arguments might not be processed if warning output for the category is + not enabled, so do not rely on any side effects. + + \sa qWarning() +*/ + +/*! \macro qCCritical(category) \relates QLoggingCategory \since 5.2 @@ -370,6 +408,24 @@ void QLoggingCategory::setFilterRules(const QString &rules) */ /*! + \macro qCCritical(category, const char *message, ...) + \relates QLoggingCategory + \since 5.3 + + Logs a critical message \a message in the logging category \a category. + \a message might contain place holders that are replaced by additional + arguments, similar to the C printf() function. + + Example: + + \snippet qloggingcategory/main.cpp 15 + + \note Arguments might not be processed if critical output for the category + is not enabled, so do not rely on any side effects. + + \sa qCritical() +*/ +/*! \macro Q_DECLARE_LOGGING_CATEGORY(name) \relates QLoggingCategory \since 5.2 diff --git a/src/corelib/io/qloggingcategory.h b/src/corelib/io/qloggingcategory.h index 15c0519827..1e8823e92b 100644 --- a/src/corelib/io/qloggingcategory.h +++ b/src/corelib/io/qloggingcategory.h @@ -94,15 +94,26 @@ private: return category; \ } -#define qCDebug(category) \ +#ifdef Q_COMPILER_VARIADIC_MACROS + +#define qCDebug(category, ...) \ for (bool enabled = category().isDebugEnabled(); Q_UNLIKELY(enabled); enabled = false) \ - QMessageLogger(__FILE__, __LINE__, Q_FUNC_INFO, category().categoryName()).debug() -#define qCWarning(category) \ + QMessageLogger(__FILE__, __LINE__, Q_FUNC_INFO, category().categoryName()).debug(__VA_ARGS__) +#define qCWarning(category, ...) \ for (bool enabled = category().isWarningEnabled(); enabled; enabled = false) \ - QMessageLogger(__FILE__, __LINE__, Q_FUNC_INFO, category().categoryName()).warning() -#define qCCritical(category) \ + QMessageLogger(__FILE__, __LINE__, Q_FUNC_INFO, category().categoryName()).warning(__VA_ARGS__) +#define qCCritical(category, ...) \ for (bool enabled = category().isCriticalEnabled(); enabled; enabled = false) \ - QMessageLogger(__FILE__, __LINE__, Q_FUNC_INFO, category().categoryName()).critical() + QMessageLogger(__FILE__, __LINE__, Q_FUNC_INFO, category().categoryName()).critical(__VA_ARGS__) + +#else + +// check for enabled category inside QMessageLogger. +#define qCDebug qDebug +#define qCWarning qWarning +#define qCCritical qCritical + +#endif // Q_COMPILER_VARIADIC_MACROS #if defined(QT_NO_DEBUG_OUTPUT) # undef qCDebug diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 2dd56423ac..68bec5472f 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -2628,10 +2628,12 @@ void QCoreApplication::setEventDispatcher(QAbstractEventDispatcher *eventDispatc \fn void qAddPostRoutine(QtCleanUpFunction ptr) \relates QCoreApplication - Adds a global routine that will be called from the QApplication + Adds a global routine that will be called from the QCoreApplication destructor. This function is normally used to add cleanup routines for program-wide functionality. + The cleanup routines are called in the reverse order of their addition. + The function specified by \a ptr should take no arguments and should return nothing. For example: @@ -2640,8 +2642,11 @@ void QCoreApplication::setEventDispatcher(QAbstractEventDispatcher *eventDispatc Note that for an application- or module-wide cleanup, qAddPostRoutine() is often not suitable. For example, if the program is split into dynamically loaded modules, the relevant - module may be unloaded long before the QApplication destructor is - called. + module may be unloaded long before the QCoreApplication destructor is + called. In such cases, if using qAddPostRoutine() is still desirable, + qRemovePostRoutine() can be used to prevent a routine from being + called by the QCoreApplication destructor. For example, if that + routine was called before the module was unloaded. For modules and libraries, using a reference-counted initialization manager or Qt's parent-child deletion mechanism may @@ -2653,6 +2658,21 @@ void QCoreApplication::setEventDispatcher(QAbstractEventDispatcher *eventDispatc By selecting the right parent object, this can often be made to clean up the module's data at the right moment. + + \sa qRemovePostRoutine() +*/ + +/*! + \fn void qRemovePostRoutine(QtCleanUpFunction ptr) + \relates QCoreApplication + \since 5.3 + + Removes the cleanup routine specified by \a ptr from the list of + routines called by the QCoreApplication destructor. The routine + must have been previously added to the list by a call to + qAddPostRoutine(), otherwise this function has no effect. + + \sa qAddPostRoutine() */ /*! diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp index e7a53c0790..6d2cba7703 100644 --- a/src/corelib/tools/qdatetime.cpp +++ b/src/corelib/tools/qdatetime.cpp @@ -2204,6 +2204,11 @@ static int qt_timezone() long offset; _get_timezone(&offset); return offset; +#elif defined(Q_OS_BSD4) && !defined(Q_OS_DARWIN) + time_t clock = time(NULL); + struct tm t; + localtime_r(&clock, &t); + return t.tm_gmtoff; #else return timezone; #endif // Q_OS_WIN diff --git a/src/network/ssl/qsslconfiguration.cpp b/src/network/ssl/qsslconfiguration.cpp index 4aad7c04c5..3d7656262b 100644 --- a/src/network/ssl/qsslconfiguration.cpp +++ b/src/network/ssl/qsslconfiguration.cpp @@ -663,7 +663,7 @@ int QSslConfiguration::sessionTicketLifeTimeHint() const \li protocol SecureProtocols (meaning either TLS 1.0 or SSL 3 will be used) \li the system's default CA certificate list \li the cipher list equal to the list of the SSL libraries' - supported SSL ciphers + supported SSL ciphers that are 128 bits or more \endlist \sa QSslSocket::supportedCiphers(), setDefaultConfiguration() diff --git a/src/network/ssl/qsslsocket.cpp b/src/network/ssl/qsslsocket.cpp index 38b493a769..0f934fa5d6 100644 --- a/src/network/ssl/qsslsocket.cpp +++ b/src/network/ssl/qsslsocket.cpp @@ -1953,6 +1953,7 @@ void QSslSocketPrivate::init() */ QList<QSslCipher> QSslSocketPrivate::defaultCiphers() { + QSslSocketPrivate::ensureInitialized(); QMutexLocker locker(&globalData()->mutex); return globalData()->config->ciphers; } diff --git a/src/network/ssl/qsslsocket_openssl.cpp b/src/network/ssl/qsslsocket_openssl.cpp index 69b9e53884..ce6b6562b9 100644 --- a/src/network/ssl/qsslsocket_openssl.cpp +++ b/src/network/ssl/qsslsocket_openssl.cpp @@ -596,6 +596,7 @@ void QSslSocketPrivate::resetDefaultCiphers() SSL *mySsl = q_SSL_new(myCtx); QList<QSslCipher> ciphers; + QList<QSslCipher> defaultCiphers; STACK_OF(SSL_CIPHER) *supportedCiphers = q_SSL_get_ciphers(mySsl); for (int i = 0; i < q_sk_SSL_CIPHER_num(supportedCiphers); ++i) { @@ -603,8 +604,11 @@ void QSslSocketPrivate::resetDefaultCiphers() if (cipher->valid) { QSslCipher ciph = QSslSocketBackendPrivate::QSslCipher_from_SSL_CIPHER(cipher); if (!ciph.isNull()) { + // Unconditionally exclude ADH ciphers since they offer no MITM protection if (!ciph.name().toLower().startsWith(QLatin1String("adh"))) ciphers << ciph; + if (ciph.usedBits() >= 128) + defaultCiphers << ciph; } } } @@ -614,7 +618,7 @@ void QSslSocketPrivate::resetDefaultCiphers() q_SSL_free(mySsl); setDefaultSupportedCiphers(ciphers); - setDefaultCiphers(ciphers); + setDefaultCiphers(defaultCiphers); } QList<QSslCertificate> QSslSocketPrivate::systemCaCertificates() diff --git a/src/plugins/platforminputcontexts/compose/compose.pro b/src/plugins/platforminputcontexts/compose/compose.pro index 2490a4ffbe..c206e99e57 100644 --- a/src/plugins/platforminputcontexts/compose/compose.pro +++ b/src/plugins/platforminputcontexts/compose/compose.pro @@ -8,6 +8,7 @@ QT += gui-private LIBS += $$QMAKE_LIBS_XKBCOMMON QMAKE_CXXFLAGS += $$QMAKE_CFLAGS_XKBCOMMON +DEFINES += COMPOSE_X11_PREFIX='\\"$$QMAKE_X11_PREFIX\\"' SOURCES += $$PWD/main.cpp \ $$PWD/qcomposeplatforminputcontext.cpp \ diff --git a/src/plugins/platforminputcontexts/compose/generator/qtablegenerator.cpp b/src/plugins/platforminputcontexts/compose/generator/qtablegenerator.cpp index 692372c3a9..121e734ec1 100644 --- a/src/plugins/platforminputcontexts/compose/generator/qtablegenerator.cpp +++ b/src/plugins/platforminputcontexts/compose/generator/qtablegenerator.cpp @@ -73,17 +73,13 @@ TableGenerator::TableGenerator() : m_state(NoErrors), void TableGenerator::initPossibleLocations() { - // AFAICT there is no way to know the exact location - // of the compose files. It depends on how Xlib was configured - // on a specific platform. During the "./configure" process - // xlib generates a config.h file which contains a bunch of defines, - // including XLOCALEDIR which points to the location of the compose file dir. // To add an extra system path use the QTCOMPOSE environment variable if (qEnvironmentVariableIsSet("QTCOMPOSE")) { m_possibleLocations.append(QString(qgetenv("QTCOMPOSE"))); } - m_possibleLocations.append(QStringLiteral("/usr/share/X11/locale")); - m_possibleLocations.append(QStringLiteral("/usr/lib/X11/locale")); + + m_possibleLocations.append(QStringLiteral(COMPOSE_X11_PREFIX "/share/X11/locale")); + m_possibleLocations.append(QStringLiteral(COMPOSE_X11_PREFIX "/lib/X11/locale")); } void TableGenerator::findComposeFile() diff --git a/src/plugins/platforms/android/qandroidplatformopenglwindow.cpp b/src/plugins/platforms/android/qandroidplatformopenglwindow.cpp index 498f59be88..86d8bf9d1b 100644 --- a/src/plugins/platforms/android/qandroidplatformopenglwindow.cpp +++ b/src/plugins/platforms/android/qandroidplatformopenglwindow.cpp @@ -51,9 +51,6 @@ #include <android/native_window.h> #include <android/native_window_jni.h> -#warning remove me -#include <QDebug> - QT_BEGIN_NAMESPACE QAndroidPlatformOpenGLWindow::QAndroidPlatformOpenGLWindow(QWindow *window, EGLDisplay display) @@ -80,7 +77,6 @@ void QAndroidPlatformOpenGLWindow::setGeometry(const QRect &rect) if (rect == geometry()) return; - qDebug() << rect; QAndroidPlatformWindow::setGeometry(rect); QtAndroid::setSurfaceGeometry(m_nativeSurfaceId, rect); } @@ -99,7 +95,6 @@ EGLSurface QAndroidPlatformOpenGLWindow::eglSurface(EGLConfig config) void QAndroidPlatformOpenGLWindow::checkNativeSurface(EGLConfig config) { QMutexLocker lock(&m_surfaceMutex); - qDebug() << geometry() << m_changedAndroidSurface.isValid(); if (m_nativeSurfaceId == -1 || !m_changedAndroidSurface.isValid()) return; @@ -147,7 +142,6 @@ void QAndroidPlatformOpenGLWindow::surfaceChanged(JNIEnv *jniEnv, jobject surfac Q_UNUSED(jniEnv); Q_UNUSED(w); Q_UNUSED(h); - qDebug() << w << h; lockSurface(); m_changedAndroidSurface = surface; m_surfaceWaitCondition.wakeOne(); diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp index 0cff92dacc..030090d98d 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection.cpp @@ -1154,6 +1154,7 @@ void QXcbConnection::processXcbEvents() xcb_generic_event_t *event = eventqueue->at(i); if (!event) continue; + QScopedPointer<xcb_generic_event_t, QScopedPointerPodDeleter> eventGuard(event); (*eventqueue)[i] = 0; uint response_type = event->response_type & ~0x80; @@ -1204,8 +1205,6 @@ void QXcbConnection::processXcbEvents() handleXcbEvent(event); m_reader->lock(); } - - free(event); } eventqueue->clear(); diff --git a/src/testlib/qabstracttestlogger_p.h b/src/testlib/qabstracttestlogger_p.h index c471717655..c549233ddb 100644 --- a/src/testlib/qabstracttestlogger_p.h +++ b/src/testlib/qabstracttestlogger_p.h @@ -94,7 +94,7 @@ public: const char *file = 0, int line = 0) = 0; virtual void addBenchmarkResult(const QBenchmarkResult &result) = 0; - virtual void addMessage(MessageTypes type, const char *message, + virtual void addMessage(MessageTypes type, const QString &message, const char *file = 0, int line = 0) = 0; void outputString(const char *msg); diff --git a/src/testlib/qplaintestlogger.cpp b/src/testlib/qplaintestlogger.cpp index 3f65dc0a6e..39580f22d4 100644 --- a/src/testlib/qplaintestlogger.cpp +++ b/src/testlib/qplaintestlogger.cpp @@ -389,14 +389,14 @@ void QPlainTestLogger::addBenchmarkResult(const QBenchmarkResult &result) printBenchmarkResult(result); } -void QPlainTestLogger::addMessage(MessageTypes type, const char *message, +void QPlainTestLogger::addMessage(MessageTypes type, const QString &message, const char *file, int line) { // suppress non-fatal messages in silent mode if (type != QAbstractTestLogger::QFatal && QTestLog::verboseLevel() < 0) return; - printMessage(QTest::messageType2String(type), message, file, line); + printMessage(QTest::messageType2String(type), qPrintable(message), file, line); } QT_END_NAMESPACE diff --git a/src/testlib/qplaintestlogger_p.h b/src/testlib/qplaintestlogger_p.h index 8aa0d745e9..69dbc89649 100644 --- a/src/testlib/qplaintestlogger_p.h +++ b/src/testlib/qplaintestlogger_p.h @@ -73,7 +73,7 @@ public: const char *file = 0, int line = 0); void addBenchmarkResult(const QBenchmarkResult &result); - void addMessage(MessageTypes type, const char *message, + void addMessage(MessageTypes type, const QString &message, const char *file = 0, int line = 0); private: diff --git a/src/testlib/qtestlog.cpp b/src/testlib/qtestlog.cpp index 037bed643d..74947b3f3a 100644 --- a/src/testlib/qtestlog.cpp +++ b/src/testlib/qtestlog.cpp @@ -209,7 +209,7 @@ namespace QTest { FOREACH_LOGGER(logger->addBenchmarkResult(result)); } - static void addMessage(QAbstractTestLogger::MessageTypes type, const char *message, + static void addMessage(QAbstractTestLogger::MessageTypes type, const QString &message, const char *file = 0, int line = 0) { FOREACH_LOGGER(logger->addMessage(type, message, file, line)); @@ -242,11 +242,10 @@ namespace QTest { static QtMessageHandler oldMessageHandler; - static bool handleIgnoredMessage(QtMsgType type, const char *msg) + static bool handleIgnoredMessage(QtMsgType type, const QString &message) { if (!ignoreResultList) return false; - const QString message = QString::fromLocal8Bit(msg); IgnoreResultList *last = 0; IgnoreResultList *list = ignoreResultList; while (list) { @@ -279,12 +278,11 @@ namespace QTest { QTEST_ASSERT(QTest::TestLoggers::loggerCount() != 0); } - QByteArray msg = message.toLocal8Bit(); - if (handleIgnoredMessage(type, msg)) + if (handleIgnoredMessage(type, message)) // the message is expected, so just swallow it. return; - msg = qMessageFormatString(type, context, message).toLocal8Bit(); + QString msg = qMessageFormatString(type, context, message); msg.chop(1); // remove trailing newline if (type != QtFatalMsg) { @@ -293,7 +291,7 @@ namespace QTest { if (!counter.deref()) { QTest::TestLoggers::addMessage(QAbstractTestLogger::QSystem, - "Maximum amount of warnings exceeded. Use -maxwarnings to override."); + QStringLiteral("Maximum amount of warnings exceeded. Use -maxwarnings to override.")); return; } } @@ -354,15 +352,15 @@ void QTestLog::leaveTestFunction() void QTestLog::printUnhandledIgnoreMessages() { - char msg[1024]; + QString message; QTest::IgnoreResultList *list = QTest::ignoreResultList; while (list) { if (list->pattern.type() == QVariant::String) { - qsnprintf(msg, 1024, "Did not receive message: \"%s\"", qPrintable(list->pattern.toString())); + message = QStringLiteral("Did not receive message: \"") + list->pattern.toString() + QLatin1Char('"'); } else { - qsnprintf(msg, 1024, "Did not receive any message matching: \"%s\"", qPrintable(list->pattern.toRegularExpression().pattern())); + message = QStringLiteral("Did not receive any message matching: \"") + list->pattern.toRegularExpression().pattern() + QLatin1Char('"'); } - QTest::TestLoggers::addMessage(QAbstractTestLogger::Info, msg); + QTest::TestLoggers::addMessage(QAbstractTestLogger::Info, message); list = list->next; } @@ -419,7 +417,7 @@ void QTestLog::addSkip(const char *msg, const char *file, int line) ++QTest::skips; - QTest::TestLoggers::addMessage(QAbstractTestLogger::Skip, msg, file, line); + QTest::TestLoggers::addMessage(QAbstractTestLogger::Skip, QString::fromUtf8(msg), file, line); } void QTestLog::addBenchmarkResult(const QBenchmarkResult &result) @@ -483,14 +481,14 @@ void QTestLog::warn(const char *msg, const char *file, int line) QTEST_ASSERT(msg); if (QTest::TestLoggers::loggerCount() > 0) - QTest::TestLoggers::addMessage(QAbstractTestLogger::Warn, msg, file, line); + QTest::TestLoggers::addMessage(QAbstractTestLogger::Warn, QString::fromUtf8(msg), file, line); } void QTestLog::info(const char *msg, const char *file, int line) { QTEST_ASSERT(msg); - QTest::TestLoggers::addMessage(QAbstractTestLogger::Info, msg, file, line); + QTest::TestLoggers::addMessage(QAbstractTestLogger::Info, QString::fromUtf8(msg), file, line); } void QTestLog::setVerboseLevel(int level) diff --git a/src/testlib/qxmltestlogger.cpp b/src/testlib/qxmltestlogger.cpp index b4035301d3..3fff753c5c 100644 --- a/src/testlib/qxmltestlogger.cpp +++ b/src/testlib/qxmltestlogger.cpp @@ -271,7 +271,7 @@ void QXmlTestLogger::addBenchmarkResult(const QBenchmarkResult &result) outputString(buf.constData()); } -void QXmlTestLogger::addMessage(MessageTypes type, const char *message, +void QXmlTestLogger::addMessage(MessageTypes type, const QString &message, const char *file, int line) { QTestCharBuffer buf; @@ -288,10 +288,10 @@ void QXmlTestLogger::addMessage(MessageTypes type, const char *message, xmlQuote("edFile, file); xmlCdata(&cdataGtag, gtag); xmlCdata(&cdataTag, tag); - xmlCdata(&cdataDescription, message); + xmlCdata(&cdataDescription, message.toUtf8().constData()); QTest::qt_asprintf(&buf, - QTest::messageFormatString(QTest::isEmpty(message), notag), + QTest::messageFormatString(message.isEmpty(), notag), QTest::xmlMessageType2String(type), quotedFile.constData(), line, cdataGtag.constData(), diff --git a/src/testlib/qxmltestlogger_p.h b/src/testlib/qxmltestlogger_p.h index 65699af3ad..8ca15e47e2 100644 --- a/src/testlib/qxmltestlogger_p.h +++ b/src/testlib/qxmltestlogger_p.h @@ -77,7 +77,7 @@ public: const char *file = 0, int line = 0); void addBenchmarkResult(const QBenchmarkResult &result); - void addMessage(MessageTypes type, const char *message, + void addMessage(MessageTypes type, const QString &message, const char *file = 0, int line = 0); static int xmlCdata(QTestCharBuffer *dest, char const* src); diff --git a/src/testlib/qxunittestlogger.cpp b/src/testlib/qxunittestlogger.cpp index 0a1a5fb6f9..a47f77ae49 100644 --- a/src/testlib/qxunittestlogger.cpp +++ b/src/testlib/qxunittestlogger.cpp @@ -220,7 +220,7 @@ void QXunitTestLogger::addIncident(IncidentTypes type, const char *description, have some information about the expected failure. */ if (type == QAbstractTestLogger::XFail) { - QXunitTestLogger::addMessage(QAbstractTestLogger::Info, description, file, line); + QXunitTestLogger::addMessage(QAbstractTestLogger::Info, QString::fromUtf8(description), file, line); } } @@ -263,7 +263,7 @@ void QXunitTestLogger::addTag(QTestElement* element) element->addAttribute(QTest::AI_Tag, buf.constData()); } -void QXunitTestLogger::addMessage(MessageTypes type, const char *message, const char *file, int line) +void QXunitTestLogger::addMessage(MessageTypes type, const QString &message, const char *file, int line) { QTestElement *errorElement = new QTestElement(QTest::LET_Error); const char *typeBuf = 0; @@ -296,7 +296,7 @@ void QXunitTestLogger::addMessage(MessageTypes type, const char *message, const } errorElement->addAttribute(QTest::AI_Type, typeBuf); - errorElement->addAttribute(QTest::AI_Description, message); + errorElement->addAttribute(QTest::AI_Description, message.toUtf8().constData()); addTag(errorElement); if (file) @@ -314,7 +314,7 @@ void QXunitTestLogger::addMessage(MessageTypes type, const char *message, const // Also add the message to the system error log (i.e. stderr), if one exists if (errorLogElement) { QTestElement *systemErrorElement = new QTestElement(QTest::LET_Error); - systemErrorElement->addAttribute(QTest::AI_Description, message); + systemErrorElement->addAttribute(QTest::AI_Description, message.toUtf8().constData()); errorLogElement->addLogElement(systemErrorElement); } } diff --git a/src/testlib/qxunittestlogger_p.h b/src/testlib/qxunittestlogger_p.h index 2c39fa952c..754462473a 100644 --- a/src/testlib/qxunittestlogger_p.h +++ b/src/testlib/qxunittestlogger_p.h @@ -77,7 +77,7 @@ class QXunitTestLogger : public QAbstractTestLogger void addBenchmarkResult(const QBenchmarkResult &result); void addTag(QTestElement* element); - void addMessage(MessageTypes type, const char *message, + void addMessage(MessageTypes type, const QString &message, const char *file = 0, int line = 0); private: diff --git a/src/tools/moc/generator.cpp b/src/tools/moc/generator.cpp index 3546d2e395..2d48c50c83 100644 --- a/src/tools/moc/generator.cpp +++ b/src/tools/moc/generator.cpp @@ -244,7 +244,7 @@ void Generator::generateCode() int len = 0; for (int i = 0; i < strings.size(); ++i) len += strings.at(i).length() + 1; - fprintf(out, " char stringdata[%d];\n", len + 1); + fprintf(out, " char stringdata[%d];\n", len); } fprintf(out, "};\n"); @@ -316,7 +316,8 @@ void Generator::generateCode() col += spanLen; } - fputs("\\0", out); + if (i != strings.size() - 1) // skip the last \0 the c++ will add it for us + fputs("\\0", out); col += len + 2; } @@ -637,12 +638,6 @@ void Generator::generateFunctions(const QList<FunctionDef>& list, const char *fu flags |= AccessPublic; else if (f.access == FunctionDef::Protected) flags |= AccessProtected; - if (f.access == FunctionDef::Private) - flags |= AccessPrivate; - else if (f.access == FunctionDef::Public) - flags |= AccessPublic; - else if (f.access == FunctionDef::Protected) - flags |= AccessProtected; if (f.isCompat) flags |= MethodCompatibility; if (f.wasCloned) diff --git a/src/widgets/styles/qwindowsvistastyle.cpp b/src/widgets/styles/qwindowsvistastyle.cpp index 2f36944b5e..de819e95db 100644 --- a/src/widgets/styles/qwindowsvistastyle.cpp +++ b/src/widgets/styles/qwindowsvistastyle.cpp @@ -1340,11 +1340,9 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption painter->setPen(menuitem->palette.buttonText().color()); - QColor discol; - if (dis) { - discol = menuitem->palette.text().color(); - painter->setPen(discol); - } + const QColor textColor = menuitem->palette.text().color(); + if (dis) + painter->setPen(textColor); int xm = windowsItemFrame + checkcol + windowsItemHMargin; int xpos = menuitem->rect.x() + xm; @@ -1368,7 +1366,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption if (menuitem->menuItemType == QStyleOptionMenuItem::DefaultItem) font.setBold(true); painter->setFont(font); - painter->setPen(discol); + painter->setPen(textColor); painter->drawText(vTextRect, text_flags, s.left(t)); painter->restore(); } |