Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/5.10.1' into 5.10
Browse files Browse the repository at this point in the history
Change-Id: Ibbe355f5e8ef12e5ffeb4e33b6a80760c3e2b464
  • Loading branch information
liangqi committed Feb 1, 2018
2 parents 27e8612 + 69d2501 commit 15ae794
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 39 deletions.
10 changes: 10 additions & 0 deletions src/corelib/io/qloggingregistry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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...
Expand Down Expand Up @@ -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
}

Expand Down
15 changes: 13 additions & 2 deletions src/corelib/io/qstandardpaths_android.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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));
Expand Down
8 changes: 8 additions & 0 deletions src/corelib/kernel/qcoreapplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/corelib/kernel/qvariant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
19 changes: 1 addition & 18 deletions src/plugins/platforms/cocoa/qcocoawindow.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1157,23 +1157,6 @@ Posted whenever an NSView object that has attached surfaces (that is,
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);
}
Expand Down Expand Up @@ -1348,7 +1331,7 @@ Posted whenever an NSView object that has attached surfaces (that is,
void QCocoaWindow::requestUpdate()
{
qCDebug(lcQpaCocoaWindow) << "QCocoaWindow::requestUpdate" << window();
[m_view setNeedsDisplay:YES];
[m_view requestUpdate];
}

void QCocoaWindow::requestActivateWindow()
Expand Down
3 changes: 3 additions & 0 deletions src/plugins/platforms/cocoa/qnsview.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
44 changes: 35 additions & 9 deletions src/plugins/platforms/cocoa/qnsview.mm
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ - (id) init
m_isMenuView = false;
self.focusRingType = NSFocusRingTypeNone;
self.cursor = nil;
m_updateRequested = false;
}
return self;
}
Expand Down Expand Up @@ -299,6 +300,25 @@ - (BOOL) isOpaque
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);
Expand All @@ -322,18 +342,24 @@ - (void)drawRect:(NSRect)dirtyRect
}
#endif

m_platformWindow->handleExposeEvent(exposedRegion);
QWindowPrivate *windowPrivate = qt_window_private(m_platformWindow->window());

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 (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 (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]; });
}
}

Expand Down
10 changes: 2 additions & 8 deletions tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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()
Expand All @@ -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()
Expand Down

0 comments on commit 15ae794

Please sign in to comment.