lukasmonk / lucaschessR2

Lucas Chess R Version 2
GNU General Public License v3.0
268 stars 40 forks source link

Cannot create/edit variation with R2.05 on Linux. #57

Closed chemtov closed 1 year ago

chemtov commented 1 year ago

Hi,

my environment is Fedora36

I try to edit a PGN, but when I'm adding a variation to it the application closes.

Traceback (most recent call last):
  File "/home/chem/src/github/lucaschessR2/bin/Code/Databases/WDB_Games.py", line 509, in tw_edit
    self.edit(recno, game)
  File "/home/chem/src/github/lucaschessR2/bin/Code/Databases/WDB_Games.py", line 496, in edit
    self.edit_save(game.recno, game)
  File "/home/chem/src/github/lucaschessR2/bin/Code/Databases/WDB_Games.py", line 436, in edit_save
    resp = self.dbGames.save_game_recno(recno, game)
  File "/home/chem/src/github/lucaschessR2/bin/Code/Databases/DBgames.py", line 504, in save_game_recno
    return self.insert(game) if recno is None else self.modify(recno, game)
  File "/home/chem/src/github/lucaschessR2/bin/Code/Databases/DBgames.py", line 868, in modify
    game_antigua = self.read_game_recno(recno)
  File "/home/chem/src/github/lucaschessR2/bin/Code/Databases/DBgames.py", line 459, in read_game_recno
    raw = self.read_complete_recno(recno)
  File "/home/chem/src/github/lucaschessR2/bin/Code/Databases/DBgames.py", line 383, in read_complete_recno
    cursor = self.conexion.execute("SELECT %s FROM Games WHERE rowid =%d" % (self.select, rowid))
AttributeError: 'NoneType' object has no attribute 'execute'

So I added this to the code:

modified   bin/Code/Databases/DBgames.py
@@ -379,6 +379,9 @@ class DBgames:

     def read_complete_recno(self, recno):
         rowid = self.li_row_ids[recno]
+        if self.conexion is None:
+            self.conexion = sqlite3.connect(self.nom_fichero)
+            self.conexion.row_factory = sqlite3.Row
         cursor = self.conexion.execute("SELECT %s FROM Games WHERE rowid =%d" % (self.select, rowid))
         return cursor.fetchone()

Now the variation is saved but the application just close when I click the "Accept" or "Cancel" button. It closes as well when I open the variation and either "Accept" or "Cancel" it.

Then I got this:

Traceback (most recent call last):
  File "/usr/lib64/python3.10/pdb.py", line 1726, in main
    pdb._runscript(mainpyfile)
  File "/usr/lib64/python3.10/pdb.py", line 1586, in _runscript
    self.run(statement)
  File "/usr/lib64/python3.10/bdb.py", line 597, in run
    exec(cmd, globals, locals)
  File "<string>", line 1, in <module>
  File "/home/chem/src/github/lucaschessR2/bin/LucasR.py", line 19, in <module>
    Code.Base.Init.init()
  File "/home/chem/src/github/lucaschessR2/bin/Code/Base/Init.py", line 19, in init
    resp = Gui.run_gui(main_procesador)
  File "/home/chem/src/github/lucaschessR2/bin/Code/MainWindow/Gui.py", line 24, in run_gui
    app = QtWidgets.QApplication([])
RuntimeError: Please destroy the QApplication singleton before creating a new QApplication instance.

And tried this:

modified   bin/Code/MainWindow/Gui.py
@@ -21,7 +21,9 @@ def run_gui(procesador):
         QtCore.QCoreApplication.setAttribute(QtCore.Qt.AA_UseHighDpiPixmaps)
     QtCore.QCoreApplication.setAttribute(QtCore.Qt.AA_UseStyleSheetPropagationInWidgetStyles, True)

-    app = QtWidgets.QApplication([])
+    app = QtWidgets.QApplication.instance()
+    if app is None:
+        app = QtWidgets.QApplication(sys.argv)

     # Usuarios
     list_users = Usuarios.Usuarios().list_users

But it still doesn't work and now the application stops without anything writen to the bug.log file.

Overall, I'm not 100% certain that this is not my local installation that is flowed. I've done my best to install it from github src code, but I could have done something wrong (it tooks some trial and error to get it working)

So can you reproduce this on a linux (wayland) environment ? I can reproduce it with R2.04 installed from your installer, but again something might be wrong with my overall env.

Beside this, your program seems great (a lot of reading to understand it all...) and having it working with chessnut air is even more awesome.

Thanks,

lukasmonk commented 1 year ago

Please, tell me step by step the program options (the menu/toolbar names) you choose, to try to replicate exactly the problem. Also tell me if the pgn is in a folder with user write permissions.

chemtov commented 1 year ago

./LucasR.py tools->PGN->read PGN file : file selector : ~/Documents/Chess/Games/JZ-64_vs_chem34_2022.12.23.pgn

New windown about : UserData/TemporaryDatabases/JZ-64_vs_chem34_2022.12.23.lcdb

Games->Edit

Single click on the 8th move for black (with ?? blunder there) and then click on the green "add" button for variation

Don't add anything and click "Accept" , then Question: Do you want to save the changes, click "yes" (no or cancel does the same) -> application closes

Re-do everything and add a variation like ... d6; h3, 0-0 , click "Accept" , answer yes or whatever -> application closes

The temporary database is in ../UserData/TemporaryDatabases/JZ-64_vs_chem34_2022.12.23.lcdb relative to the bin/LucasR.py and has write permission for the user, the same is true for the ~/Documents/Chess/Games directory.

Here is the pgn file JZ-64_vs_chem34_2022.12.23.zip

Let me know if you need anything else.

Thanks

lukasmonk commented 1 year ago

Could you test the change in QT/QTUtil of this class:

class EscondeWindow:
    def __init__(self, window):
        self.window = window

    def __enter__(self):
        if Code.is_windows:
            self.pos = self.window.pos()
            screen = QtWidgets.QDesktopWidget().screenGeometry()
            self.window.move(screen.width() * 10, 0)
        return self

    def __exit__(self, type, value, traceback):
        if Code.is_windows:
            self.window.move(self.pos)
            self.window.show()
chemtov commented 1 year ago

Hi,

patched Code/QT/QTUtil.py like this:

modified   bin/Code/QT/QTUtil.py
@@ -157,13 +157,12 @@ class EscondeWindow:
         if Code.is_windows:
             screen = QtWidgets.QDesktopWidget().screenGeometry()
             self.window.move(screen.width() * 10, 0)
-        else:
-            self.window.hide()
         return self

     def __exit__(self, type, value, traceback):
-        self.window.move(self.pos)
-        self.window.show()
+        if Code.is_windows:
+            self.window.move(self.pos)
+            self.window.show()

And the issue totally disapeared \o/.

Thanks a lot,

lukasmonk commented 1 year ago

There is a problem in Linux, when a window is hidden, a child window is launched, and this one is closed. The solution is not to hide it, it will be necessary to evaluate what problems this causes.