Merge remote-tracking branch 'origin/5.10.1' into 5.10

Change-Id: Ibbe355f5e8ef12e5ffeb4e33b6a80760c3e2b464
This commit is contained in:
Liang Qi 2018-02-01 19:44:11 +01:00
commit 15ae794966
8 changed files with 74 additions and 39 deletions

View File

@ -44,6 +44,7 @@
#include <QtCore/qstandardpaths.h>
#include <QtCore/qtextstream.h>
#include <QtCore/qdir.h>
#include <QtCore/qcoreapplication.h>
// We can't use the default macros because this would lead to recursion.
// Instead let's define our own one that unconditionally logs...
@ -255,6 +256,15 @@ void QLoggingSettingsParser::parseNextLine(QStringRef line)
QLoggingRegistry::QLoggingRegistry()
: categoryFilter(defaultCategoryFilter)
{
#if defined(Q_OS_ANDROID)
// Unless QCoreApplication has been constructed we can't be sure that
// we are on Qt's main thread. If we did allow logging here, we would
// potentially set Qt's main thread to Android's thread 0, which would
// confuse Qt later when running main().
if (!qApp)
return;
#endif
initializeRules(); // Init on first use
}

View File

@ -217,7 +217,16 @@ static QString getFilesDir()
if (!path.isEmpty())
return path;
return (path = QDir::homePath());
QJNIObjectPrivate appCtx = applicationContext();
if (!appCtx.isValid())
return QString();
QJNIObjectPrivate file = appCtx.callObjectMethod("getFilesDir",
"()Ljava/io/File;");
if (!file.isValid())
return QString();
return (path = getAbsolutePath(file));
}
QString QStandardPaths::writableLocation(StandardLocation type)
@ -319,7 +328,9 @@ QStringList QStandardPaths::standardLocations(StandardLocation type)
if (!ba.isEmpty())
return QStringList((fontLocation = QDir::cleanPath(QString::fromLocal8Bit(ba))));
return QStringList((fontLocation = QLatin1String("/system/fonts")));
// Don't cache the fallback, as we might just have been called before
// QT_ANDROID_FONT_LOCATION has been set.
return QStringList(QLatin1String("/system/fonts"));
}
return QStringList(writableLocation(type));

View File

@ -802,6 +802,14 @@ void QCoreApplicationPrivate::init()
if (!coreappdata()->applicationVersionSet)
coreappdata()->applicationVersion = appVersion();
#if defined(Q_OS_ANDROID)
// We've deferred initializing the logging registry due to not being
// able to guarantee that logging happened on the same thread as the
// Qt main thread, but now that the Qt main thread is set up, we can
// enable categorized logging.
QLoggingRegistry::instance()->initializeRules();
#endif
#if QT_CONFIG(library)
// Reset the lib paths, so that they will be recomputed, taking the availability of argv[0]
// into account. If necessary, recompute right away and replay the manual changes on top of the

View File

@ -440,10 +440,10 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
*str = v_cast<QDate>(d)->toString(Qt::ISODate);
break;
case QVariant::Time:
*str = v_cast<QTime>(d)->toString(Qt::ISODateWithMs);
*str = v_cast<QTime>(d)->toString(Qt::ISODate);
break;
case QVariant::DateTime:
*str = v_cast<QDateTime>(d)->toString(Qt::ISODateWithMs);
*str = v_cast<QDateTime>(d)->toString(Qt::ISODate);
break;
#endif
case QVariant::Bool:

View File

@ -1157,23 +1157,6 @@ void QCocoaWindow::handleExposeEvent(const QRegion &region)
m_exposedRect = QRect();
}
QWindowPrivate *windowPrivate = qt_window_private(window());
if (windowPrivate->updateRequestPending) {
// We can only deliver update request events when the window is exposed,
// and we also have to make sure we deliver any change to the exposed
// rect as a real expose event (including going from non-exposed to
// exposed). FIXME: Should this logic live in QGuiApplication?
if (isExposed() && m_exposedRect == previouslyExposedRect) {
qCDebug(lcQpaCocoaWindow) << "QCocoaWindow::handleExposeEvent" << window() << region << "as update request";
windowPrivate->deliverUpdateRequest();
return;
} else {
// Since updateRequestPending is still set, we will issue a deferred setNeedsDisplay
// from drawRect and get back into this code on the next display cycle, delivering
// the pending update request.
}
}
qCDebug(lcQpaCocoaWindow) << "QCocoaWindow::handleExposeEvent" << window() << region << "isExposed" << isExposed();
QWindowSystemInterface::handleExposeEvent<QWindowSystemInterface::SynchronousDelivery>(window(), region);
}
@ -1348,7 +1331,7 @@ void QCocoaWindow::recreateWindowIfNeeded()
void QCocoaWindow::requestUpdate()
{
qCDebug(lcQpaCocoaWindow) << "QCocoaWindow::requestUpdate" << window();
[m_view setNeedsDisplay:YES];
[m_view requestUpdate];
}
void QCocoaWindow::requestActivateWindow()

View File

@ -81,6 +81,7 @@ Q_FORWARD_DECLARE_OBJC_CLASS(QT_MANGLE_NAMESPACE(QNSViewMouseMoveHelper));
NSEvent *m_currentlyInterpretedKeyEvent;
bool m_isMenuView;
QSet<quint32> m_acceptedKeyDowns;
bool m_updateRequested;
}
@property (nonatomic, retain) NSCursor *cursor;
@ -105,6 +106,8 @@ Q_FORWARD_DECLARE_OBJC_CLASS(QT_MANGLE_NAMESPACE(QNSViewMouseMoveHelper));
- (void)resetMouseButtons;
- (void)requestUpdate;
- (void)handleMouseEvent:(NSEvent *)theEvent;
- (bool)handleMouseDownEvent:(NSEvent *)theEvent withButton:(int)buttonNumber;
- (bool)handleMouseDraggedEvent:(NSEvent *)theEvent withButton:(int)buttonNumber;

View File

@ -147,6 +147,7 @@ Q_LOGGING_CATEGORY(lcQpaTablet, "qt.qpa.input.tablet")
m_isMenuView = false;
self.focusRingType = NSFocusRingTypeNone;
self.cursor = nil;
m_updateRequested = false;
}
return self;
}
@ -299,6 +300,25 @@ Q_LOGGING_CATEGORY(lcQpaTablet, "qt.qpa.input.tablet")
return m_platformWindow->isOpaque();
}
- (void)requestUpdate
{
if (self.needsDisplay) {
// If the view already has needsDisplay set it means that there may be code waiting for
// a real expose event, so we can't issue setNeedsDisplay now as a way to trigger an
// update request. We will re-trigger requestUpdate from drawRect.
return;
}
[self setNeedsDisplay:YES];
m_updateRequested = true;
}
- (void)setNeedsDisplayInRect:(NSRect)rect
{
[super setNeedsDisplayInRect:rect];
m_updateRequested = false;
}
- (void)drawRect:(NSRect)dirtyRect
{
Q_UNUSED(dirtyRect);
@ -322,18 +342,24 @@ Q_LOGGING_CATEGORY(lcQpaTablet, "qt.qpa.input.tablet")
}
#endif
m_platformWindow->handleExposeEvent(exposedRegion);
QWindowPrivate *windowPrivate = qt_window_private(m_platformWindow->window());
if (qt_window_private(m_platformWindow->window())->updateRequestPending) {
// A call to QWindow::requestUpdate was issued during the expose event, or we
// had to deliver a real expose event and still need to deliver the update.
// But AppKit will reset the needsDisplay state of the view after completing
if (m_updateRequested) {
Q_ASSERT(windowPrivate->updateRequestPending);
qCDebug(lcQpaCocoaWindow) << "Delivering update request to" << m_platformWindow->window();
windowPrivate->deliverUpdateRequest();
m_updateRequested = false;
} else {
m_platformWindow->handleExposeEvent(exposedRegion);
}
if (windowPrivate->updateRequestPending) {
// A call to QWindow::requestUpdate was issued during event delivery above,
// but AppKit will reset the needsDisplay state of the view after completing
// the current display cycle, so we need to defer the request to redisplay.
// FIXME: Perhaps this should be a trigger to enable CADisplayLink?
qCDebug(lcQpaCocoaWindow) << "[QNSView drawRect:] issuing deferred setNeedsDisplay due to pending update request";
dispatch_async(dispatch_get_main_queue (), ^{
[self setNeedsDisplay:YES];
});
qCDebug(lcQpaCocoaWindow) << "Pending update request, triggering re-display";
dispatch_async(dispatch_get_main_queue (), ^{ [self requestUpdate]; });
}
}

