Syncplay / syncplay

Client/server to synchronize media playback on mpv/VLC/MPC-HC/MPC-BE on many computers
http://syncplay.pl/
Apache License 2.0
2.17k stars 215 forks source link

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

Open YamiDoesDev opened 1 year ago

YamiDoesDev commented 1 year ago

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:

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 commented 1 year ago

I've not tested it, but https://github.com/Syncplay/syncplay/commit/b62b038cdf58c54205987dfc52ebf228505ad03b should hopefully solve the issue.

YamiDoesDev commented 1 year ago

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

KWeaver87 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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: https://github.com/Syncplay/syncplay/blob/af0d0006f143353f7ef096390883a8070cf0aca4/syncplay/ui/GuiConfiguration.py#L1430 to read self.setWindowFlags(self.windowFlags() & Qt.WindowType.WindowCloseButtonHint & ~Qt.WindowType.WindowContextHelpButtonHint) does it fix things?

You may also have to change the line: https://github.com/Syncplay/syncplay/blob/b62b038cdf58c54205987dfc52ebf228505ad03b/syncplay/ui/gui.py#L142 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 commented 1 year ago

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 https://github.com/Syncplay/syncplay/commit/b62b038cdf58c54205987dfc52ebf228505ad03b it works fine as long as I'm using Python 3.10.

YamiDoesDev commented 1 year ago

@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...