Fix #8017: Crash copying croped image to clipboard

This commit is contained in:
Vladimir Vainer 2017-06-29 16:11:57 +03:00
parent 8a62d81fc5
commit 5f2dd2ef6c

View file

@ -7,6 +7,7 @@
#include "atom/common/native_mate_converters/image_converter.h" #include "atom/common/native_mate_converters/image_converter.h"
#include "atom/common/native_mate_converters/string16_converter.h" #include "atom/common/native_mate_converters/string16_converter.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/base/clipboard/scoped_clipboard_writer.h" #include "ui/base/clipboard/scoped_clipboard_writer.h"
#include "atom/common/node_includes.h" #include "atom/common/node_includes.h"
@ -166,7 +167,12 @@ gfx::Image Clipboard::ReadImage(mate::Arguments* args) {
void Clipboard::WriteImage(const gfx::Image& image, mate::Arguments* args) { void Clipboard::WriteImage(const gfx::Image& image, mate::Arguments* args) {
ui::ScopedClipboardWriter writer(GetClipboardType(args)); ui::ScopedClipboardWriter writer(GetClipboardType(args));
writer.WriteImage(image.AsBitmap()); SkBitmap bmp;
if (image.AsBitmap().deepCopyTo(&bmp)) {
writer.WriteImage(bmp);
} else {
writer.WriteImage(image.AsBitmap());
}
} }
#if !defined(OS_MACOSX) #if !defined(OS_MACOSX)