fancymax / AutoCompleteTextField

AutoCompleteTextField for OS X
MIT License
70 stars 7 forks source link

NSTextView port throws error: invalid numeric value to CoreGraphics #1

Closed futurist closed 7 years ago

futurist commented 7 years ago

When port this lib into NSTextView, using Swift 3.0, as below:

https://github.com/futurist/cutecmd-mac/blob/4486b868cf057713704566deb304a79609632d30/cutecmd-mac/AutoCompleteTextField.swift

I have a bug reported as below:

Nov 23 08:22:25 cutecmd-mac[6516] : Error: this application, or a library it uses, has passed an invalid numeric value (NaN, or not-a-number) to CoreGraphics API and this value is being ignored.Please fix this problem.

This happens when the self.getCompletionArray returned a complete different array as before.

I've googled and told that it's due to NSPopover, but I'm not sure.

To reproduce it, download and run the repo, input

s (will popup Safari etc.) Backspace (clear the input) q (this will throw above error)

Xcode 8, macOS 10.11.6

What's going on? help needed for the port into NSTextView

fancymax commented 7 years ago

@futurist in macOS 10.12 Xcode8.0, I can't reproduce the problem

futurist commented 7 years ago

Don't know why, but will appear every time here

untitled

Using building completion popup (F5), there's no any error, but it's weak...

futurist commented 7 years ago

The Swift 3.0 update also have this problem in my mac:

2016-11-26 8 55 34

futurist commented 7 years ago

I've moved the popover.contentSize calculation into a delegate method (popoverWillShow), and the problem gone here.

https://github.com/futurist/cutecmd-mac/commit/c8f5565fd3f7c65ce15c63e6c7ae559795e35dee#diff-cedb50a79b0833adf206a909638564aaR208

fancymax commented 7 years ago

@futurist thanks for your effort. Would you mind pulling the requests?

futurist commented 7 years ago

If you using javascript, maybe you can check my lib:

https://github.com/cssobj/cssobj

Welcome to give a star! 😄