Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: unsupported operand type(s) for &: 'WindowType' and 'ApplicationAttribute' #600

Open
YamiDoesDev opened this issue Apr 9, 2023 · 7 comments
Assignees

Comments

@YamiDoesDev
Copy link

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Run "syncplay" via terminal (to see the error output)
  2. Type in your personal server-config
  3. Start the Room

Expected behavior
Syncplay would open the room and possibly a video as well.

Screenshots
If applicable, add screenshots to help explain your problem.

Version and platform:

  • OS: Archlinx 6.2.9 (I guess)
  • Syncplay version and build type: Syncplay v. 1.7.0 (Yoitsu)
  • Media player and version: mpv 0.35.1-dirty / VLC 3.0.18 Vetinari

Additional context

syncplay --debug    
Traceback (most recent call last):
  File "/usr/bin/syncplay", line 19, in <module>
    ep_client.main()
  File "/usr/lib/syncplay/syncplay/ep_client.py", line 8, in main
    SyncplayClientManager().run()
  File "/usr/lib/syncplay/syncplay/clientManager.py", line 12, in run
    interface = ui.getUi(graphical=not config["noGui"], passedBar=menuBar)
  File "/usr/lib/syncplay/syncplay/ui/__init__.py", line 17, in getUi
    ui = GraphicalUI(passedBar=passedBar)
  File "/usr/lib/syncplay/syncplay/ui/gui.py", line 2109, in __init__
    self.setWindowFlags(self.windowFlags() & Qt.AA_DontUseNativeMenuBar)
TypeError: unsupported operand type(s) for &: 'WindowType' and 'ApplicationAttribute'

The path: Syncplay/syncplay/blob/master/syncplay/ui/gui.py#L2109)

self.setWindowFlags(self.windowFlags() & Qt.AA_DontUseNativeMenuBar)

I don't have much of an understanding about qt-python myself. On one hand, it seems no not like the & operator. Changing it to | did not help either. If I change the operator into a comma, following error will be printed instead:

Traceback (most recent call last):
  File "/usr/bin/syncplay", line 19, in <module>
    ep_client.main()
  File "/usr/lib/syncplay/syncplay/ep_client.py", line 8, in main
    SyncplayClientManager().run()
  File "/usr/lib/syncplay/syncplay/clientManager.py", line 12, in run
    interface = ui.getUi(graphical=not config["noGui"], passedBar=menuBar)
  File "/usr/lib/syncplay/syncplay/ui/__init__.py", line 17, in getUi
    ui = GraphicalUI(passedBar=passedBar)
  File "/usr/lib/syncplay/syncplay/ui/gui.py", line 2109, in __init__
    self.setWindowFlags(self.windowFlags(),  Qt.AA_DontUseNativeMenuBar)
TypeError: MainWindow.setWindowFlags() takes exactly one argument (2 given)

A possible workaround for me was to just comment out the second parameter. At least it loaded the room as intented.

@Et0h
Copy link
Contributor

Et0h commented Apr 11, 2023

I've not tested it, but b62b038 should hopefully solve the issue.

@YamiDoesDev
Copy link
Author

Well, that's literally what I did 😇
So consider it tested

@KWeaver87
Copy link

I ran into this same issue today, using Manjaro 22.1.0. I had not used Syncplay since the previous Saturday.
Installing syncplay-git from the AUR gave me the b62b038 commit, and was able to use Syncplay for 1.5 hours without any issue.
So, a +1 to it being tested.

@powerjungle
Copy link
Contributor

powerjungle commented May 6, 2023

I think on my Gentoo system, after updating from python 3.10 to python 3.11 I got a similar error:

Attribute Qt::AA_EnableHighDpiScaling must be set before QCoreApplication is created.
Traceback (most recent call last):
  File "/home/syncplay-dev/syncplay/syncplayClient.py", line 17, in <module>
    ep_client.main()
  File "/home/syncplay-dev/syncplay/syncplay/ep_client.py", line 8, in main
    SyncplayClientManager().run()
  File "/home/syncplay-dev/syncplay/syncplay/clientManager.py", line 9, in run
    config = ConfigurationGetter().getConfiguration()
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/syncplay-dev/syncplay/syncplay/ui/ConfigurationGetter.py", line 553, in getConfiguration
    self._forceGuiPrompt()
  File "/home/syncplay-dev/syncplay/syncplay/ui/ConfigurationGetter.py", line 455, in _forceGuiPrompt
    for key, value in list(self._promptForMissingArguments().items()):
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/syncplay-dev/syncplay/syncplay/ui/ConfigurationGetter.py", line 420, in _promptForMissingArguments
    gc.run()
  File "/home/syncplay-dev/syncplay/syncplay/ui/GuiConfiguration.py", line 42, in run
    dialog = ConfigDialog(self.config, self._availablePlayerPaths, self.error, self.defaultConfig)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/syncplay-dev/syncplay/syncplay/ui/GuiConfiguration.py", line 1430, in __init__
    self.setWindowFlags(self.windowFlags() & Qt.WindowCloseButtonHint & ~Qt.WindowContextHelpButtonHint)
TypeError: 'PySide2.QtCore.Qt.WindowFlags' object cannot be interpreted as an integer

Everything was working fine before that. I think after reinstalling the requirements it might've pulled a new version of PySide as well. Right now it's running PySide2-5.15.2.

@Et0h
Copy link
Contributor

Et0h commented May 7, 2023

Everything was working fine before that. I think after reinstalling the requirements it might've pulled a new version of PySide as well. Right now it's running PySide2-5.13.2.

If you change the line:

self.setWindowFlags(self.windowFlags() & Qt.WindowCloseButtonHint & ~Qt.WindowContextHelpButtonHint)
to read self.setWindowFlags(self.windowFlags() & Qt.WindowType.WindowCloseButtonHint & ~Qt.WindowType.WindowContextHelpButtonHint)
does it fix things?

You may also have to change the line:

self.setWindowFlags(Qt.Dialog | Qt.WindowTitleHint | Qt.WindowCloseButtonHint | Qt.CustomizeWindowHint)
to self.setWindowFlags(Qt.WindowType.Dialog | Qt.WindowType.WindowTitleHint | Qt.WindowType.WindowCloseButtonHint | Qt.WindowType.CustomizeWindowHint)

If that doesn't work, does commenting out these line result in Syncplay and the configuration window working adequately?

@powerjungle
Copy link
Contributor

powerjungle commented May 7, 2023

to read self.setWindowFlags(self.windowFlags() & Qt.WindowType.WindowCloseButtonHint & ~Qt.WindowType.WindowContextHelpButtonHint)
does it fix things?

Nope, the same error appears.

Don't bother, because I just noticed this in the PySide2 package page:

Requires: Python >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <3.11

Source: https://pypi.org/project/PySide2/

@YamiDoesDev What Python version is your system running? Your issue might be related to this.

Edit: Yep, just tested, changing to python3.10 fixed my issue. My exact current working Python version is: 3.10.10

Edit2: In my case with or without the commit b62b038 it works fine as long as I'm using Python 3.10.

@YamiDoesDev
Copy link
Author

@powerjungle Currently I run python 3.10.10, but it could have been a lower version a month ago.

Did this bug really become that big? Like, commenting out that one parameter already fixed it for me back then...

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

No branches or pull requests

5 participants