{"action":"created","issue":{"url":"https://api.github.com/repos/equalsraf/neovim-qt/issues/66","labels_url":"https://api.github.com/repos/equalsraf/neovim-qt/issues/66/labels{/name}","comments_url":"https://api.github.com/repos/equalsraf/neovim-qt/issues/66/comments","events_url":"https://api.github.com/repos/equalsraf/neovim-qt/issues/66/events","html_url":"https://github.com/equalsraf/neovim-qt/pull/66","id":120086830,"number":66,"title":"Fix two regressions","user":{"login":"Marenz","id":424752,"avatar_url":"https://avatars.githubusercontent.com/u/424752?v=3","gravatar_id":"","url":"https://api.github.com/users/Marenz","html_url":"https://github.com/Marenz","followers_url":"https://api.github.com/users/Marenz/followers","following_url":"https://api.github.com/users/Marenz/following{/other_user}","gists_url":"https://api.github.com/users/Marenz/gists{/gist_id}","starred_url":"https://api.github.com/users/Marenz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Marenz/subscriptions","organizations_url":"https://api.github.com/users/Marenz/orgs","repos_url":"https://api.github.com/users/Marenz/repos","events_url":"https://api.github.com/users/Marenz/events{/privacy}","received_events_url":"https://api.github.com/users/Marenz/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-12-03T03:24:12Z","updated_at":"2015-12-03T10:25:15Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/equalsraf/neovim-qt/pulls/66","html_url":"https://github.com/equalsraf/neovim-qt/pull/66","diff_url":"https://github.com/equalsraf/neovim-qt/pull/66.diff","patch_url":"https://github.com/equalsraf/neovim-qt/pull/66.patch"},"body":"I bisected this bug down to commit https://github.com/equalsraf/neovim-qt/commit/38644b9\r\n\r\nHere is a .gif demonstrating the problem. It is a bit multisided. The gif demonstrate the following things in order: \r\n\r\n* Without mouse/keyboard input you just see white. It only renders something once it gets input.\r\n* Moving the window back and forth is fine until it gets to the big screen, then it freezes\r\n* But giving it a lot of input also causes it to freeze (last part)\r\n\r\n![resize-freeze](https://cloud.githubusercontent.com/assets/424752/11551006/5787c8ee-9975-11e5-8137-e58a932d1bd2.gif)"},"comment":{"url":"https://api.github.com/repos/equalsraf/neovim-qt/issues/comments/161584618","html_url":"https://github.com/equalsraf/neovim-qt/pull/66#issuecomment-161584618","issue_url":"https://api.github.com/repos/equalsraf/neovim-qt/issues/66","id":161584618,"user":{"login":"equalsraf","id":715238,"avatar_url":"https://avatars.githubusercontent.com/u/715238?v=3","gravatar_id":"","url":"https://api.github.com/users/equalsraf","html_url":"https://github.com/equalsraf","followers_url":"https://api.github.com/users/equalsraf/followers","following_url":"https://api.github.com/users/equalsraf/following{/other_user}","gists_url":"https://api.github.com/users/equalsraf/gists{/gist_id}","starred_url":"https://api.github.com/users/equalsraf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/equalsraf/subscriptions","organizations_url":"https://api.github.com/users/equalsraf/orgs","repos_url":"https://api.github.com/users/equalsraf/repos","events_url":"https://api.github.com/users/equalsraf/events{/privacy}","received_events_url":"https://api.github.com/users/equalsraf/received_events","type":"User","site_admin":false},"created_at":"2015-12-03T10:25:15Z","updated_at":"2015-12-03T10:25:15Z","body":"IIIRC, I really made a mess of things there, thanks for tracking this down.\r\n\r\nBy removing the `msgpack_unpacker_reserve_buffer` the buffer can never grow, once it fills up we just keep reading 0 bytes. Looking at the old version of `::dataAvailable()` I suspect it was also wrong in that it should check the buffer before attempting to read.\r\n\r\nDoes this work?\r\n\r\n```diff\r\nindex 109a62d..246d71b 100644\r\n--- a/src/msgpackiodevice.cpp\r\n+++ b/src/msgpackiodevice.cpp\r\n@@ -176,16 +176,28 @@ void MsgpackIODevice::dataAvailableFd(int fd)\r\n  */\r\n void MsgpackIODevice::dataAvailable()\r\n {\r\n-       qint64 bytes = m_dev->read(msgpack_unpacker_buffer(&m_uk), msgpack_unpacker_buffer_capacity(&m_uk));\r\n-       if ( bytes > 0 ) {\r\n-               msgpack_unpacker_buffer_consumed(&m_uk, bytes);\r\n-               msgpack_unpacked result;\r\n-               msgpack_unpacked_init(&result);\r\n-               while(msgpack_unpacker_next(&m_uk, &result)) {\r\n-                       dispatch(result.data);\r\n+       qint64 bytes = 1;\r\n+       while(bytes > 0) {\r\n+               if (msgpack_unpacker_buffer_capacity(&m_uk) == 0) {\r\n+                       if (!msgpack_unpacker_reserve_buffer(&m_uk, 8192)) {\r\n+                               // FIXME: Error out\r\n+                               qWarning() << \"Could not allocate memory in unpack buffer\";\r\n+                               return;\r\n+                       }\r\n+               }\r\n+\r\n+               bytes = m_dev->read(msgpack_unpacker_buffer(&m_uk), msgpack_unpacker_buffer_capacity(&m_uk));\r\n+\r\n+               if ( bytes > 0 ) {\r\n+                       msgpack_unpacker_buffer_consumed(&m_uk, bytes);\r\n+                       msgpack_unpacked result;\r\n+                       msgpack_unpacked_init(&result);\r\n+                       while(msgpack_unpacker_next(&m_uk, &result)) {\r\n+                               dispatch(result.data);\r\n+                       }\r\n+               } else if (bytes == -1) {\r\n+                       setError(InvalidDevice, tr(\"Error when reading from device\"));\r\n                }\r\n-       } else if (bytes == -1) {\r\n-               setError(InvalidDevice, tr(\"Error when reading from device\"));\r\n        }\r\n }\r\n\r\n```\r\n\r\nBTW the best way to trigger the event here seems to be resizing the window multiple times, likely because this causes lots of msgpack notifications."}}