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:
parent
23d42a6a30
commit
a84c895b17
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user