aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2014-08-04 17:16:00 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2014-08-04 17:16:12 +0200
commit8d0d512bde834fe4abb618b9a139355ef8780e95 (patch)
tree76f73fa8620024ad7ef8d3a8a68ca05a49b26a08
parent70b9d36a2c7b900a80323e33ddc06b14d28fe538 (diff)
parentbd0aa105198d3cc12751dc4645877af70cac6258 (diff)
Merge pull request #4606
bd0aa10 Replace the temporary file hack currently used to change Bitcoin-Qt's dock icon (OS X) with a buffer-based solution. (Doug)
-rw-r--r--src/qt/macdockiconhandler.mm16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/qt/macdockiconhandler.mm b/src/qt/macdockiconhandler.mm
index 74fb64ace3..a2ff148d9d 100644
--- a/src/qt/macdockiconhandler.mm
+++ b/src/qt/macdockiconhandler.mm
@@ -6,7 +6,7 @@
#include <QImageWriter>
#include <QMenu>
-#include <QTemporaryFile>
+#include <QBuffer>
#include <QWidget>
#undef slots
@@ -95,14 +95,14 @@ void MacDockIconHandler::setIcon(const QIcon &icon)
QSize size = icon.actualSize(QSize(128, 128));
QPixmap pixmap = icon.pixmap(size);
- // write temp file hack (could also be done through QIODevice [memory])
- QTemporaryFile notificationIconFile;
- if (!pixmap.isNull() && notificationIconFile.open()) {
- QImageWriter writer(&notificationIconFile, "PNG");
+ // Write image into a R/W buffer from raw pixmap, then save the image.
+ QBuffer notificationBuffer;
+ if (!pixmap.isNull() && notificationBuffer.open(QIODevice::ReadWrite)) {
+ QImageWriter writer(&notificationBuffer, "PNG");
if (writer.write(pixmap.toImage())) {
- const char *cString = notificationIconFile.fileName().toUtf8().data();
- NSString *macString = [NSString stringWithCString:cString encoding:NSUTF8StringEncoding];
- image = [[NSImage alloc] initWithContentsOfFile:macString];
+ NSData* macImgData = [NSData dataWithBytes:notificationBuffer.buffer().data()
+ length:notificationBuffer.buffer().size()];
+ image = [[NSImage alloc] initWithData:macImgData];
}
}