Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 585e0fa

Browse files
committed
Merge pull request matplotlib#1034 from mdehoon/fix_for_issue_1013
MdH = allow compilation on recent Mac OS X without compiler warnings
2 parents 60b641d + a4ed0cf commit 585e0fa

File tree

1 file changed

+25
-8
lines changed

1 file changed

+25
-8
lines changed

src/_macosx.m

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,11 @@ - (void)masterCloses:(NSNotification*)notification;
355355
- (void)close;
356356
@end
357357

358+
#ifdef COMPILING_FOR_10_6
359+
@interface View : NSView <NSWindowDelegate>
360+
#else
358361
@interface View : NSView
362+
#endif
359363
{ PyObject* canvas;
360364
NSRect rubberband;
361365
BOOL inside;
@@ -4244,14 +4248,22 @@ -(void)save_figure:(id)sender
42444248
self->handler = [self->handler initWithToolbar: (PyObject*)self];
42454249
for (i = 0; i < 9; i++)
42464250
{
4247-
ScrollableButton* button;
4251+
NSButton* button;
42484252
SEL scrollWheelUpAction = scroll_actions[i][0];
42494253
SEL scrollWheelDownAction = scroll_actions[i][1];
4250-
if (scrollWheelUpAction || scrollWheelDownAction)
4251-
button = [ScrollableButton alloc];
4254+
if (scrollWheelUpAction && scrollWheelDownAction)
4255+
{
4256+
ScrollableButton* scrollable_button = [ScrollableButton alloc];
4257+
[scrollable_button initWithFrame: rect];
4258+
[scrollable_button setScrollWheelUpAction: scrollWheelUpAction];
4259+
[scrollable_button setScrollWheelDownAction: scrollWheelDownAction];
4260+
button = (NSButton*)scrollable_button;
4261+
}
42524262
else
4263+
{
42534264
button = [NSButton alloc];
4254-
[button initWithFrame: rect];
4265+
[button initWithFrame: rect];
4266+
}
42554267
PyObject* imagedata = PyDict_GetItemString(images, imagenames[i]);
42564268
NSImage* image = _read_ppm_image(imagedata);
42574269
[button setBezelStyle: NSShadowlessSquareBezelStyle];
@@ -4264,10 +4276,6 @@ -(void)save_figure:(id)sender
42644276
[button setToolTip: tooltips[i]];
42654277
[button setTarget: self->handler];
42664278
[button setAction: actions[i]];
4267-
if (scrollWheelUpAction)
4268-
[button setScrollWheelUpAction: scrollWheelUpAction];
4269-
if (scrollWheelDownAction)
4270-
[button setScrollWheelDownAction: scrollWheelDownAction];
42714279
[[window contentView] addSubview: button];
42724280
[button release];
42734281
rect.origin.x += rect.size.width + smallgap;
@@ -4929,7 +4937,16 @@ -(void)save_figure:(id)sender
49294937
[ns_default_filename release];
49304938
if (result == NSOKButton)
49314939
{
4940+
#ifdef COMPILING_FOR_10_6
4941+
NSURL* url = [panel URL];
4942+
NSString* filename = [url path];
4943+
if (!filename) {
4944+
PyErr_SetString(PyExc_RuntimeError, "Failed to obtain filename");
4945+
return 0;
4946+
}
4947+
#else
49324948
NSString* filename = [panel filename];
4949+
#endif
49334950
unsigned int n = [filename length];
49344951
unichar* buffer = malloc(n*sizeof(unichar));
49354952
[filename getCharacters: buffer];

0 commit comments

Comments
 (0)