{"action":"created","issue":{"url":"https://api.github.com/repos/MRtrix3/mrtrix3/issues/306","labels_url":"https://api.github.com/repos/MRtrix3/mrtrix3/issues/306/labels{/name}","comments_url":"https://api.github.com/repos/MRtrix3/mrtrix3/issues/306/comments","events_url":"https://api.github.com/repos/MRtrix3/mrtrix3/issues/306/events","html_url":"https://github.com/MRtrix3/mrtrix3/issues/306","id":97876038,"number":306,"title":"QSpinBox double slot invocation","user":{"login":"Lestropie","id":5637955,"avatar_url":"https://avatars.githubusercontent.com/u/5637955?v=3","gravatar_id":"","url":"https://api.github.com/users/Lestropie","html_url":"https://github.com/Lestropie","followers_url":"https://api.github.com/users/Lestropie/followers","following_url":"https://api.github.com/users/Lestropie/following{/other_user}","gists_url":"https://api.github.com/users/Lestropie/gists{/gist_id}","starred_url":"https://api.github.com/users/Lestropie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Lestropie/subscriptions","organizations_url":"https://api.github.com/users/Lestropie/orgs","repos_url":"https://api.github.com/users/Lestropie/repos","events_url":"https://api.github.com/users/Lestropie/events{/privacy}","received_events_url":"https://api.github.com/users/Lestropie/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/MRtrix3/mrtrix3/labels/bug","name":"bug","color":"fc2929"},{"url":"https://api.github.com/repos/MRtrix3/mrtrix3/labels/gui","name":"gui","color":"eb6420"},{"url":"https://api.github.com/repos/MRtrix3/mrtrix3/labels/question","name":"question","color":"cc317c"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-07-29T07:09:09Z","updated_at":"2015-08-06T21:28:44Z","closed_at":null,"body":"I've noticed this from time to time, particularly on the LOD selector in the ODF tool but am now seeing it in another context with a QSpinBox.\r\n\r\nIf you click one of the up/down arrows on the spin box, sometimes the slot function is called twice, so you get a double increment / decrement. It's caused by a timer throwing an event that is processed as a mouse button hold, _before_ the mouse button release event is received, in cases where the value change causes heavy processing.\r\n\r\nThis is relevant reading:\r\nhttps://bugreports.qt.io/browse/QTBUG-33128\r\n\r\nIt's possible to get around, but not without disabling having the increment/decrement controls repeatedly engage on mouse button hold. Are there cases where this capability should / should not be permitted, or should this become the default behaviour for all spin boxes in MRview?"},"comment":{"url":"https://api.github.com/repos/MRtrix3/mrtrix3/issues/comments/128515507","html_url":"https://github.com/MRtrix3/mrtrix3/issues/306#issuecomment-128515507","issue_url":"https://api.github.com/repos/MRtrix3/mrtrix3/issues/306","id":128515507,"user":{"login":"jdtournier","id":3221000,"avatar_url":"https://avatars.githubusercontent.com/u/3221000?v=3","gravatar_id":"","url":"https://api.github.com/users/jdtournier","html_url":"https://github.com/jdtournier","followers_url":"https://api.github.com/users/jdtournier/followers","following_url":"https://api.github.com/users/jdtournier/following{/other_user}","gists_url":"https://api.github.com/users/jdtournier/gists{/gist_id}","starred_url":"https://api.github.com/users/jdtournier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jdtournier/subscriptions","organizations_url":"https://api.github.com/users/jdtournier/orgs","repos_url":"https://api.github.com/users/jdtournier/repos","events_url":"https://api.github.com/users/jdtournier/events{/privacy}","received_events_url":"https://api.github.com/users/jdtournier/received_events","type":"User","site_admin":false},"created_at":"2015-08-06T21:28:44Z","updated_at":"2015-08-06T21:28:44Z","body":"Yes, I saw that 'fix' for this issue. Maybe we could try a different approach: inherit from QSpinBox, and reimplement its `timerEvent()` method to check the status of the mouse buttons using [QApplication::mouseButtons()](http://doc.qt.io/qt-4.8/qapplication.html#mouseButtons), and invoke the original implementation of the `timerEvent()` if the mouse buttons genuinely are still depressed. Although I'm guessing this won't work as-is without some trickery, if the mouse button status only gets updated in some other callback that might be invoked _after_ the timer event, but then a judicious `qApp->processEvents()` would probably sort that out..."}}