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

Skip to content

Fix up some OSX backend issues #12053

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 10, 2018
Merged

Conversation

dopplershift
Copy link
Contributor

This fixes up a few issues in the OSX backend:

@dopplershift
Copy link
Contributor Author

attn: @astrofrog

@dopplershift
Copy link
Contributor Author

Anyone wanting to check me on the API calls can check out the docs here.

@dopplershift dopplershift added this to the v3.0 milestone Sep 7, 2018
@dopplershift dopplershift added Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. GUI: MacOSX labels Sep 7, 2018
src/_macosx.m Outdated
gstate = PyGILState_Ensure();
result = PyObject_CallMethod(canvas, "enter_notify_event", "");
PyObject* loc = Py_BuildValue("ii", x, y);
Py_INCREF(Py_None);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can just borrow the ref to None (i.e. don't bother with Py_INCREF/Py_DECREF)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that because we're staying inside our function? I know we have to inc ref when returning (or use Py_RETURN_NONE).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup

src/_macosx.m Outdated
PyObject* loc = Py_BuildValue("ii", x, y);
Py_INCREF(Py_None);
result = PyObject_CallMethod(canvas, "enter_notify_event", "OO",
Py_None, loc);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think something like

result = PyObject_CallMethod(canvas, "enter_notify_event", "O(ii)", Py_None, x, y);

should work(?) and save you from bothering with loc and its refcounting.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, that's a new one.

Fixes deprecation warning by adding needed event information.
…#11985)

One of the arugments when creating a timer on OSX is the time of first
fire. We were passing 0, which puts the time in the past, which means it
fires as soon as possible. Change to calculate what that time should be.
@dopplershift
Copy link
Contributor Author

Well that simplifies the one commit significantly.

Copy link
Member

@ivanov ivanov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done! I just tested this on OS 10.9.5 and works great - no deprecation warning from #10948, and the timer event fires after 5 seconds like its supposed to from @astrofrog's example in #11985

@astrofrog
Copy link
Contributor

@dopplershift - thanks for the timer fix!

@jklymak
Copy link
Member

jklymak commented Sep 10, 2018

Thanks @dopplershift!

@jklymak jklymak merged commit 5e20d9b into matplotlib:master Sep 10, 2018
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull request Sep 10, 2018
@dopplershift dopplershift deleted the fixup-osx branch September 10, 2018 17:00
QuLogic added a commit that referenced this pull request Sep 10, 2018
…053-on-v3.0.x

Backport PR #12053 on branch v3.0.x (Fix up some OSX backend issues)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GUI: MacOSX Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Single shot timer not working correctly with MacOSX backend OSX backend raises deprecation warning for enter_notify_event
5 participants