diff options
author | Seth ProductEngine <slitovchuk@productengine.com> | 2012-02-01 23:44:25 +0200 |
---|---|---|
committer | Seth ProductEngine <slitovchuk@productengine.com> | 2012-02-01 23:44:25 +0200 |
commit | 7314ac3a37d624e6a750fc12df64d08b584ad593 (patch) | |
tree | 9300080165a73bcb95d17e14573d89115ae1d25a | |
parent | b3960899066156bc7d3fd5befb2f7e687a328152 (diff) |
EXP-1672 FIXED Various fixes to prevent crashes in notifications.
- Refactoring of LLToast and LLScreenChannel classes: moved LLToast signals to the private section.
- Modified the screen channel's lists of toasts to store LLHandles instead of pointers and screen channel code to work with toast LLHandles.
-rw-r--r-- | indra/newview/llinspecttoast.cpp | 2 | ||||
-rw-r--r-- | indra/newview/llscreenchannel.cpp | 289 | ||||
-rw-r--r-- | indra/newview/llscreenchannel.h | 30 | ||||
-rw-r--r-- | indra/newview/lltoast.cpp | 7 | ||||
-rw-r--r-- | indra/newview/lltoast.h | 29 |
5 files changed, 239 insertions, 118 deletions
diff --git a/indra/newview/llinspecttoast.cpp b/indra/newview/llinspecttoast.cpp index d7b82667d1..f4fe5dec01 100644 --- a/indra/newview/llinspecttoast.cpp +++ b/indra/newview/llinspecttoast.cpp @@ -72,6 +72,8 @@ LLInspectToast::LLInspectToast(const LLSD& notification_id) : LLInspectToast::~LLInspectToast() { LLTransientFloaterMgr::getInstance()->removeControlView(this); + + mConnection.disconnect(); } // virtual diff --git a/indra/newview/llscreenchannel.cpp b/indra/newview/llscreenchannel.cpp index 5301955964..1045009a04 100644 --- a/indra/newview/llscreenchannel.cpp +++ b/indra/newview/llscreenchannel.cpp @@ -195,17 +195,18 @@ LLScreenChannel::~LLScreenChannel() } -std::list<LLToast*> LLScreenChannel::findToasts(const Matcher& matcher) +std::list<const LLToast*> LLScreenChannel::findToasts(const Matcher& matcher) { - std::list<LLToast*> res; + std::list<const LLToast*> res; // collect stored toasts for (std::vector<ToastElem>::iterator it = mStoredToastList.begin(); it != mStoredToastList.end(); it++) { - if (matcher.matches(it->toast->getNotification())) + const LLToast* toast = it->getToast(); + if (toast && matcher.matches(toast->getNotification())) { - res.push_back(it->toast); + res.push_back(toast); } } @@ -213,9 +214,10 @@ std::list<LLToast*> LLScreenChannel::findToasts(const Matcher& matcher) for (std::vector<ToastElem>::iterator it = mToastList.begin(); it != mToastList.end(); it++) { - if (matcher.matches(it->toast->getNotification())) + const LLToast* toast = it->getToast(); + if (toast && matcher.matches(toast->getNotification())) { - res.push_back(it->toast); + res.push_back(toast); } } @@ -260,15 +262,16 @@ void LLScreenChannel::addToast(const LLToast::Params& p) return; } - ToastElem new_toast_elem(p); + LLToast* toast = new LLToast(p); + ToastElem new_toast_elem(toast->getHandle()); - new_toast_elem.toast->setOnFadeCallback(boost::bind(&LLScreenChannel::onToastFade, this, _1)); - new_toast_elem.toast->setOnToastDestroyedCallback(boost::bind(&LLScreenChannel::onToastDestroyed, this, _1)); + toast->setOnFadeCallback(boost::bind(&LLScreenChannel::onToastFade, this, _1)); + toast->setOnToastDestroyedCallback(boost::bind(&LLScreenChannel::onToastDestroyed, this, _1)); if(mControlHovering) { - new_toast_elem.toast->setOnToastHoverCallback(boost::bind(&LLScreenChannel::onToastHover, this, _1, _2)); - new_toast_elem.toast->setMouseEnterCallback(boost::bind(&LLScreenChannel::stopToastTimer, this, new_toast_elem.toast)); - new_toast_elem.toast->setMouseLeaveCallback(boost::bind(&LLScreenChannel::startToastTimer, this, new_toast_elem.toast)); + toast->setOnToastHoverCallback(boost::bind(&LLScreenChannel::onToastHover, this, _1, _2)); + toast->setMouseEnterCallback(boost::bind(&LLScreenChannel::stopToastTimer, this, toast)); + toast->setMouseLeaveCallback(boost::bind(&LLScreenChannel::startToastTimer, this, toast)); } if(show_toast) @@ -324,8 +327,8 @@ void LLScreenChannel::onToastFade(LLToast* toast) bool delete_toast = !mCanStoreToasts || !toast->getCanBeStored(); if(delete_toast) { - mToastList.erase(it); deleteToast(toast); + mToastList.erase(it); } else { @@ -340,13 +343,13 @@ void LLScreenChannel::onToastFade(LLToast* toast) //-------------------------------------------------------------------------- void LLScreenChannel::deleteToast(LLToast* toast) { - if (toast->isDead()) + if (!toast || toast->isDead()) { return; } // send signal to observers about destroying of a toast - toast->mOnDeleteToastSignal(toast); + toast->closeToast(); // update channel's Hovering state // turning hovering off manually because onMouseLeave won't happen if a toast was closed using a keyboard @@ -354,9 +357,6 @@ void LLScreenChannel::deleteToast(LLToast* toast) { mHoveredToast = NULL; } - - // close the toast - toast->closeFloater(); } //-------------------------------------------------------------------------- @@ -364,12 +364,16 @@ void LLScreenChannel::deleteToast(LLToast* toast) void LLScreenChannel::storeToast(ToastElem& toast_elem) { // do not store clones - std::vector<ToastElem>::iterator it = find(mStoredToastList.begin(), mStoredToastList.end(), toast_elem.id); + std::vector<ToastElem>::iterator it = find(mStoredToastList.begin(), mStoredToastList.end(), toast_elem.getID()); if( it != mStoredToastList.end() ) return; - mStoredToastList.push_back(toast_elem); - mOnStoreToast(toast_elem.toast->getPanel(), toast_elem.id); + const LLToast* toast = toast_elem.getToast(); + if (toast) + { + mStoredToastList.push_back(toast_elem); + mOnStoreToast(toast->getPanel(), toast->getNotificationID()); + } } //-------------------------------------------------------------------------- @@ -382,9 +386,13 @@ void LLScreenChannel::loadStoredToastsToChannel() for(it = mStoredToastList.begin(); it != mStoredToastList.end(); ++it) { - (*it).toast->setIsHidden(false); - (*it).toast->startTimer(); - mToastList.push_back((*it)); + LLToast* toast = it->getToast(); + if (toast) + { + toast->setIsHidden(false); + toast->startTimer(); + mToastList.push_back(*it); + } } mStoredToastList.clear(); @@ -399,17 +407,19 @@ void LLScreenChannel::loadStoredToastByNotificationIDToChannel(LLUUID id) if( it == mStoredToastList.end() ) return; - LLToast* toast = (*it).toast; - - if(toast->getVisible()) + LLToast* toast = it->getToast(); + if (toast) { - // toast is already in channel - return; - } + if(toast->getVisible()) + { + // toast is already in channel + return; + } - toast->setIsHidden(false); - toast->startTimer(); - mToastList.push_back((*it)); + toast->setIsHidden(false); + toast->startTimer(); + mToastList.push_back(*it); + } redrawToasts(); } @@ -423,9 +433,19 @@ void LLScreenChannel::removeStoredToastByNotificationID(LLUUID id) if( it == mStoredToastList.end() ) return; - LLToast* toast = (*it).toast; - mStoredToastList.erase(it); - mRejectToastSignal(toast->getNotificationID()); + const LLToast* toast = it->getToast(); + if (toast) + { + mRejectToastSignal(toast->getNotificationID()); + } + + // Call find() once more, because the mStoredToastList could have been changed + // in mRejectToastSignal callback and the iterator could have become invalid. + it = find(mStoredToastList.begin(), mStoredToastList.end(), id); + if (it != mStoredToastList.end()) + { + mStoredToastList.erase(it); + } } //-------------------------------------------------------------------------- @@ -436,21 +456,22 @@ void LLScreenChannel::killToastByNotificationID(LLUUID id) if( it != mToastList.end()) { - LLToast* toast = (*it).toast; + LLToast* toast = it->getToast(); // if it is a notification toast and notification is UnResponded - then respond on it // else - simply destroy a toast // // NOTE: if a notification is unresponded this function will be called twice for the same toast. // At first, the notification will be discarded, at second (it will be caused by discarding), // the toast will be destroyed. - if(toast->isNotificationValid()) + if(toast && toast->isNotificationValid()) { mRejectToastSignal(toast->getNotificationID()); } else { - mToastList.erase(it); + deleteToast(toast); + mToastList.erase(it); redrawToasts(); } return; @@ -459,20 +480,31 @@ void LLScreenChannel::killToastByNotificationID(LLUUID id) // searching among stored toasts it = find(mStoredToastList.begin(), mStoredToastList.end(), id); - if( it != mStoredToastList.end() ) + if (it != mStoredToastList.end()) + { + LLToast* toast = it->getToast(); + if (toast) + { + // send signal to a listener to let him perform some action on toast rejecting + mRejectToastSignal(toast->getNotificationID()); + deleteToast(toast); + } + } + + // Call find() once more, because the mStoredToastList could have been changed + // in mRejectToastSignal callback and the iterator could have become invalid. + it = find(mStoredToastList.begin(), mStoredToastList.end(), id); + if (it != mStoredToastList.end()) { - LLToast* toast = (*it).toast; mStoredToastList.erase(it); - // send signal to a listener to let him perform some action on toast rejecting - mRejectToastSignal(toast->getNotificationID()); - deleteToast(toast); } + } void LLScreenChannel::killMatchedToasts(const Matcher& matcher) { - std::list<LLToast*> to_delete = findToasts(matcher); - for (std::list<LLToast*>::iterator it = to_delete.begin(); it + std::list<const LLToast*> to_delete = findToasts(matcher); + for (std::list<const LLToast*>::iterator it = to_delete.begin(); it != to_delete.end(); it++) { killToastByNotificationID((*it)-> getNotificationID()); @@ -486,12 +518,15 @@ void LLScreenChannel::modifyToastByNotificationID(LLUUID id, LLPanel* panel) if( it != mToastList.end() && panel) { - LLToast* toast = (*it).toast; - LLPanel* old_panel = toast->getPanel(); - toast->removeChild(old_panel); - delete old_panel; - toast->insertPanel(panel); - toast->startTimer(); + LLToast* toast = it->getToast(); + if (toast) + { + LLPanel* old_panel = toast->getPanel(); + toast->removeChild(old_panel); + delete old_panel; + toast->insertPanel(panel); + toast->startTimer(); + } redrawToasts(); } } @@ -540,16 +575,29 @@ void LLScreenChannel::showToastsBottom() { if(it != mToastList.rbegin()) { - LLToast* toast = (*(it-1)).toast; + LLToast* toast = (it-1)->getToast(); + if (!toast) + { + llwarns << "Attempt to display a deleted toast." << llendl; + return; + } + bottom = toast->getRect().mTop - toast->getTopPad(); toast_margin = gSavedSettings.getS32("ToastGap"); } - toast_rect = (*it).toast->getRect(); + LLToast* toast = it->getToast(); + if(!toast) + { + llwarns << "Attempt to display a deleted toast." << llendl; + return; + } + + toast_rect = toast->getRect(); toast_rect.setOriginAndSize(getRect().mRight - toast_rect.getWidth(), bottom + toast_margin, toast_rect.getWidth(), toast_rect.getHeight()); - (*it).toast->setRect(toast_rect); + toast->setRect(toast_rect); if(floater && floater->overlapsScreenChannel()) { @@ -561,7 +609,7 @@ void LLScreenChannel::showToastsBottom() { shift += floater->getDockControl()->getTongueHeight(); } - (*it).toast->translate(0, shift); + toast->translate(0, shift); } LLRect channel_rect = getChannelRect(); @@ -572,13 +620,13 @@ void LLScreenChannel::showToastsBottom() } } - bool stop_showing_toasts = (*it).toast->getRect().mTop > getRect().mTop; + bool stop_showing_toasts = toast->getRect().mTop > getRect().mTop; if(!stop_showing_toasts) { if( it != mToastList.rend()-1) { - S32 toast_top = (*it).toast->getRect().mTop + gSavedSettings.getS32("ToastGap"); + S32 toast_top = toast->getRect().mTop + gSavedSettings.getS32("ToastGap"); stop_showing_toasts = toast_top > getRect().mTop; } } @@ -592,17 +640,17 @@ void LLScreenChannel::showToastsBottom() if(stop_showing_toasts) break; - if( !(*it).toast->getVisible() ) + if( !toast->getVisible() ) { // HACK // EXT-2653: it is necessary to prevent overlapping for secondary showed toasts - (*it).toast->setVisible(TRUE); + toast->setVisible(TRUE); } - if(!(*it).toast->hasFocus()) + if(!toast->hasFocus()) { // Fixing Z-order of toasts (EXT-4862) // Next toast will be positioned under this one. - gFloaterView->sendChildToBack((*it).toast); + gFloaterView->sendChildToBack(toast); } } @@ -612,7 +660,11 @@ void LLScreenChannel::showToastsBottom() mHiddenToastsNum = 0; for(; it != mToastList.rend(); it++) { - (*it).toast->hide(); + LLToast* toast = it->getToast(); + if (toast) + { + toast->hide(); + } } } } @@ -620,17 +672,31 @@ void LLScreenChannel::showToastsBottom() //-------------------------------------------------------------------------- void LLScreenChannel::showToastsCentre() { - LLRect toast_rect; - S32 bottom = (getRect().mTop - getRect().mBottom)/2 + mToastList[0].toast->getRect().getHeight()/2; + LLToast* toast = mToastList[0].getToast(); + if (!toast) + { + llwarns << "Attempt to display a deleted toast." << llendl; + return; + } + + LLRect toast_rect; + S32 bottom = (getRect().mTop - getRect().mBottom)/2 + toast->getRect().getHeight()/2; std::vector<ToastElem>::reverse_iterator it; for(it = mToastList.rbegin(); it != mToastList.rend(); ++it) { - toast_rect = (*it).toast->getRect(); + LLToast* toast = it->getToast(); + if (!toast) + { + llwarns << "Attempt to display a deleted toast." << llendl; + return; + } + + toast_rect = toast->getRect(); toast_rect.setLeftTopAndSize(getRect().mLeft - toast_rect.getWidth() / 2, bottom + toast_rect.getHeight() / 2 + gSavedSettings.getS32("ToastGap"), toast_rect.getWidth() ,toast_rect.getHeight()); - (*it).toast->setRect(toast_rect); + toast->setRect(toast_rect); - (*it).toast->setVisible(TRUE); + toast->setVisible(TRUE); } } @@ -652,16 +718,29 @@ void LLScreenChannel::showToastsTop() { if(it != mToastList.rbegin()) { - LLToast* toast = (*(it-1)).toast; + LLToast* toast = (it-1)->getToast(); + if (!toast) + { + llwarns << "Attempt to display a deleted toast." << llendl; + return; + } + top = toast->getRect().mBottom - toast->getTopPad(); toast_margin = gSavedSettings.getS32("ToastGap"); } - toast_rect = (*it).toast->getRect(); + LLToast* toast = it->getToast(); + if (!toast) + { + llwarns << "Attempt to display a deleted toast." << llendl; + return; + } + + toast_rect = toast->getRect(); toast_rect.setLeftTopAndSize(channel_rect.mRight - toast_rect.getWidth(), top, toast_rect.getWidth(), toast_rect.getHeight()); - (*it).toast->setRect(toast_rect); + toast->setRect(toast_rect); if(floater && floater->overlapsScreenChannel()) { @@ -673,7 +752,7 @@ void LLScreenChannel::showToastsTop() { shift -= floater->getDockControl()->getTongueHeight(); } - (*it).toast->translate(0, shift); + toast->translate(0, shift); } LLRect channel_rect = getChannelRect(); @@ -684,13 +763,13 @@ void LLScreenChannel::showToastsTop() } } - bool stop_showing_toasts = (*it).toast->getRect().mBottom < channel_rect.mBottom; + bool stop_showing_toasts = toast->getRect().mBottom < channel_rect.mBottom; if(!stop_showing_toasts) { if( it != mToastList.rend()-1) { - S32 toast_bottom = (*it).toast->getRect().mBottom - gSavedSettings.getS32("ToastGap"); + S32 toast_bottom = toast->getRect().mBottom - gSavedSettings.getS32("ToastGap"); stop_showing_toasts = toast_bottom < channel_rect.mBottom; } } @@ -704,17 +783,17 @@ void LLScreenChannel::showToastsTop() if(stop_showing_toasts) break; - if( !(*it).toast->getVisible() ) + if (!toast->getVisible()) { // HACK // EXT-2653: it is necessary to prevent overlapping for secondary showed toasts - (*it).toast->setVisible(TRUE); + toast->setVisible(TRUE); } - if(!(*it).toast->hasFocus()) + if (!toast->hasFocus()) { // Fixing Z-order of toasts (EXT-4862) // Next toast will be positioned under this one. - gFloaterView->sendChildToBack((*it).toast); + gFloaterView->sendChildToBack(toast); } } @@ -724,7 +803,11 @@ void LLScreenChannel::showToastsTop() mHiddenToastsNum = 0; for(; it != mToastList.rend(); it++) { - (*it).toast->hide(); + LLToast* toast = it->getToast(); + if (toast) + { + toast->hide(); + } } } } @@ -827,7 +910,17 @@ void LLNotificationsUI::LLScreenChannel::startToastTimer(LLToast* toast) void LLScreenChannel::hideToastsFromScreen() { for(std::vector<ToastElem>::iterator it = mToastList.begin(); it != mToastList.end(); it++) - (*it).toast->setVisible(FALSE); + { + LLToast* toast = it->getToast(); + if (toast) + { + toast->setVisible(FALSE); + } + else + { + llwarns << "Attempt to hide a deleted toast." << llendl; + } + } } //-------------------------------------------------------------------------- @@ -836,8 +929,15 @@ void LLScreenChannel::hideToast(const LLUUID& notification_id) std::vector<ToastElem>::iterator it = find(mToastList.begin(), mToastList.end(), notification_id); if(mToastList.end() != it) { - ToastElem te = *it; - te.toast->hide(); + LLToast* toast = it->getToast(); + if (toast) + { + toast->hide(); + } + else + { + llwarns << "Attempt to hide a deleted toast." << llendl; + } } } @@ -845,24 +945,25 @@ void LLScreenChannel::closeHiddenToasts(const Matcher& matcher) { // since we can't guarantee that close toast operation doesn't change mToastList // we collect matched toasts that should be closed into separate list - std::list<ToastElem> toasts; + std::list<LLToast*> toasts; for (std::vector<ToastElem>::iterator it = mToastList.begin(); it != mToastList.end(); it++) { - LLToast * toast = it->toast; + LLToast* toast = it->getToast(); // add to list valid toast that match to provided matcher criteria if (toast != NULL && !toast->isDead() && toast->getNotification() != NULL && !toast->getVisible() && matcher.matches(toast->getNotification())) { - toasts.push_back(*it); + toasts.push_back(toast); } } // close collected toasts - for (std::list<ToastElem>::iterator it = toasts.begin(); it + for (std::list<LLToast*>::iterator it = toasts.begin(); it != toasts.end(); it++) { - it->toast->closeFloater(); + LLToast* toast = *it; + toast->closeFloater(); } } @@ -872,7 +973,7 @@ void LLScreenChannel::removeToastsFromChannel() hideToastsFromScreen(); for(std::vector<ToastElem>::iterator it = mToastList.begin(); it != mToastList.end(); it++) { - deleteToast((*it).toast); + deleteToast(it->getToast()); } mToastList.clear(); } @@ -886,9 +987,10 @@ void LLScreenChannel::removeAndStoreAllStorableToasts() hideToastsFromScreen(); for(std::vector<ToastElem>::iterator it = mToastList.begin(); it != mToastList.end();) { - if((*it).toast->getCanBeStored()) + LLToast* toast = it->getToast(); + if(toast && toast->getCanBeStored()) { - storeToast(*(it)); + storeToast(*it); it = mToastList.erase(it); } else @@ -908,9 +1010,10 @@ void LLScreenChannel::removeToastsBySessionID(LLUUID id) hideToastsFromScreen(); for(std::vector<ToastElem>::iterator it = mToastList.begin(); it != mToastList.end();) { - if((*it).toast->getSessionID() == id) + LLToast* toast = it->getToast(); + if(toast && toast->getSessionID() == id) { - deleteToast((*it).toast); + deleteToast(toast); it = mToastList.erase(it); } else @@ -968,5 +1071,5 @@ LLToast* LLScreenChannel::getToastByNotificationID(LLUUID id) if (it == mStoredToastList.end()) return NULL; - return it->toast; + return it->getToast(); } diff --git a/indra/newview/llscreenchannel.h b/indra/newview/llscreenchannel.h index c9f8855fe6..695b6cd44d 100644 --- a/indra/newview/llscreenchannel.h +++ b/indra/newview/llscreenchannel.h @@ -163,7 +163,7 @@ public: virtual bool matches(const LLNotificationPtr) const = 0; }; - std::list<LLToast*> findToasts(const Matcher& matcher); + std::list<const LLToast*> findToasts(const Matcher& matcher); // Channel's outfit-functions // update channel's size and position in the World View @@ -238,31 +238,39 @@ public: reject_tost_signal_t mRejectToastSignal; boost::signals2::connection setOnRejectToastCallback(reject_tost_callback_t cb) { return mRejectToastSignal.connect(cb); } private: - struct ToastElem + class ToastElem { - LLUUID id; - LLToast* toast; + public: + ToastElem(const LLHandle<LLToast>& toast) : mToast(toast) + { + } - ToastElem(LLToast::Params p) : id(p.notif_id) + ToastElem(const ToastElem& toast_elem) : mToast(toast_elem.mToast) { - toast = new LLToast(p); } - ToastElem(const ToastElem& toast_elem) + LLToast* getToast() const { - id = toast_elem.id; - toast = toast_elem.toast; + return mToast.get(); + } + + LLUUID getID() const + { + return mToast.isDead() ? LLUUID() : mToast.get()->getNotificationID(); } bool operator == (const LLUUID &id_op) const { - return (id == id_op); + return (getID() == id_op); } bool operator == (LLPanel* panel_op) const { - return (toast == panel_op); + return (mToast.get() == panel_op); } + + private: + LLHandle<LLToast> mToast; }; // Channel's handlers diff --git a/indra/newview/lltoast.cpp b/indra/newview/lltoast.cpp index 21120a1b8d..cdc611f7af 100644 --- a/indra/newview/lltoast.cpp +++ b/indra/newview/lltoast.cpp @@ -215,6 +215,13 @@ void LLToast::setFadingTime(S32 seconds) mToastFadingTime = seconds; } +void LLToast::closeToast() +{ + mOnDeleteToastSignal(this); + + closeFloater(); +} + S32 LLToast::getTopPad() { if(mWrapperPanel) diff --git a/indra/newview/lltoast.h b/indra/newview/lltoast.h index 0b06728935..e1d99b1bcb 100644 --- a/indra/newview/lltoast.h +++ b/indra/newview/lltoast.h @@ -75,6 +75,7 @@ class LLToast : public LLModalDialog, public LLInstanceTracker<LLToast> public: typedef boost::function<void (LLToast* toast)> toast_callback_t; typedef boost::signals2::signal<void (LLToast* toast)> toast_signal_t; + typedef boost::signals2::signal<void (LLToast* toast, bool mouse_enter)> toast_hover_check_signal_t; struct Params : public LLInitParam::Block<Params> { @@ -131,7 +132,7 @@ public: void reshapeToPanel(); // get toast's panel - LLPanel* getPanel() { return mPanel; } + LLPanel* getPanel() const { return mPanel; } // enable/disable Toast's Hide button void setHideButtonEnabled(bool enabled); // @@ -155,6 +156,8 @@ public: void setFadingTime(S32 seconds); + void closeToast(); + /** * Returns padding between floater top and wrapper_panel top. * This padding should be taken into account when positioning or reshaping toasts @@ -167,9 +170,9 @@ public: // get information whether the notification corresponding to the toast is valid or not bool isNotificationValid(); // get toast's Notification ID - const LLUUID getNotificationID() { return mNotificationID;} + const LLUUID getNotificationID() const { return mNotificationID;} // get toast's Session ID - const LLUUID getSessionID() { return mSessionID;} + const LLUUID getSessionID() const { return mSessionID;} // void setCanFade(bool can_fade); // @@ -179,19 +182,12 @@ public: // set whether this toast considered as hidden or not void setIsHidden( bool is_toast_hidden ) { mIsHidden = is_toast_hidden; } - const LLNotificationPtr& getNotification() { return mNotification;} + const LLNotificationPtr& getNotification() const { return mNotification;} // Registers signals/callbacks for events - toast_signal_t mOnFadeSignal; - toast_signal_t mOnDeleteToastSignal; - toast_signal_t mOnToastDestroyedSignal; - boost::signals2::connection setOnFadeCallback(toast_callback_t cb) { return mOnFadeSignal.connect(cb); } - boost::signals2::connection setOnToastDestroyedCallback(toast_callback_t cb) { return mOnToastDestroyedSignal.connect(cb); } - - typedef boost::function<void (LLToast* toast, bool mouse_enter)> toast_hover_check_callback_t; - typedef boost::signals2::signal<void (LLToast* toast, bool mouse_enter)> toast_hover_check_signal_t; - toast_hover_check_signal_t mOnToastHoverSignal; - boost::signals2::connection setOnToastHoverCallback(toast_hover_check_callback_t cb) { return mOnToastHoverSignal.connect(cb); } + boost::signals2::connection setOnFadeCallback(const toast_signal_t::slot_type& cb) { return mOnFadeSignal.connect(cb); } + boost::signals2::connection setOnToastDestroyedCallback(const toast_signal_t::slot_type& cb) { return mOnToastDestroyedSignal.connect(cb); } + boost::signals2::connection setOnToastHoverCallback(const toast_hover_check_signal_t::slot_type& cb) { return mOnToastHoverSignal.connect(cb); } boost::signals2::connection setMouseEnterCallback( const commit_signal_t::slot_type& cb ) { return mToastMouseEnterSignal.connect(cb); }; boost::signals2::connection setMouseLeaveCallback( const commit_signal_t::slot_type& cb ) { return mToastMouseLeaveSignal.connect(cb); }; @@ -237,6 +233,11 @@ private: bool mIsFading; bool mIsHovered; + toast_signal_t mOnFadeSignal; + toast_signal_t mOnDeleteToastSignal; + toast_signal_t mOnToastDestroyedSignal; + toast_hover_check_signal_t mOnToastHoverSignal; + commit_signal_t mToastMouseEnterSignal; commit_signal_t mToastMouseLeaveSignal; }; |