From 3b29d4bc2a6f01bdef43c8eef577141b5f0603ad Mon Sep 17 00:00:00 2001 From: random-zebra Date: Sun, 18 Nov 2018 00:30:00 +0100 Subject: [PATCH] release DB cursor before emitting signals --- src/database.py | 25 +++++++++++++++++-------- src/version.txt | 4 ++-- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/database.py b/src/database.py index cab2eb2..7350dea 100644 --- a/src/database.py +++ b/src/database.py @@ -189,13 +189,14 @@ def initTable_RPC(self, cursor): General methods ''' def clearTable(self, table_name): + cleared_RPC = False try: cursor = self.getCursor() cursor.execute("DELETE FROM %s" % table_name) # in case, reload default RPC and emit changed signal if table_name == 'CUSTOM_RPC_SERVERS': self.initTable_RPC(cursor) - self.app.sig_changed_rpcServers.emit() + cleared_RPC = True except Exception as e: err_msg = 'error clearing %s in database' % table_name @@ -203,6 +204,8 @@ def clearTable(self, table_name): finally: self.releaseCursor() + if cleared_RPC: + self.app.sig_changed_rpcServers.emit() @@ -211,6 +214,7 @@ def clearTable(self, table_name): RPC servers methods ''' def addRPCServer(self, protocol, host, user, passwd): + added_RPC = False try: cursor = self.getCursor() @@ -218,19 +222,21 @@ def addRPCServer(self, protocol, host, user, passwd): "VALUES (?, ?, ?, ?)", (protocol, host, user, passwd) ) - - self.app.sig_changed_rpcServers.emit() + added_RPC = True except Exception as e: err_msg = 'error adding RPC server entry to DB' printException(getCallerName(), getFunctionName(), err_msg, e.args) finally: self.releaseCursor() + if added_RPC: + self.app.sig_changed_rpcServers.emit() def editRPCServer(self, protocol, host, user, passwd, id): + changed_RPC = False try: cursor = self.getCursor() @@ -239,14 +245,15 @@ def editRPCServer(self, protocol, host, user, passwd, id): "WHERE id = ?", (protocol, host, user, passwd, id) ) - - self.app.sig_changed_rpcServers.emit() + changed_RPC = True except Exception as e: err_msg = 'error editing RPC server entry to DB' printException(getCallerName(), getFunctionName(), err_msg, e.args) finally: - self.releaseCursor() + self.releaseCursor() + if changed_RPC: + self.app.sig_changed_rpcServers.emit() @@ -287,12 +294,12 @@ def getRPCServers(self, custom, id=None): def removeRPCServer(self, index): + removed_RPC = False try: cursor = self.getCursor() cursor.execute("DELETE FROM RPC_SERVERS" " WHERE id=?", (index,)) - - self.app.sig_changed_rpcServers.emit() + removed_RPC = True except Exception as e: err_msg = 'error removing RPC servers from database' @@ -300,6 +307,8 @@ def removeRPCServer(self, index): finally: self.releaseCursor() + if removed_RPC: + self.app.sig_changed_rpcServers.emit() diff --git a/src/version.txt b/src/version.txt index f9b87fa..ddbb062 100644 --- a/src/version.txt +++ b/src/version.txt @@ -1,5 +1,5 @@ { "number": "0.3.99", - "tag": "n", - "comments": ["update specfile"] + "tag": "o", + "comments": ["DB signals fix"] } \ No newline at end of file