Fixed smiley-related file descriptor/handle leak ( hopefully. . . . ;w; )
This commit is contained in:
parent
f43394b4af
commit
a82d460da4
3 changed files with 19 additions and 11 deletions
23
convo.py
23
convo.py
|
@ -323,6 +323,7 @@ class PesterMovie(QtGui.QMovie):
|
||||||
text.document().addResource(QtGui.QTextDocument.ImageResource,
|
text.document().addResource(QtGui.QTextDocument.ImageResource,
|
||||||
text.urls[movie], movie.currentPixmap())
|
text.urls[movie], movie.currentPixmap())
|
||||||
text.setLineWrapColumnOrWidth(text.lineWrapColumnOrWidth())
|
text.setLineWrapColumnOrWidth(text.lineWrapColumnOrWidth())
|
||||||
|
|
||||||
|
|
||||||
class PesterText(QtWidgets.QTextEdit):
|
class PesterText(QtWidgets.QTextEdit):
|
||||||
def __init__(self, theme, parent=None):
|
def __init__(self, theme, parent=None):
|
||||||
|
@ -344,17 +345,25 @@ class PesterText(QtWidgets.QTextEdit):
|
||||||
self.urls = {}
|
self.urls = {}
|
||||||
for k in smiledict:
|
for k in smiledict:
|
||||||
self.addAnimation(QtCore.QUrl("smilies/%s" % (smiledict[k])), "smilies/%s" % (smiledict[k]))
|
self.addAnimation(QtCore.QUrl("smilies/%s" % (smiledict[k])), "smilies/%s" % (smiledict[k]))
|
||||||
self.mainwindow.animationSetting[bool].connect(self.animateChanged)
|
#self.mainwindow.animationSetting[bool].connect(self.animateChanged)
|
||||||
def addAnimation(self, url, fileName):
|
def addAnimation(self, url, fileName):
|
||||||
|
# We don't need to treat images formats like .png as animation,
|
||||||
|
# this always opens a file handler otherwise, "movie.frameCount() > 1" isn't sufficient.
|
||||||
|
# Might be useful to use QImageReader's supportsAnimation function for this?
|
||||||
|
# As long as we're only using gifs there's no advantage to that though.
|
||||||
|
if not fileName.endswith(".gif"):
|
||||||
|
return
|
||||||
|
|
||||||
movie = PesterMovie(self)
|
movie = PesterMovie(self)
|
||||||
movie.setFileName(fileName)
|
movie.setFileName(fileName)
|
||||||
movie.setCacheMode(QtGui.QMovie.CacheAll)
|
self.urls[movie] = url
|
||||||
if movie.frameCount() > 1:
|
movie.frameChanged[int].connect(movie.animate)
|
||||||
self.urls[movie] = url
|
|
||||||
movie.frameChanged[int].connect(movie.animate)
|
"""
|
||||||
#movie.start()
|
|
||||||
@QtCore.pyqtSlot(bool)
|
@QtCore.pyqtSlot(bool)
|
||||||
def animateChanged(self, animate):
|
def animateChanged(self, animate):
|
||||||
|
PchumLog.warning("aaa")
|
||||||
|
|
||||||
if animate:
|
if animate:
|
||||||
for m in self.urls:
|
for m in self.urls:
|
||||||
html = str(self.toHtml())
|
html = str(self.toHtml())
|
||||||
|
@ -367,6 +376,7 @@ class PesterText(QtWidgets.QTextEdit):
|
||||||
if html.find(self.urls[m].toString()) != -1:
|
if html.find(self.urls[m].toString()) != -1:
|
||||||
if m.frameCount() > 1:
|
if m.frameCount() > 1:
|
||||||
m.stop()
|
m.stop()
|
||||||
|
"""
|
||||||
|
|
||||||
@QtCore.pyqtSlot(bool)
|
@QtCore.pyqtSlot(bool)
|
||||||
def textReady(self, ready):
|
def textReady(self, ready):
|
||||||
|
@ -807,6 +817,7 @@ class PesterConvo(QtWidgets.QFrame):
|
||||||
def closeEvent(self, event):
|
def closeEvent(self, event):
|
||||||
self.mainwindow.waitingMessages.messageAnswered(self.title())
|
self.mainwindow.waitingMessages.messageAnswered(self.title())
|
||||||
for movie in self.textArea.urls:
|
for movie in self.textArea.urls:
|
||||||
|
movie.setFileName("") # Required, sometimes, for some reason. . .
|
||||||
movie.stop()
|
movie.stop()
|
||||||
del movie
|
del movie
|
||||||
self.windowClosed.emit(self.title())
|
self.windowClosed.emit(self.title())
|
||||||
|
|
2
memos.py
2
memos.py
|
@ -278,7 +278,7 @@ class MemoText(PesterText):
|
||||||
self.urls = {}
|
self.urls = {}
|
||||||
for k in smiledict:
|
for k in smiledict:
|
||||||
self.addAnimation(QtCore.QUrl("smilies/%s" % (smiledict[k])), "smilies/%s" % (smiledict[k]))
|
self.addAnimation(QtCore.QUrl("smilies/%s" % (smiledict[k])), "smilies/%s" % (smiledict[k]))
|
||||||
self.mainwindow.animationSetting[bool].connect(self.animateChanged)
|
#self.mainwindow.animationSetting[bool].connect(self.animateChanged)
|
||||||
|
|
||||||
def initTheme(self, theme):
|
def initTheme(self, theme):
|
||||||
if "memos/scrollbar" in theme:
|
if "memos/scrollbar" in theme:
|
||||||
|
|
|
@ -2865,10 +2865,7 @@ class PesterWindow(MovingWindow):
|
||||||
if opvmesssetting != curopvmess:
|
if opvmesssetting != curopvmess:
|
||||||
self.config.set('opvMessages', opvmesssetting)
|
self.config.set('opvMessages', opvmesssetting)
|
||||||
# animated smiles
|
# animated smiles
|
||||||
if ostools.isOSXBundle():
|
animatesetting = self.optionmenu.animationscheck.isChecked()
|
||||||
animatesetting = False;
|
|
||||||
else:
|
|
||||||
animatesetting = self.optionmenu.animationscheck.isChecked()
|
|
||||||
curanimate = self.config.animations()
|
curanimate = self.config.animations()
|
||||||
if animatesetting != curanimate:
|
if animatesetting != curanimate:
|
||||||
self.config.set('animations', animatesetting)
|
self.config.set('animations', animatesetting)
|
||||||
|
|
Loading…
Reference in a new issue