Commit 14ade472 authored by Adrian Georgescu's avatar Adrian Georgescu

Fixed caching contact icon

parent 9573dece
...@@ -119,6 +119,7 @@ class IconManager(object, metaclass=Singleton): ...@@ -119,6 +119,7 @@ class IconManager(object, metaclass=Singleton):
@run_in_gui_thread(wait=True) @run_in_gui_thread(wait=True)
def store_data(self, id, data): def store_data(self, id, data):
data = data if isinstance(data, bytes) else data.encode()
id = id.replace('/', '_') id = id.replace('/', '_')
directory = ApplicationData.get('images') directory = ApplicationData.get('images')
filename = os.path.join(directory, id + '.png') filename = os.path.join(directory, id + '.png')
...@@ -133,7 +134,7 @@ class IconManager(object, metaclass=Singleton): ...@@ -133,7 +134,7 @@ class IconManager(object, metaclass=Singleton):
pixmap.save(buffer, 'png') pixmap.save(buffer, 'png')
data = str(buffer.data()) data = str(buffer.data())
with open(filename, 'wb') as f: with open(filename, 'wb') as f:
f.write(data.encode()) f.write(data)
icon = QIcon(pixmap) icon = QIcon(pixmap)
icon.filename = filename icon.filename = filename
icon.content = data icon.content = data
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment