summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2020-05-18 08:52:33 +0200
committerLiang Qi <liang.qi@qt.io>2020-05-19 08:21:02 +0200
commitb2c991bfeaae076f14b0f6c6ed37cbdbbcb3bdc9 (patch)
tree8ad2401ab7027bd7bbc1c659a8e1ee397d1487da /src
parent8718b0d07026be1d0cf26b5c1947a66cf33526a1 (diff)
parent2cd6d76d680b1bddef774acc51d80da9e29f1c2e (diff)
Merge "Merge remote-tracking branch 'origin/5.15' into dev"
Diffstat (limited to 'src')
-rw-r--r--src/corelib/io/qstandardpaths_win.cpp7
-rw-r--r--src/corelib/serialization/qcborvalue.cpp2
-rw-r--r--src/gui/painting/qicc.cpp3
-rw-r--r--src/gui/text/qtextdocumentlayout.cpp7
-rw-r--r--src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp5
-rw-r--r--src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp26
-rw-r--r--src/widgets/dialogs/qfiledialog.cpp7
7 files changed, 46 insertions, 11 deletions
diff --git a/src/corelib/io/qstandardpaths_win.cpp b/src/corelib/io/qstandardpaths_win.cpp
index 5055f4020c..cbe4ccd0b2 100644
--- a/src/corelib/io/qstandardpaths_win.cpp
+++ b/src/corelib/io/qstandardpaths_win.cpp
@@ -47,6 +47,7 @@
#include <qcoreapplication.h>
#endif
+#include <qoperatingsystemversion.h>
#include <qt_windows.h>
#include <shlobj.h>
#include <intshcut.h>
@@ -99,7 +100,11 @@ static bool isProcessLowIntegrity() {
// Disable function until Qt CI is updated
return false;
#else
- HANDLE process_token = GetCurrentProcessToken(); // non-leaking pseudo-handle
+ if (QOperatingSystemVersion::current() < QOperatingSystemVersion::Windows8)
+ return false;
+ // non-leaking pseudo-handle. Expanded inline function GetCurrentProcessToken()
+ // (was made an inline function in Windows 8).
+ const auto process_token = HANDLE(quintptr(-4));
QVarLengthArray<char,256> token_info_buf(256);
auto* token_info = reinterpret_cast<TOKEN_MANDATORY_LABEL*>(token_info_buf.data());
diff --git a/src/corelib/serialization/qcborvalue.cpp b/src/corelib/serialization/qcborvalue.cpp
index be22e2c043..0b95bf5b8e 100644
--- a/src/corelib/serialization/qcborvalue.cpp
+++ b/src/corelib/serialization/qcborvalue.cpp
@@ -1635,7 +1635,7 @@ void QCborContainerPrivate::decodeStringFromCbor(QCborStreamReader &reader)
if (len == rawlen) {
auto oldSize = data.size();
auto newSize = oldSize;
- if (!add_overflow(newSize, len, &newSize)) {
+ if (!add_overflow(newSize, len, &newSize) && newSize < MaxByteArraySize) {
if (newSize != oldSize)
data.resize(newSize);
diff --git a/src/gui/painting/qicc.cpp b/src/gui/painting/qicc.cpp
index e2257c27da..ca06e8763f 100644
--- a/src/gui/painting/qicc.cpp
+++ b/src/gui/painting/qicc.cpp
@@ -225,7 +225,7 @@ static bool isValidIccProfile(const ICCProfileHeader &header)
}
// Don't overflow 32bit integers:
- if (header.tagCount >= INT32_MAX / sizeof(TagTableEntry)) {
+ if (header.tagCount >= (INT32_MAX - sizeof(ICCProfileHeader)) / sizeof(TagTableEntry)) {
qCWarning(lcIcc, "Failed tag count sanity");
return false;
}
@@ -629,6 +629,7 @@ bool fromIccProfile(const QByteArray &data, QColorSpace *colorSpace)
// Read tag index
const TagTableEntry *tagTable = (const TagTableEntry *)(data.constData() + sizeof(ICCProfileHeader));
const qsizetype offsetToData = sizeof(ICCProfileHeader) + header->tagCount * sizeof(TagTableEntry);
+ Q_ASSERT(offsetToData > 0);
if (offsetToData > data.size()) {
qCWarning(lcIcc) << "fromIccProfile: failed index size sanity";
return false;
diff --git a/src/gui/text/qtextdocumentlayout.cpp b/src/gui/text/qtextdocumentlayout.cpp
index e5731bcfab..fc61ee50bb 100644
--- a/src/gui/text/qtextdocumentlayout.cpp
+++ b/src/gui/text/qtextdocumentlayout.cpp
@@ -105,13 +105,14 @@ public:
bool sizeDirty;
bool layoutDirty;
+ bool fullLayoutCompleted;
QVector<QPointer<QTextFrame> > floats;
};
QTextFrameData::QTextFrameData()
: maximumWidth(QFIXED_MAX),
- currentLayoutStruct(nullptr), sizeDirty(true), layoutDirty(true)
+ currentLayoutStruct(nullptr), sizeDirty(true), layoutDirty(true), fullLayoutCompleted(false)
{
}
@@ -2943,7 +2944,7 @@ QRectF QTextDocumentLayoutPrivate::layoutFrame(QTextFrame *f, int layoutFrom, in
QTextFrameData *fd = data(f);
QFixed newContentsWidth;
- bool fullLayout = false;
+ bool fullLayout = (f == document->rootFrame() && !fd->fullLayoutCompleted);
{
QTextFrameFormat fformat = f->frameFormat();
// set sizes of this frame from the format
@@ -3397,6 +3398,7 @@ void QTextDocumentLayoutPrivate::layoutFlow(QTextFrame::Iterator it, QTextLayout
cp.contentsWidth = layoutStruct->contentsWidth;
checkPoints.append(cp);
checkPoints.reserve(checkPoints.size());
+ fd->fullLayoutCompleted = true;
} else {
currentLazyLayoutPosition = checkPoints.constLast().positionInFrame;
// #######
@@ -3808,6 +3810,7 @@ void QTextDocumentLayout::documentChanged(int from, int oldLength, int length)
d->contentHasAlignment = false;
d->currentLazyLayoutPosition = 0;
d->checkPoints.clear();
+ data(d->docPrivate->rootFrame())->fullLayoutCompleted = false;
d->layoutStep();
} else {
d->ensureLayoutedByPosition(from);
diff --git a/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp b/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
index 13c39436ba..4b37367ad0 100644
--- a/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
+++ b/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
@@ -107,6 +107,7 @@ public:
{ }
WId winId = 0;
+ bool directoryMode = false;
bool modal = false;
bool multipleFiles = false;
bool saveFile = false;
@@ -145,6 +146,9 @@ void QXdgDesktopPortalFileDialog::initializeDialog()
if (options()->fileMode() == QFileDialogOptions::ExistingFiles)
d->multipleFiles = true;
+ if (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly)
+ d->directoryMode = true;
+
if (options()->isLabelExplicitlySet(QFileDialogOptions::Accept))
d->acceptLabel = options()->labelText(QFileDialogOptions::Accept);
@@ -179,6 +183,7 @@ void QXdgDesktopPortalFileDialog::openPortal()
options.insert(QLatin1String("modal"), d->modal);
options.insert(QLatin1String("multiple"), d->multipleFiles);
+ options.insert(QLatin1String("directory"), d->directoryMode);
if (d->saveFile) {
if (!d->directory.isEmpty())
diff --git a/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp b/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp
index fb65f6d909..30c43b67dc 100644
--- a/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp
+++ b/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp
@@ -45,6 +45,12 @@
#include <qpa/qplatformthemefactory_p.h>
#include <qpa/qplatformintegration.h>
+#include <QDBusConnection>
+#include <QDBusMessage>
+#include <QDBusPendingCall>
+#include <QDBusPendingCallWatcher>
+#include <QDBusPendingReply>
+
QT_BEGIN_NAMESPACE
class QXdgDesktopPortalThemePrivate : public QPlatformThemePrivate
@@ -60,6 +66,7 @@ public:
}
QPlatformTheme *baseTheme;
+ uint fileChooserPortalVersion = 0;
};
QXdgDesktopPortalTheme::QXdgDesktopPortalTheme()
@@ -90,6 +97,21 @@ QXdgDesktopPortalTheme::QXdgDesktopPortalTheme()
// 3) Fall back on the built-in "null" platform theme.
if (!d->baseTheme)
d->baseTheme = new QPlatformTheme;
+
+ // Get information about portal version
+ QDBusMessage message = QDBusMessage::createMethodCall(QLatin1String("org.freedesktop.portal.Desktop"),
+ QLatin1String("/org/freedesktop/portal/desktop"),
+ QLatin1String("org.freedesktop.DBus.Properties"),
+ QLatin1String("Get"));
+ message << QLatin1String("org.freedesktop.portal.FileChooser") << QLatin1String("version");
+ QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message);
+ QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingCall);
+ QObject::connect(watcher, &QDBusPendingCallWatcher::finished, [d] (QDBusPendingCallWatcher *watcher) {
+ QDBusPendingReply<QVariant> reply = *watcher;
+ if (reply.isValid()) {
+ d->fileChooserPortalVersion = reply.value().toUInt();
+ }
+ });
}
QPlatformMenuItem* QXdgDesktopPortalTheme::createPlatformMenuItem() const
@@ -131,7 +153,9 @@ QPlatformDialogHelper* QXdgDesktopPortalTheme::createPlatformDialogHelper(Dialog
Q_D(const QXdgDesktopPortalTheme);
if (type == FileDialog) {
- if (d->baseTheme->usePlatformNativeDialog(type))
+ // Older versions of FileChooser portal don't support opening directories, therefore we fallback
+ // to native file dialog opened inside the sandbox to open a directory.
+ if (d->fileChooserPortalVersion < 3 && d->baseTheme->usePlatformNativeDialog(type))
return new QXdgDesktopPortalFileDialog(static_cast<QPlatformFileDialogHelper*>(d->baseTheme->createPlatformDialogHelper(type)));
return new QXdgDesktopPortalFileDialog;
diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp
index 77fec76c6f..b268864132 100644
--- a/src/widgets/dialogs/qfiledialog.cpp
+++ b/src/widgets/dialogs/qfiledialog.cpp
@@ -1378,8 +1378,8 @@ QStringList qt_make_filter_list(const QString &filter)
\snippet code/src_gui_dialogs_qfiledialog.cpp 6
- \note This is not supported on Android's native file dialog. Use
- \l{setMimeTypeFilters()} instead.
+ \note With Android's native file dialog, the mime type matching the given
+ name filter is used because only mime types are supported.
\sa setMimeTypeFilters(), setNameFilters()
*/
@@ -1431,9 +1431,6 @@ QStringList qt_strip_filters(const QStringList &filters)
filters for each file type. For example, JPEG images have three possible
extensions; if your application can open such files, selecting the
\c image/jpeg mime type as a filter will allow you to open all of them.
-
- \note This is not supported on Android's native file dialog. Use
- \l{setMimeTypeFilters()} instead.
*/
void QFileDialog::setNameFilters(const QStringList &filters)
{