日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

juce中的BailOutChecker

發布時間:2023/12/10 编程问答 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 juce中的BailOutChecker 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

界面庫中值得注意的一點就是對象響應事件的時候自身被刪除了,那么后續的訪問自然就會出問題,所以需要在響應事件之后先添加引用,相關處理之后再查看自身是否已經被刪除,如果已經被刪除那么就直接退出。juce中通過BailOutChecker來進行這處檢查,內部實現很簡單也就是通過弱引用來進行,關于弱引用請看上一篇文章

//==============================================================================/** A class to keep an eye on a component and check for it being deleted.This is designed for use with the ListenerList::callChecked() methods, to allowthe list iterator to stop cleanly if the component is deleted by a listener callbackwhile the list is still being iterated.*/class JUCE_API BailOutChecker{public:/** Creates a checker that watches one component. */BailOutChecker (Component* component);/** Returns true if either of the two components have been deleted since this object was created. */bool shouldBailOut() const noexcept;private:const WeakReference<Component> safePointer;JUCE_DECLARE_NON_COPYABLE (BailOutChecker)};

紅色部份標識了進行檢查的部份:

void Component::internalMouseWheel (MouseInputSource source, Point<float> relativePos,Time time, const MouseWheelDetails& wheel) {Desktop& desktop = Desktop::getInstance(); BailOutChecker checker (this);const MouseEvent me (source, relativePos, source.getCurrentModifiers(), MouseInputSource::invalidPressure,this, this, time, relativePos, time, 0, false);if (isCurrentlyBlockedByAnotherModalComponent()){// allow blocked mouse-events to go to global listeners..desktop.mouseListeners.callChecked (checker, &MouseListener::mouseWheelMove, me, wheel);}else{mouseWheelMove (me, wheel); if (checker.shouldBailOut())return;
     //歷遍的過程中同樣需要檢查desktop.mouseListeners.callChecked (checker, &MouseListener::mouseWheelMove, me, wheel);if (! checker.shouldBailOut())MouseListenerList::sendWheelEvent (*this, checker, me, wheel);} }

  

轉載于:https://www.cnblogs.com/csxy/p/5472362.html

創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎

總結

以上是生活随笔為你收集整理的juce中的BailOutChecker的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。