|
From: <jo...@us...> - 2009-08-22 04:19:52
|
Revision: 7518
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7518&view=rev
Author: jouni
Date: 2009-08-22 04:19:45 +0000 (Sat, 22 Aug 2009)
Log Message:
-----------
Changed the way the target OS X version is determined in _macosx.m.
Modified Paths:
--------------
trunk/matplotlib/src/_macosx.m
Modified: trunk/matplotlib/src/_macosx.m
===================================================================
--- trunk/matplotlib/src/_macosx.m 2009-08-22 00:02:15 UTC (rev 7517)
+++ trunk/matplotlib/src/_macosx.m 2009-08-22 04:19:45 UTC (rev 7518)
@@ -5,11 +5,16 @@
#include "numpy/arrayobject.h"
#include "path_cleanup.h"
+/* Proper way to check for the OS X version we are compiling for, from
+ http://developer.apple.com/documentation/DeveloperTools/Conceptual/cross_development */
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
+#define COMPILING_FOR_10_5
+#endif
static int nwin = 0; /* The number of open windows */
/* Use Atsui for Mac OS X 10.4, CoreText for Mac OS X 10.5 */
-#ifndef MAC_OS_X_VERSION_10_5
+#ifndef COMPILING_FOR_10_5
static int ngc = 0; /* The number of graphics contexts in use */
@@ -175,7 +180,7 @@
return 1;
}
-#ifndef MAC_OS_X_VERSION_10_5
+#ifndef COMPILING_FOR_10_5
static int _init_atsui(void)
{
OSStatus status;
@@ -451,7 +456,7 @@
self->cr = NULL;
self->level = 0;
-#ifndef MAC_OS_X_VERSION_10_5
+#ifndef COMPILING_FOR_10_5
if (ngc==0)
{
int ok = _init_atsui();
@@ -466,7 +471,7 @@
return (PyObject*) self;
}
-#ifndef MAC_OS_X_VERSION_10_5
+#ifndef COMPILING_FOR_10_5
static void
GraphicsContext_dealloc(GraphicsContext *self)
{
@@ -1877,7 +1882,7 @@
}
-#ifdef MAC_OS_X_VERSION_10_5
+#ifdef COMPILING_FOR_10_5
static CTFontRef
#else
static ATSFontRef
@@ -1891,7 +1896,7 @@
const char* temp;
const char* name = "Times-Roman";
CFStringRef string;
-#ifdef MAC_OS_X_VERSION_10_5
+#ifdef COMPILING_FOR_10_5
CTFontRef font = 0;
#else
ATSFontRef font = 0;
@@ -2091,7 +2096,7 @@
string = CFStringCreateWithCString(kCFAllocatorDefault,
temp,
kCFStringEncodingMacRoman);
-#ifdef MAC_OS_X_VERSION_10_5
+#ifdef COMPILING_FOR_10_5
font = CTFontCreateWithName(string, size, NULL);
#else
font = ATSFontFindFromPostScriptName(string, kATSOptionFlagsDefault);
@@ -2109,20 +2114,20 @@
{ string = CFStringCreateWithCString(kCFAllocatorDefault,
name,
kCFStringEncodingMacRoman);
-#ifdef MAC_OS_X_VERSION_10_5
+#ifdef COMPILING_FOR_10_5
font = CTFontCreateWithName(string, size, NULL);
#else
font = ATSFontFindFromPostScriptName(string, kATSOptionFlagsDefault);
#endif
CFRelease(string);
}
-#ifndef MAC_OS_X_VERSION_10_5
+#ifndef COMPILING_FOR_10_5
CGContextSelectFont(cr, name, size, kCGEncodingMacRoman);
#endif
return font;
}
-#ifdef MAC_OS_X_VERSION_10_5
+#ifdef COMPILING_FOR_10_5
static PyObject*
GraphicsContext_draw_text (GraphicsContext* self, PyObject* args)
{
@@ -2821,7 +2826,7 @@
"_macosx.GraphicsContext", /*tp_name*/
sizeof(GraphicsContext), /*tp_basicsize*/
0, /*tp_itemsize*/
-#ifdef MAC_OS_X_VERSION_10_5
+#ifdef COMPILING_FOR_10_5
0, /*tp_dealloc*/
#else
(destructor)GraphicsContext_dealloc, /*tp_dealloc*/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2009-09-02 00:44:23
|
Revision: 7627
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7627&view=rev
Author: mdehoon
Date: 2009-09-02 00:44:16 +0000 (Wed, 02 Sep 2009)
Log Message:
-----------
Allowing mouse dragging with three-button mice.
Modified Paths:
--------------
trunk/matplotlib/src/_macosx.m
Modified: trunk/matplotlib/src/_macosx.m
===================================================================
--- trunk/matplotlib/src/_macosx.m 2009-09-01 14:44:50 UTC (rev 7626)
+++ trunk/matplotlib/src/_macosx.m 2009-09-02 00:44:16 UTC (rev 7627)
@@ -349,8 +349,10 @@
- (void)mouseMoved:(NSEvent*)event;
- (void)rightMouseDown:(NSEvent*)event;
- (void)rightMouseUp:(NSEvent*)event;
+- (void)rightMouseDragged:(NSEvent*)event;
- (void)otherMouseDown:(NSEvent*)event;
- (void)otherMouseUp:(NSEvent*)event;
+- (void)otherMouseDragged:(NSEvent*)event;
- (void)setRubberband:(NSRect)rect;
- (void)removeRubberband;
- (const char*)convertKeyEvent:(NSEvent*)event;
@@ -4744,6 +4746,23 @@
PyGILState_Release(gstate);
}
+- (void)rightMouseDragged:(NSEvent *)event
+{
+ int x, y;
+ NSPoint location = [event locationInWindow];
+ location = [self convertPoint: location fromView: nil];
+ x = location.x;
+ y = location.y;
+ PyGILState_STATE gstate = PyGILState_Ensure();
+ PyObject* result = PyObject_CallMethod(canvas, "motion_notify_event", "ii", x, y);
+ if(result)
+ Py_DECREF(result);
+ else
+ PyErr_Print();
+
+ PyGILState_Release(gstate);
+}
+
- (void)otherMouseDown:(NSEvent *)event
{
int x, y;
@@ -4784,6 +4803,23 @@
PyGILState_Release(gstate);
}
+- (void)otherMouseDragged:(NSEvent *)event
+{
+ int x, y;
+ NSPoint location = [event locationInWindow];
+ location = [self convertPoint: location fromView: nil];
+ x = location.x;
+ y = location.y;
+ PyGILState_STATE gstate = PyGILState_Ensure();
+ PyObject* result = PyObject_CallMethod(canvas, "motion_notify_event", "ii", x, y);
+ if(result)
+ Py_DECREF(result);
+ else
+ PyErr_Print();
+
+ PyGILState_Release(gstate);
+}
+
- (void)setRubberband:(NSRect)rect
{
if (!NSIsEmptyRect(rubberband)) [self setNeedsDisplayInRect: rubberband];
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2009-11-03 13:54:04
|
Revision: 7918
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7918&view=rev
Author: mdehoon
Date: 2009-11-03 13:53:57 +0000 (Tue, 03 Nov 2009)
Log Message:
-----------
Make sure that the FigureCanvas and the View are deallocated.
Previously, the Py_INCREF ensured that the reference count of FigureCanvas
never reaches zero. The FigureCanvas was therefore never deallocated, and
the View remained in memory.
See bug #2889570 on bugzilla, reported by Nicholas Lederer.
Modified Paths:
--------------
trunk/matplotlib/src/_macosx.m
Modified: trunk/matplotlib/src/_macosx.m
===================================================================
--- trunk/matplotlib/src/_macosx.m 2009-11-02 18:58:46 UTC (rev 7917)
+++ trunk/matplotlib/src/_macosx.m 2009-11-03 13:53:57 UTC (rev 7918)
@@ -340,7 +340,8 @@
- (void)dealloc;
- (void)drawRect:(NSRect)rect;
- (void)windowDidResize:(NSNotification*)notification;
-- (View*)initWithFrame:(NSRect)rect canvas:(PyObject*)fc;
+- (View*)initWithFrame:(NSRect)rect;
+- (void)setCanvas: (PyObject*)newCanvas;
- (BOOL)windowShouldClose:(NSNotification*)notification;
- (BOOL)isFlipped;
- (void)mouseDown:(NSEvent*)event;
@@ -2896,10 +2897,22 @@
if(!PyArg_ParseTuple(args, "ii", &width, &height)) return -1;
NSRect rect = NSMakeRect(0.0, 0.0, width, height);
- self->view = [self->view initWithFrame: rect canvas: (PyObject*)self];
+ self->view = [self->view initWithFrame: rect];
+ [self->view setCanvas: (PyObject*)self];
return 0;
}
+static void
+FigureCanvas_dealloc(FigureCanvas* self)
+{
+ if (self->view)
+ {
+ [self->view setCanvas: NULL];
+ [self->view release];
+ }
+ self->ob_type->tp_free((PyObject*)self);
+}
+
static PyObject*
FigureCanvas_repr(FigureCanvas* self)
{
@@ -3243,7 +3256,7 @@
"_macosx.FigureCanvas", /*tp_name*/
sizeof(FigureCanvas), /*tp_basicsize*/
0, /*tp_itemsize*/
- 0, /*tp_dealloc*/
+ (destructor)FigureCanvas_dealloc, /*tp_dealloc*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
@@ -4483,27 +4496,25 @@
return NO;
}
-- (View*)initWithFrame:(NSRect)rect canvas: (PyObject*)fc
+- (View*)initWithFrame:(NSRect)rect
{
self = [super initWithFrame: rect];
rubberband = NSZeroRect;
- if (canvas)
- {
- Py_DECREF(canvas);
- }
- canvas = fc;
- Py_INCREF(canvas);
return self;
}
- (void)dealloc
{
FigureCanvas* fc = (FigureCanvas*)canvas;
- fc->view = NULL;
- Py_DECREF(canvas);
+ if (fc) fc->view = NULL;
[super dealloc];
}
+- (void)setCanvas: (PyObject*)newCanvas
+{
+ canvas = newCanvas;
+}
+
-(void)drawRect:(NSRect)rect
{
PyObject* result;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2010-02-16 14:31:10
|
Revision: 8134
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8134&view=rev
Author: mdehoon
Date: 2010-02-16 14:31:02 +0000 (Tue, 16 Feb 2010)
Log Message:
-----------
Keeping track of the mouse entering and exiting a window, and moving over an
active window.
Modified Paths:
--------------
trunk/matplotlib/src/_macosx.m
Modified: trunk/matplotlib/src/_macosx.m
===================================================================
--- trunk/matplotlib/src/_macosx.m 2010-02-15 16:38:50 UTC (rev 8133)
+++ trunk/matplotlib/src/_macosx.m 2010-02-16 14:31:02 UTC (rev 8134)
@@ -336,6 +336,8 @@
@interface View : NSView
{ PyObject* canvas;
NSRect rubberband;
+ BOOL inside;
+ NSTrackingRectTag tracking;
}
- (void)dealloc;
- (void)drawRect:(NSRect)rect;
@@ -344,6 +346,8 @@
- (void)setCanvas: (PyObject*)newCanvas;
- (BOOL)windowShouldClose:(NSNotification*)notification;
- (BOOL)isFlipped;
+- (void)mouseEntered:(NSEvent*)event;
+- (void)mouseExited:(NSEvent*)event;
- (void)mouseDown:(NSEvent*)event;
- (void)mouseUp:(NSEvent*)event;
- (void)mouseDragged:(NSEvent*)event;
@@ -4463,6 +4467,8 @@
{
self = [super initWithFrame: rect];
rubberband = NSZeroRect;
+ inside = false;
+ tracking = nil;
return self;
}
@@ -4470,6 +4476,7 @@
{
FigureCanvas* fc = (FigureCanvas*)canvas;
if (fc) fc->view = NULL;
+ [self removeTrackingRect: tracking];
[super dealloc];
}
@@ -4551,6 +4558,11 @@
else
PyErr_Print();
PyGILState_Release(gstate);
+ if (tracking) [self removeTrackingRect: tracking];
+ tracking = [self addTrackingRect: [self bounds]
+ owner: self
+ userData: nil
+ assumeInside: NO];
[self setNeedsDisplay: YES];
}
@@ -4575,6 +4587,45 @@
return YES;
}
+- (void)mouseEntered:(NSEvent *)event
+{
+ PyGILState_STATE gstate;
+ PyObject* result;
+ NSWindow* window = [self window];
+ if ([window isKeyWindow]==false) return;
+
+ gstate = PyGILState_Ensure();
+ result = PyObject_CallMethod(canvas, "enter_notify_event", "");
+ if(result)
+ Py_DECREF(result);
+ else
+ PyErr_Print();
+ PyGILState_Release(gstate);
+
+ [window setAcceptsMouseMovedEvents: YES];
+ inside = true;
+}
+
+- (void)mouseExited:(NSEvent *)event
+{
+ PyGILState_STATE gstate;
+ PyObject* result;
+ NSWindow* window = [self window];
+ if ([window isKeyWindow]==false) return;
+
+ if (inside==false) return;
+ gstate = PyGILState_Ensure();
+ result = PyObject_CallMethod(canvas, "leave_notify_event", "");
+ if(result)
+ Py_DECREF(result);
+ else
+ PyErr_Print();
+ PyGILState_Release(gstate);
+
+ [[self window] setAcceptsMouseMovedEvents: NO];
+ inside = false;
+}
+
- (void)mouseDown:(NSEvent *)event
{
int x, y;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2010-02-17 02:15:21
|
Revision: 8137
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8137&view=rev
Author: mdehoon
Date: 2010-02-17 02:15:13 +0000 (Wed, 17 Feb 2010)
Log Message:
-----------
Fixing a compiler warning.
Modified Paths:
--------------
trunk/matplotlib/src/_macosx.m
Modified: trunk/matplotlib/src/_macosx.m
===================================================================
--- trunk/matplotlib/src/_macosx.m 2010-02-16 23:09:50 UTC (rev 8136)
+++ trunk/matplotlib/src/_macosx.m 2010-02-17 02:15:13 UTC (rev 8137)
@@ -4468,7 +4468,7 @@
self = [super initWithFrame: rect];
rubberband = NSZeroRect;
inside = false;
- tracking = nil;
+ tracking = 0;
return self;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2010-04-17 13:45:19
|
Revision: 8240
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8240&view=rev
Author: mdehoon
Date: 2010-04-17 13:45:13 +0000 (Sat, 17 Apr 2010)
Log Message:
-----------
Fixing bug #2891502 by allowing window sizes larger than the screen.
Modified Paths:
--------------
trunk/matplotlib/src/_macosx.m
Modified: trunk/matplotlib/src/_macosx.m
===================================================================
--- trunk/matplotlib/src/_macosx.m 2010-04-16 19:02:22 UTC (rev 8239)
+++ trunk/matplotlib/src/_macosx.m 2010-04-17 13:45:13 UTC (rev 8240)
@@ -320,6 +320,7 @@
{ PyObject* manager;
}
- (Window*)initWithContentRect:(NSRect)rect styleMask:(unsigned int)mask backing:(NSBackingStoreType)bufferingType defer:(BOOL)deferCreation withManager: (PyObject*)theManager;
+- (NSRect)constrainFrameRect:(NSRect)rect toScreen:(NSScreen*)screen;
- (BOOL)closeButtonPressed;
- (void)close;
- (void)dealloc;
@@ -4396,6 +4397,16 @@
return self;
}
+- (NSRect)constrainFrameRect:(NSRect)rect toScreen:(NSScreen*)screen
+{
+ /* Allow window sizes larger than the screen */
+ NSRect suggested = [super constrainFrameRect: rect toScreen: screen];
+ const CGFloat difference = rect.size.height - suggested.size.height;
+ suggested.origin.y -= difference;
+ suggested.size.height += difference;
+ return suggested;
+}
+
- (BOOL)closeButtonPressed
{
PyObject* result;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2010-10-09 01:15:12
|
Revision: 8738
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8738&view=rev
Author: mdehoon
Date: 2010-10-09 01:15:06 +0000 (Sat, 09 Oct 2010)
Log Message:
-----------
See bug #3081512. Set line widths correctly in draw_quad_mesh.
Modified Paths:
--------------
trunk/matplotlib/src/_macosx.m
Modified: trunk/matplotlib/src/_macosx.m
===================================================================
--- trunk/matplotlib/src/_macosx.m 2010-10-08 18:16:54 UTC (rev 8737)
+++ trunk/matplotlib/src/_macosx.m 2010-10-09 01:15:06 UTC (rev 8738)
@@ -1758,8 +1758,6 @@
/* Preset graphics context properties if possible */
CGContextSetShouldAntialias(cr, antialiased);
- CGContextSetLineWidth(cr, 0.0);
-
if (Nfacecolors==1)
{
const double r = *(double*)PyArray_GETPTR2(facecolors, 0, 0);
@@ -1822,6 +1820,7 @@
CGContextMoveToPoint(cr, points[3].x, points[3].y);
CGContextAddLines(cr, points, 4);
+ CGContextClosePath(cr);
if (Nfacecolors > 1)
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2010-10-23 03:34:58
|
Revision: 8762
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8762&view=rev
Author: mdehoon
Date: 2010-10-23 03:34:52 +0000 (Sat, 23 Oct 2010)
Log Message:
-----------
Implement close_event in the Mac OS X native backend.
Modified Paths:
--------------
trunk/matplotlib/src/_macosx.m
Modified: trunk/matplotlib/src/_macosx.m
===================================================================
--- trunk/matplotlib/src/_macosx.m 2010-10-22 16:20:15 UTC (rev 8761)
+++ trunk/matplotlib/src/_macosx.m 2010-10-23 03:34:52 UTC (rev 8762)
@@ -346,6 +346,7 @@
- (void)windowDidResize:(NSNotification*)notification;
- (View*)initWithFrame:(NSRect)rect;
- (void)setCanvas: (PyObject*)newCanvas;
+- (void)windowWillClose:(NSNotification*)notification;
- (BOOL)windowShouldClose:(NSNotification*)notification;
- (BOOL)isFlipped;
- (void)mouseEntered:(NSEvent*)event;
@@ -4935,6 +4936,20 @@
[self setNeedsDisplay: YES];
}
+- (void)windowWillClose:(NSNotification*)notification
+{
+ PyGILState_STATE gstate;
+ PyObject* result;
+
+ gstate = PyGILState_Ensure();
+ result = PyObject_CallMethod(canvas, "close_event", "");
+ if(result)
+ Py_DECREF(result);
+ else
+ PyErr_Print();
+ PyGILState_Release(gstate);
+}
+
- (BOOL)windowShouldClose:(NSNotification*)notification
{
NSWindow* window = [self window];
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2011-01-03 13:45:27
|
Revision: 8872
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8872&view=rev
Author: mdehoon
Date: 2011-01-03 13:45:21 +0000 (Mon, 03 Jan 2011)
Log Message:
-----------
Making the necessary changes for Python 3.
Modified Paths:
--------------
trunk/matplotlib/src/_macosx.m
Modified: trunk/matplotlib/src/_macosx.m
===================================================================
--- trunk/matplotlib/src/_macosx.m 2011-01-02 22:46:13 UTC (rev 8871)
+++ trunk/matplotlib/src/_macosx.m 2011-01-03 13:45:21 UTC (rev 8872)
@@ -5,6 +5,17 @@
#include "numpy/arrayobject.h"
#include "path_cleanup.h"
+/* Must define Py_TYPE for Python 2.5 or older */
+#ifndef Py_TYPE
+# define Py_TYPE(o) ((o)->ob_type)
+#endif
+
+/* Must define PyVarObject_HEAD_INIT for Python 2.5 or older */
+#ifndef PyVarObject_HEAD_INIT
+#define PyVarObject_HEAD_INIT(type, size) \
+ PyObject_HEAD_INIT(type) size,
+#endif
+
/* Proper way to check for the OS X version we are compiling for, from
http://developer.apple.com/documentation/DeveloperTools/Conceptual/cross_development */
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
@@ -488,14 +499,18 @@
ngc--;
if (ngc==0) _dealloc_atsui();
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
#endif
static PyObject*
GraphicsContext_repr(GraphicsContext* self)
{
+#if PY_MAJOR_VERSION >= 3
+ return PyUnicode_FromFormat("GraphicsContext object %p wrapping the Quartz 2D graphics context %p", (void*)self, (void*)(self->cr));
+#else
return PyString_FromFormat("GraphicsContext object %p wrapping the Quartz 2D graphics context %p", (void*)self, (void*)(self->cr));
+#endif
}
static PyObject*
@@ -2236,6 +2251,9 @@
#else
ATSFontRef font = 0;
#endif
+#if PY_MAJOR_VERSION >= 3
+ PyObject* ascii = NULL;
+#endif
const int k = (strcmp(italic, "italic") ? 0 : 2)
+ (strcmp(weight, "bold") ? 0 : 1);
@@ -2416,8 +2434,14 @@
for (i = 0; i < n; i++)
{
PyObject* item = PyList_GET_ITEM(family, i);
+#if PY_MAJOR_VERSION >= 3
+ ascii = PyUnicode_AsASCIIString(item);
+ if(!ascii) return 0;
+ temp = PyBytes_AS_STRING(ascii);
+#else
if(!PyString_Check(item)) return 0;
temp = PyString_AS_STRING(item);
+#endif
for (j = 0; j < NMAP; j++)
{ if (!strcmp(map[j].name, temp))
{ temp = psnames[map[j].index][k];
@@ -2444,6 +2468,10 @@
name = temp;
break;
}
+#if PY_MAJOR_VERSION >= 3
+ Py_DECREF(ascii);
+ ascii = NULL;
+#endif
}
if(!font)
{ string = CFStringCreateWithCString(kCFAllocatorDefault,
@@ -2459,6 +2487,9 @@
#ifndef COMPILING_FOR_10_5
CGContextSelectFont(cr, name, size, kCGEncodingMacRoman);
#endif
+#if PY_MAJOR_VERSION >= 3
+ Py_XDECREF(ascii);
+#endif
return font;
}
@@ -2958,11 +2989,19 @@
CGDataProviderRef provider;
double rect[4] = {0.0, 0.0, self->size.width, self->size.height};
+#if PY_MAJOR_VERSION >= 3
+ if (!PyBytes_Check(image))
+ {
+ PyErr_SetString(PyExc_RuntimeError, "image is not a byte array");
+ return NULL;
+ }
+#else
if (!PyString_Check(image))
{
PyErr_SetString(PyExc_RuntimeError, "image is not a string");
return NULL;
}
+#endif
const size_t bytesPerComponent = 1;
const size_t bitsPerComponent = 8 * bytesPerComponent;
@@ -2978,8 +3017,13 @@
}
Py_INCREF(image);
+#if PY_MAJOR_VERSION >= 3
+ n = PyByteArray_GET_SIZE(image);
+ data = PyByteArray_AS_STRING(image);
+#else
n = PyString_GET_SIZE(image);
data = PyString_AsString(image);
+#endif
provider = CGDataProviderCreateWithData(image,
data,
@@ -3161,8 +3205,7 @@
"set_joinstyle, etc.).\n";
static PyTypeObject GraphicsContextType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_macosx.GraphicsContext", /*tp_name*/
sizeof(GraphicsContext), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -3247,14 +3290,19 @@
[self->view setCanvas: NULL];
[self->view release];
}
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject*
FigureCanvas_repr(FigureCanvas* self)
{
+#if PY_MAJOR_VERSION >= 3
+ return PyUnicode_FromFormat("FigureCanvas object %p wrapping NSView %p",
+ (void*)self, (void*)(self->view));
+#else
return PyString_FromFormat("FigureCanvas object %p wrapping NSView %p",
(void*)self, (void*)(self->view));
+#endif
}
static PyObject*
@@ -3588,8 +3636,7 @@
"A FigureCanvas object wraps a Cocoa NSView object.\n";
static PyTypeObject FigureCanvasType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_macosx.FigureCanvas", /*tp_name*/
sizeof(FigureCanvas), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -3720,8 +3767,13 @@
static PyObject*
FigureManager_repr(FigureManager* self)
{
+#if PY_MAJOR_VERSION >= 3
+ return PyUnicode_FromFormat("FigureManager object %p wrapping NSWindow %p",
+ (void*) self, (void*)(self->window));
+#else
return PyString_FromFormat("FigureManager object %p wrapping NSWindow %p",
(void*) self, (void*)(self->window));
+#endif
}
static void
@@ -3734,7 +3786,7 @@
[window close];
[pool release];
}
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject*
@@ -3765,8 +3817,7 @@
"A FigureManager object wraps a Cocoa NSWindow object.\n";
static PyTypeObject FigureManagerType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_macosx.FigureManager", /*tp_name*/
sizeof(FigureManager), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -4101,13 +4152,17 @@
NavigationToolbar_dealloc(NavigationToolbar *self)
{
[self->handler release];
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject*
NavigationToolbar_repr(NavigationToolbar* self)
{
+#if PY_MAJOR_VERSION >= 3
+ return PyUnicode_FromFormat("NavigationToolbar object %p", (void*)self);
+#else
return PyString_FromFormat("NavigationToolbar object %p", (void*)self);
+#endif
}
static char NavigationToolbar_doc[] =
@@ -4214,7 +4269,11 @@
{
if(states[i]==1)
{
+#if PY_MAJOR_VERSION >= 3
+ PyList_SET_ITEM(list, j, PyLong_FromLong(i));
+#else
PyList_SET_ITEM(list, j, PyInt_FromLong(i));
+#endif
j++;
}
}
@@ -4237,8 +4296,7 @@
};
static PyTypeObject NavigationToolbarType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_macosx.NavigationToolbar", /*tp_name*/
sizeof(NavigationToolbar), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -4623,13 +4681,17 @@
NavigationToolbar2_dealloc(NavigationToolbar2 *self)
{
[self->handler release];
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject*
NavigationToolbar2_repr(NavigationToolbar2* self)
{
+#if PY_MAJOR_VERSION >= 3
+ return PyUnicode_FromFormat("NavigationToolbar2 object %p", (void*)self);
+#else
return PyString_FromFormat("NavigationToolbar2 object %p", (void*)self);
+#endif
}
static char NavigationToolbar2_doc[] =
@@ -4662,8 +4724,7 @@
};
static PyTypeObject NavigationToolbar2Type = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_macosx.NavigationToolbar2", /*tp_name*/
sizeof(NavigationToolbar2), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -5539,14 +5600,19 @@
CFRelease(self->timer);
self->timer = NULL;
}
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject*
Timer_repr(Timer* self)
{
+#if PY_MAJOR_VERSION >= 3
+ return PyUnicode_FromFormat("Timer object %p wrapping CFRunLoopTimerRef %p",
+ (void*) self, (void*)(self->timer));
+#else
return PyString_FromFormat("Timer object %p wrapping CFRunLoopTimerRef %p",
(void*) self, (void*)(self->timer));
+#endif
}
static char Timer_doc[] =
@@ -5657,8 +5723,7 @@
};
static PyTypeObject TimerType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_macosx.Timer", /*tp_name*/
sizeof(Timer), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -5722,23 +5787,52 @@
{NULL, NULL, 0, NULL}/* sentinel */
};
+#if PY_MAJOR_VERSION >= 3
+
+static struct PyModuleDef moduledef = {
+ PyModuleDef_HEAD_INIT,
+ "_macosx",
+ "Mac OS X native backend",
+ -1,
+ methods,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+};
+
+PyObject* PyInit__macosx(void)
+
+#else
+
void init_macosx(void)
-{ PyObject *m;
+#endif
+{ PyObject *module;
import_array();
- if (PyType_Ready(&GraphicsContextType) < 0) return;
- if (PyType_Ready(&FigureCanvasType) < 0) return;
- if (PyType_Ready(&FigureManagerType) < 0) return;
- if (PyType_Ready(&NavigationToolbarType) < 0) return;
- if (PyType_Ready(&NavigationToolbar2Type) < 0) return;
- if (PyType_Ready(&TimerType) < 0) return;
+ if (PyType_Ready(&GraphicsContextType) < 0
+ || PyType_Ready(&FigureCanvasType) < 0
+ || PyType_Ready(&FigureManagerType) < 0
+ || PyType_Ready(&NavigationToolbarType) < 0
+ || PyType_Ready(&NavigationToolbar2Type) < 0
+ || PyType_Ready(&TimerType) < 0)
+#if PY_MAJOR_VERSION >= 3
+ return NULL;
+#else
+ return;
+#endif
- m = Py_InitModule4("_macosx",
- methods,
- "Mac OS X native backend",
- NULL,
- PYTHON_API_VERSION);
+#if PY_MAJOR_VERSION >= 3
+ module = PyModule_Create(&moduledef);
+ if (module==NULL) return NULL;
+#else
+ module = Py_InitModule4("_macosx",
+ methods,
+ "Mac OS X native backend",
+ NULL,
+ PYTHON_API_VERSION);
+#endif
Py_INCREF(&GraphicsContextType);
Py_INCREF(&FigureCanvasType);
@@ -5746,12 +5840,12 @@
Py_INCREF(&NavigationToolbarType);
Py_INCREF(&NavigationToolbar2Type);
Py_INCREF(&TimerType);
- PyModule_AddObject(m, "GraphicsContext", (PyObject*) &GraphicsContextType);
- PyModule_AddObject(m, "FigureCanvas", (PyObject*) &FigureCanvasType);
- PyModule_AddObject(m, "FigureManager", (PyObject*) &FigureManagerType);
- PyModule_AddObject(m, "NavigationToolbar", (PyObject*) &NavigationToolbarType);
- PyModule_AddObject(m, "NavigationToolbar2", (PyObject*) &NavigationToolbar2Type);
- PyModule_AddObject(m, "Timer", (PyObject*) &TimerType);
+ PyModule_AddObject(module, "GraphicsContext", (PyObject*) &GraphicsContextType);
+ PyModule_AddObject(module, "FigureCanvas", (PyObject*) &FigureCanvasType);
+ PyModule_AddObject(module, "FigureManager", (PyObject*) &FigureManagerType);
+ PyModule_AddObject(module, "NavigationToolbar", (PyObject*) &NavigationToolbarType);
+ PyModule_AddObject(module, "NavigationToolbar2", (PyObject*) &NavigationToolbar2Type);
+ PyModule_AddObject(module, "Timer", (PyObject*) &TimerType);
PyOS_InputHook = wait_for_stdin;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2011-01-08 06:56:48
|
Revision: 8901
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8901&view=rev
Author: mdehoon
Date: 2011-01-08 06:56:42 +0000 (Sat, 08 Jan 2011)
Log Message:
-----------
Fixing a bug. Due to a race condition, the view of a closing window could get one release too many.
Modified Paths:
--------------
trunk/matplotlib/src/_macosx.m
Modified: trunk/matplotlib/src/_macosx.m
===================================================================
--- trunk/matplotlib/src/_macosx.m 2011-01-06 19:55:16 UTC (rev 8900)
+++ trunk/matplotlib/src/_macosx.m 2011-01-08 06:56:42 UTC (rev 8901)
@@ -3755,7 +3755,6 @@
[window setDelegate: view];
[window makeFirstResponder: view];
[[window contentView] addSubview: view];
- [view release];
[window makeKeyAndOrderFront: nil];
nwin++;
@@ -4854,6 +4853,10 @@
gstate = PyGILState_Ensure();
Py_DECREF(manager);
PyGILState_Release(gstate);
+ /* The reference count of the view that was added as a subview to the
+ * content view of this window was increased during the call to addSubview,
+ * and is decreased during the call to [super dealloc].
+ */
[super dealloc];
}
@end
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2011-01-28 12:38:40
|
Revision: 8936
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8936&view=rev
Author: mdehoon
Date: 2011-01-28 12:38:34 +0000 (Fri, 28 Jan 2011)
Log Message:
-----------
Make an autorelease pool, otherwise we're leaking memory.
Modified Paths:
--------------
trunk/matplotlib/src/_macosx.m
Modified: trunk/matplotlib/src/_macosx.m
===================================================================
--- trunk/matplotlib/src/_macosx.m 2011-01-24 09:41:49 UTC (rev 8935)
+++ trunk/matplotlib/src/_macosx.m 2011-01-28 12:38:34 UTC (rev 8936)
@@ -4705,8 +4705,10 @@
NSText* messagebox = self->messagebox;
if (messagebox)
- { NSString* text = [NSString stringWithUTF8String: message];
+ { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
+ NSString* text = [NSString stringWithUTF8String: message];
[messagebox setString: text];
+ [pool release];
}
Py_INCREF(Py_None);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|