Skip to content
Snippets Groups Projects
Commit 5db330e1 authored by George Nachman's avatar George Nachman
Browse files

Don't allow saving broken images, as it just saves the broken image icon. Issue 5971

parent 9a0a5a8e
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -4618,7 +4618,7 @@ static double EuclideanDistance(NSPoint p1, NSPoint p2) {
// Allocate a menu
theMenu = [[[NSMenu alloc] initWithTitle:@"Contextual Menu"] autorelease];
iTermImageInfo *imageInfo = [self imageInfoAtCoord:coord];
if (imageInfo) {
if (imageInfo && !imageInfo.broken) {
// Show context menu for an image.
NSArray *entryDicts =
@[ @{ @"title": @"Save Image As…",
Loading
Loading
Loading
Loading
@@ -11,6 +11,7 @@
#import "iTermExpose.h"
#import "iTermGrowlDelegate.h"
#import "iTermImage.h"
#import "iTermImageInfo.h"
#import "iTermImageMark.h"
#import "iTermURLMark.h"
#import "iTermPreferences.h"
Loading
Loading
@@ -3411,7 +3412,8 @@ static NSString *const kInilineFileInset = @"inset"; // NSValue of NSEdgeInsets
} else {
image = [iTermImage imageWithCompressedData:data];
}
if (!image) {
const BOOL isBroken = !image;
if (isBroken) {
image = [iTermImage imageWithNativeImage:[NSImage imageNamed:@"broken_image"]];
assert(image);
}
Loading
Loading
@@ -3500,6 +3502,8 @@ static NSString *const kInilineFileInset = @"inset"; // NSValue of NSEdgeInsets
height,
preserveAspectRatio,
fractionalInset);
iTermImageInfo *imageInfo = GetImageInfo(c.code);
imageInfo.broken = isBroken;
for (int y = 0; y < height; y++) {
if (y > 0) {
[self linefeed];
Loading
Loading
Loading
Loading
@@ -56,6 +56,9 @@ extern NSString *const iTermImageDidLoad;
// Creates a pasteboard item that responds with image or file.
@property(nonatomic, readonly) NSPasteboardItem *pasteboardItem;
 
// Is this a broken image?
@property(nonatomic) BOOL broken;
// Used to create a new instance for a new image. This may remain an empty container until
// -setImageFromImage: is called.
- (instancetype)initWithCode:(unichar)code;
Loading
Loading
Loading
Loading
@@ -22,6 +22,7 @@ static NSString *const kImageInfoPreserveAspectRatioKey = @"Preserve Aspect Rati
static NSString *const kImageInfoFilenameKey = @"Filename";
static NSString *const kImageInfoInsetKey = @"Edge Insets";
static NSString *const kImageInfoCodeKey = @"Code";
static NSString *const kImageInfoBrokenKey = @"Broken";
 
NSString *const iTermImageDidLoad = @"iTermImageDidLoad";
 
Loading
Loading
@@ -51,6 +52,7 @@ NSString *const iTermImageDidLoad = @"iTermImageDidLoad";
self = [super init];
if (self) {
_size = [dictionary[kImageInfoSizeKey] sizeValue];
_broken = [dictionary[kImageInfoBrokenKey] boolValue];
_inset = [dictionary[kImageInfoInsetKey] futureEdgeInsetsValue];
_data = [dictionary[kImageInfoImageKey] retain];
_dictionary = [dictionary copy];
Loading
Loading
@@ -202,7 +204,8 @@ NSString *const iTermImageDidLoad = @"iTermImageDidLoad";
kImageInfoImageKey: _data ?: [NSData data],
kImageInfoPreserveAspectRatioKey: @(_preserveAspectRatio),
kImageInfoFilenameKey: _filename ?: @"",
kImageInfoCodeKey: @(_code)};
kImageInfoCodeKey: @(_code),
kImageInfoBrokenKey: @(_broken) };
}
 
 
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment