Skip to content
This repository has been archived by the owner on May 22, 2019. It is now read-only.

TypeError: 'QJSValue' object is not iterable #11

Open
marguerite opened this issue Aug 16, 2015 · 4 comments
Open

TypeError: 'QJSValue' object is not iterable #11

marguerite opened this issue Aug 16, 2015 · 4 comments

Comments

@marguerite
Copy link

Traceback (most recent call last):
  File "/usr/share/deepin-movie/utils/utils.py", line 164, in run
    self._process_path_list(self._pathList)
  File "/usr/share/deepin-movie/utils/utils.py", line 152, in _process_path_list
    for path in pathList:
TypeError: 'QJSValue' object is not iterable

Qt 版本 5.4.2

@felixonmars
Copy link
Contributor

Same here with Qt 5.5.0. branch release/2.2.

@felixonmars
Copy link
Contributor

The following patch works for me:

diff --git a/src/utils/utils.py b/src/utils/utils.py
index e0140a1..cbad5f3 100644
--- a/src/utils/utils.py
+++ b/src/utils/utils.py
@@ -146,7 +146,7 @@ class FindVideoThread(QThread):
             self._cate_video_tuple_list.append(("", path))

     def _process_path_list(self, pathList):
-        for path in pathList:
+        for path in pathList.toString().split(","):
             if utils.urlIsDir(path):
                 self._process_path_list(utils.getAllFilesInDir(path))
             elif path not in map(lambda x: x[1], self._cate_video_tuple_list):

@felixonmars
Copy link
Contributor

An improved patch:

diff --git a/src/utils/utils.py b/src/utils/utils.py
index e0140a1..df0a423 100644
--- a/src/utils/utils.py
+++ b/src/utils/utils.py
@@ -30,7 +30,8 @@ md = magic.open(magic.MAGIC_MIME_TYPE)
 md.load()
 from PyQt5.QtWidgets import QApplication
 from PyQt5.QtGui import QKeySequence
-from PyQt5.QtCore import QObject, QThread, pyqtSignal, pyqtSlot, pyqtProperty
+from PyQt5.QtCore import QObject, QThread, pyqtSignal, pyqtSlot, pyqtProperty,\
+                         PYQT_VERSION

 from views.subtitles import *
 from dbus_interfaces import screenSaverInterface
@@ -146,6 +147,8 @@ class FindVideoThread(QThread):
             self._cate_video_tuple_list.append(("", path))

     def _process_path_list(self, pathList):
+        if PYQT_VERSION >= 0x50400:
+            pathList = pathList.toVariant()
         for path in pathList:
             if utils.urlIsDir(path):
                 self._process_path_list(utils.getAllFilesInDir(path))

I will submit the patch to upstream later.

@felixonmars
Copy link
Contributor

Link to CR: https://cr.deepin.io/#/c/7671/

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants