Android: Fix native fileDialog not waiting for user selection

Add an event loop to wait for user file selection in native fileDialog

Task-number: QTBUG-77214
Change-Id: I3d97d6c3f46cf2a8ed0ee6f98e555e8d62e12cc3
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
This commit is contained in:
Assam Boudjelthia 2020-01-31 17:04:54 +02:00
parent 23d42a6a30
commit a84c895b17
2 changed files with 5 additions and 0 deletions

View File

@ -100,10 +100,13 @@ bool QAndroidPlatformFileDialogHelper::show(Qt::WindowFlags windowFlags, Qt::Win
void QAndroidPlatformFileDialogHelper::exec()
{
m_eventLoop.exec(QEventLoop::DialogExec);
}
void QAndroidPlatformFileDialogHelper::hide()
{
if (m_eventLoop.isRunning())
m_eventLoop.exit();
QtAndroidPrivate::unregisterActivityResultListener(this);
}

View File

@ -41,6 +41,7 @@
#define QANDROIDPLATFORMFILEDIALOGHELPER_H
#include <jni.h>
#include <QEventLoop>
#include <qpa/qplatformdialoghelper.h>
#include <QtCore/private/qjnihelpers_p.h>
@ -72,6 +73,7 @@ public:
bool handleActivityResult(jint requestCode, jint resultCode, jobject data) override;
private:
QEventLoop m_eventLoop;
QUrl m_selectedFile;
};