mirror of
https://github.com/ciromattia/kcc
synced 2025-12-13 09:46:25 +00:00
Fixed multi-instance lock
This commit is contained in:
16
kcc.py
16
kcc.py
@@ -87,8 +87,7 @@ class QApplicationMessaging(QtWidgets.QApplication):
|
||||
self._running = True
|
||||
else:
|
||||
self._running = False
|
||||
if not self._memory.create(1):
|
||||
raise RuntimeError(self._memory.errorString().toLocal8Bit().data())
|
||||
self._memory.create(1)
|
||||
self._key = 'KCC'
|
||||
self._timeout = 1000
|
||||
self._server = QtNetwork.QLocalServer(self)
|
||||
@@ -96,6 +95,10 @@ class QApplicationMessaging(QtWidgets.QApplication):
|
||||
self._server.newConnection.connect(self.handleMessage)
|
||||
self._server.listen(self._key)
|
||||
|
||||
def __del__(self):
|
||||
if self._memory.isAttached():
|
||||
self._memory.detach()
|
||||
|
||||
def isRunning(self):
|
||||
return self._running
|
||||
|
||||
@@ -137,13 +140,8 @@ if __name__ == "__main__":
|
||||
KCCAplication.sendMessage(sys.argv[1])
|
||||
sys.exit(0)
|
||||
else:
|
||||
messageBox = QtWidgets.QMessageBox()
|
||||
icon = QtGui.QIcon()
|
||||
icon.addPixmap(QtGui.QPixmap(':/Icon/icons/comic2ebook.png'), QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||
messageBox.setWindowIcon(icon)
|
||||
QtWidgets.QMessageBox.critical(messageBox, 'KCC - Error', 'KCC is already running!',
|
||||
QtWidgets.QMessageBox.Ok)
|
||||
sys.exit(1)
|
||||
KCCAplication.sendMessage('ARISE')
|
||||
sys.exit(0)
|
||||
KCCWindow = QMainWindowKCC()
|
||||
KCCUI = KCC_gui.KCCGUI(KCCAplication, KCCWindow)
|
||||
if len(sys.argv) > 1:
|
||||
|
||||
@@ -945,7 +945,8 @@ class KCCGUI(KCC_ui.Ui_KCC):
|
||||
def handleMessage(self, message):
|
||||
MW.raise_()
|
||||
MW.activateWindow()
|
||||
if not self.conversionAlive:
|
||||
message = message.decode('UTF-8')
|
||||
if not self.conversionAlive and message != 'ARISE':
|
||||
if self.needClean:
|
||||
self.needClean = False
|
||||
GUI.JobList.clear()
|
||||
|
||||
@@ -1079,4 +1079,4 @@ def checkOptions():
|
||||
(int(X*1.5), int(Y*1.5)))
|
||||
image.ProfileData.Profiles["Custom"] = newProfile
|
||||
options.profile = "Custom"
|
||||
options.profileData = image.ProfileData.Profiles[options.profile]
|
||||
options.profileData = image.ProfileData.Profiles[options.profile]
|
||||
Reference in New Issue
Block a user