Skip to content
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

Popover is broken #104

Open
justvanrossum opened this issue Sep 21, 2019 · 9 comments
Open

Popover is broken #104

justvanrossum opened this issue Sep 21, 2019 · 9 comments

Comments

@justvanrossum
Copy link
Collaborator

from vanilla import Popover
p = Popover((10, 10, 200, 300))
/Users/just/code/git/vanilla/Lib/vanilla/vanillaPopover.py:123: UninitializedDeallocWarning: leaking an uninitialized object of type VVanillaPopoverContentView
  self._nsObject = getNSSubclass(self.contentViewClass).alloc().initWithFrame_(((0, 0), size))
Traceback (most recent call last):
  File "<untitled>", line 2, in <module>
  File "/Users/just/code/git/vanilla/Lib/vanilla/vanillaPopover.py", line 123, in __init__
    self._nsObject = getNSSubclass(self.contentViewClass).alloc().initWithFrame_(((0, 0), size))
objc.internal_error: Cannot calculate FFI type for {CGRect={CGPoint=dd}{CGSize=dd}}16
Exception ignored in: <bound method Popover.__del__ of <vanilla.vanillaPopover.Popover object at 0x10a433e80>>
Traceback (most recent call last):
  File "/Users/just/code/git/vanilla/Lib/vanilla/vanillaPopover.py", line 139, in __del__
    self._breakCycles()
  File "/Users/just/code/git/vanilla/Lib/vanilla/vanillaPopover.py", line 143, in _breakCycles
    view = self._getContentView()
  File "/Users/just/code/git/vanilla/Lib/vanilla/vanillaBase.py", line 131, in _getContentView
    return self._nsObject
AttributeError: 'Popover' object has no attribute '_nsObject'
@justvanrossum
Copy link
Collaborator Author

I'm getting a different error in my actual app, trying to reproduce.

@justvanrossum
Copy link
Collaborator Author

Sorry, the above code is bogus. Will further search later.

@justvanrossum
Copy link
Collaborator Author

This is the actual traceback:

Traceback (most recent call last):
  File "myCode.py", line 175, in buttonClick
    self.featurePopover = p = Popover((170, height + 20))
  File "/Users/just/code/git/vanilla/Lib/vanilla/vanillaGroup.py", line 86, in __setattr__
    super(Group, self).__setattr__(attr, value)
  File "/Users/just/code/git/vanilla/Lib/vanilla/vanillaBase.py", line 48, in __setattr__
    _setAttr(VanillaBaseObject, self, attr, value)
  File "/Users/just/code/git/vanilla/Lib/vanilla/vanillaBase.py", line 357, in _setAttr
    if hasattr(value, "getPosSize") and value.getPosSize() == "auto":
  File "/Users/just/code/git/vanilla/Lib/vanilla/vanillaBase.py", line 157, in getPosSize
    return self._posSize
AttributeError: 'Popover' object has no attribute '_posSize'

But I am not yet successful in creating a small reproducer. Although: now I see, the self in my code is a Group instance, so perhaps that should be a clue.

@justvanrossum
Copy link
Collaborator Author

The intent of self.featurePopover was to have a reference to the Popover, and that used to be no problem. If I make sure I don't assign a Popover instance to an attribute of my Group subclass, it works.

Maybe that code was never kosher, but it did work. Let me try to find what changed.

@justvanrossum
Copy link
Collaborator Author

justvanrossum commented Sep 21, 2019

Ok, the change was introduced in the autolayout PR:

if hasattr(value, "getPosSize") and value.getPosSize() == "auto":

Popover does implement getPosSize() because it inherits it from VanillaBaseObject, but it doesn't work:

from vanilla import Popover
p = Popover((100, 200))
p.getPosSize()
Traceback (most recent call last):
  File "<untitled>", line 3, in <module>
  File "/Users/just/code/git/vanilla/Lib/vanilla/vanillaBase.py", line 157, in getPosSize
    return self._posSize
AttributeError: 'Popover' object has no attribute '_posSize'

That should not be a problem, as I don't think Popover needs getPosSize() really. My code assigns a Popover instance to an attribute of a Group subclass, which is perhaps a little sneaky, as all I need is a reference to the popup, but now this is interfering with the magic vanilla setattr behavior.

I can't really blame vanilla, so I'll just work around it in my code.

@typemytype
Copy link
Member

I think you touch a number of edge cases with a Popover

  • it should clean up nicely in _breakCycles
  • a getPosSize and setPosSize would be a good thing, similar to a Window or Sheet object. A Popover is basically the same as a Window.

@typemytype typemytype reopened this Sep 22, 2019
@justvanrossum
Copy link
Collaborator Author

it should clean up nicely in _breakCycles

It could be that that error was triggered by me (in my first bogus example) not calling Popover with the correct argument: like Window, it wants a (w, h) tuple, not a (x, y, w, h) tuple. Fix that and the _breakCycles error disappears.

@typemytype
Copy link
Member

you need to keep a reference somewhere of the NSPopover object, if not this pops up: UninitializedDeallocWarning: leaking an uninitialized object of type VVanillaPopoverContentView and will mess up everything afterwards

@typemytype
Copy link
Member

maybe a Popover shouldn't by a subclass of a VanillaBaseObject but similar to a Window be a subclass of a NSObject with vanilla like attributes like getPosSize and others

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants