From dd450a1006c6975014f95dcb93395e961945c4f2 Mon Sep 17 00:00:00 2001
From: Adam Kallai <kadam@inf.u-szeged.hu>
Date: Thu, 5 Feb 2015 15:06:59 +0100
Subject: [PATCH] Revert the QJSValue parameter type in UIDelegate
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The mapping of var signal parameters to QJSValue was reverted
in qtdeclarative, commit 605777e6cf557dbaf2835c63562bf3fe1620ee45.

Change the FilePickerController::accepted() slot parameter type from
QJSValue to QVariant in UIDelegate.

Task-number: QTBUG-44307
Change-Id: I373b37b6eb4c32e91fd92701ecad685eab9cb804
Reviewed-by: Andras Becsi <andras.becsi@theqtcompany.com>
Reviewed-by: Michael Brüning <michael.bruning@theqtcompany.com>
---
 src/webengine/ui_delegates_manager.cpp | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/src/webengine/ui_delegates_manager.cpp b/src/webengine/ui_delegates_manager.cpp
index 48e1bee7e..ed4d59bfd 100644
--- a/src/webengine/ui_delegates_manager.cpp
+++ b/src/webengine/ui_delegates_manager.cpp
@@ -342,7 +342,7 @@ public:
     FilePickerController(WebContentsAdapterClient::FileChooserMode, const QExplicitlySharedDataPointer<WebContentsAdapter> &, QObject * = 0);
 
 public Q_SLOTS:
-    void accepted(const QJSValue &files);
+    void accepted(const QVariant &files);
     void rejected();
 
 private:
@@ -359,14 +359,11 @@ FilePickerController::FilePickerController(WebContentsAdapterClient::FileChooser
 {
 }
 
-void FilePickerController::accepted(const QJSValue &filesValue)
+void FilePickerController::accepted(const QVariant &files)
 {
     QStringList stringList;
-    int length = filesValue.property(QStringLiteral("length")).toInt();
-    for (int i = 0; i < length; i++) {
-        stringList.append(QUrl(filesValue.property(i).toString()).toLocalFile());
-    }
-
+    Q_FOREACH (const QUrl &url, files.value<QList<QUrl> >())
+        stringList.append(url.toLocalFile());
     m_adapter->filesSelectedInChooser(stringList, m_mode);
 }
 
@@ -415,7 +412,7 @@ void UIDelegatesManager::showFilePicker(WebContentsAdapterClient::FileChooserMod
     CHECK_QML_SIGNAL_PROPERTY(filesPickedSignal, filePickerComponent->url());
     QQmlProperty rejectSignal(filePicker, QStringLiteral("onRejected"));
     CHECK_QML_SIGNAL_PROPERTY(rejectSignal, filePickerComponent->url());
-    static int acceptedIndex = controller->metaObject()->indexOfSlot("accepted(QJSValue)");
+    static int acceptedIndex = controller->metaObject()->indexOfSlot("accepted(QVariant)");
     QObject::connect(filePicker, filesPickedSignal.method(), controller, controller->metaObject()->method(acceptedIndex));
     static int rejectedIndex = controller->metaObject()->indexOfSlot("rejected()");
     QObject::connect(filePicker, rejectSignal.method(), controller, controller->metaObject()->method(rejectedIndex));
-- 
GitLab