View File

@ -1099,9 +1099,8 @@ void tst_QVariant::toString_data()
QTest::newRow( "bool" ) << QVariant( true ) << QString( "true" );
QTest::newRow( "qdate" ) << QVariant( QDate( 2002, 1, 1 ) ) << QString( "2002-01-01" );
QTest::newRow( "qtime" ) << QVariant( QTime( 12, 34, 56 ) ) << QString( "12:34:56.000" );
QTest::newRow( "qtime-with-ms" ) << QVariant( QTime( 12, 34, 56, 789 ) ) << QString( "12:34:56.789" );
QTest::newRow( "qdatetime" ) << QVariant( QDateTime( QDate( 2002, 1, 1 ), QTime( 12, 34, 56, 789 ) ) ) << QString( "2002-01-01T12:34:56.789" );
QTest::newRow( "qtime" ) << QVariant( QTime( 12, 34, 56 ) ) << QString( "12:34:56" );
QTest::newRow( "qdatetime" ) << QVariant( QDateTime( QDate( 2002, 1, 1 ), QTime( 12, 34, 56 ) ) ) << QString( "2002-01-01T12:34:56" );
QTest::newRow( "llong" ) << QVariant( (qlonglong)Q_INT64_C(123456789012) ) <<
QString( "123456789012" );
QTest::newRow("QJsonValue") << QVariant(QJsonValue(QString("hello"))) << QString("hello");
@ -1152,7 +1151,6 @@ void tst_QVariant::toTime_data()
QTest::newRow( "qtime" ) << QVariant( QTime( 12, 34, 56 ) ) << QTime( 12, 34, 56 );
QTest::newRow( "qdatetime" ) << QVariant( QDateTime( QDate( 2002, 10, 10 ), QTime( 12, 34, 56 ) ) ) << QTime( 12, 34, 56 );
QTest::newRow( "qstring" ) << QVariant( QString( "12:34:56" ) ) << QTime( 12, 34, 56 );
QTest::newRow( "qstring-with-ms" ) << QVariant( QString( "12:34:56.789" ) ) << QTime( 12, 34, 56, 789 );
}
void tst_QVariant::toTime()
@ -1173,10 +1171,6 @@ void tst_QVariant::toDateTime_data()
<< QDateTime( QDate( 2002, 10, 10 ), QTime( 12, 34, 56 ) );
QTest::newRow( "qdate" ) << QVariant( QDate( 2002, 10, 10 ) ) << QDateTime( QDate( 2002, 10, 10 ), QTime( 0, 0, 0 ) );
QTest::newRow( "qstring" ) << QVariant( QString( "2002-10-10T12:34:56" ) ) << QDateTime( QDate( 2002, 10, 10 ), QTime( 12, 34, 56 ) );
QTest::newRow( "qstring-utc" ) << QVariant( QString( "2002-10-10T12:34:56Z" ) )
<< QDateTime( QDate( 2002, 10, 10 ), QTime( 12, 34, 56 ), Qt::UTC );
QTest::newRow( "qstring-with-ms" ) << QVariant( QString( "2002-10-10T12:34:56.789" ) )
<< QDateTime( QDate( 2002, 10, 10 ), QTime( 12, 34, 56, 789 ) );
}
void tst_QVariant::toDateTime()