From 2075d92369ed5eac73ff7dad6a22d10d2ae0ed1e Mon Sep 17 00:00:00 2001 From: Lirusaito Date: Tue, 7 May 2019 00:33:39 -0400 Subject: [PATCH] Fix crash when SinguReplaceLinks is false reported by Beware --- indra/llui/lltexteditor.cpp | 2 +- indra/llui/llurlentry.cpp | 31 ++++++++++++++++++++----------- indra/llui/llurlentry.h | 2 +- 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/indra/llui/lltexteditor.cpp b/indra/llui/lltexteditor.cpp index f366cb2df..843fff605 100644 --- a/indra/llui/lltexteditor.cpp +++ b/indra/llui/lltexteditor.cpp @@ -4317,7 +4317,7 @@ void LLTextEditor::appendTextImpl(const std::string &new_text, const LLStyleSP s if (always_underline) link_style->mUnderline = true; appendAndHighlightText(link, part, link_style, !always_underline/*match.underlineOnHoverOnly()*/); }; - const auto&& cb = force_replace_links ? boost::bind(&LLTextEditor::replaceUrl, this, _1, _2, _3) : LLUrlLabelCallback::slot_function_type(); + const auto&& cb = force_replace_links ? boost::bind(&LLTextEditor::replaceUrl, this, _1, _2, _3) : LLUrlLabelCallback(); while (!text.empty() && LLUrlRegistry::instance().findUrl(text, match, cb)) { start = match.getStart(); diff --git a/indra/llui/llurlentry.cpp b/indra/llui/llurlentry.cpp index d3e9ffee4..81be0e2de 100644 --- a/indra/llui/llurlentry.cpp +++ b/indra/llui/llurlentry.cpp @@ -673,9 +673,12 @@ std::string LLUrlEntryAgent::getLabel(const std::string &url, const LLUrlLabelCa } else { - auto connection = LLAvatarNameCache::get(agent_id, boost::bind(&LLUrlEntryAgent::onAvatarNameCache, this, _1, _2)); - mAvatarNameCacheConnections.emplace(agent_id, connection); - addObserver(agent_id_string, url, cb); + if (cb) + { + auto connection = LLAvatarNameCache::get(agent_id, boost::bind(&LLUrlEntryAgent::onAvatarNameCache, this, _1, _2)); + mAvatarNameCacheConnections.emplace(agent_id, connection); + addObserver(agent_id_string, url, cb); + } return LLTrans::getString("LoadingData"); } } @@ -785,9 +788,12 @@ std::string LLUrlEntryAgentName::getLabel(const std::string &url, const LLUrlLab } else { - auto connection = LLAvatarNameCache::get(agent_id, boost::bind(&LLUrlEntryAgentName::onAvatarNameCache, this, _1, _2)); - mAvatarNameCacheConnections.emplace(agent_id, connection); - addObserver(agent_id_string, url, cb); + if (cb) + { + auto connection = LLAvatarNameCache::get(agent_id, boost::bind(&LLUrlEntryAgentName::onAvatarNameCache, this, _1, _2)); + mAvatarNameCacheConnections.emplace(agent_id, connection); + addObserver(agent_id_string, url, cb); + } return LLTrans::getString("LoadingData"); } } @@ -921,10 +927,13 @@ std::string LLUrlEntryGroup::getLabel(const std::string &url, const LLUrlLabelCa } else { - gCacheName->getGroup(group_id, - boost::bind(&LLUrlEntryGroup::onGroupNameReceived, - this, _1, _2, _3)); - addObserver(group_id_string, url, cb); + if (cb) + { + gCacheName->getGroup(group_id, + boost::bind(&LLUrlEntryGroup::onGroupNameReceived, + this, _1, _2, _3)); + addObserver(group_id_string, url, cb); + } return LLTrans::getString("LoadingData"); } } @@ -1028,7 +1037,7 @@ std::string LLUrlEntryParcel::getLabel(const std::string &url, const LLUrlLabelC std::string parcel_id_string = unescapeUrl(path_array[2]); // parcel id // Add an observer to call LLUrlLabelCallback when we have parcel name. - addObserver(parcel_id_string, url, cb); + if (cb) addObserver(parcel_id_string, url, cb); LLUUID parcel_id(parcel_id_string); diff --git a/indra/llui/llurlentry.h b/indra/llui/llurlentry.h index d526ea957..01f1fb1ae 100644 --- a/indra/llui/llurlentry.h +++ b/indra/llui/llurlentry.h @@ -42,7 +42,7 @@ class LLAvatarName; typedef boost::signals2::signal LLUrlLabelSignal; -typedef LLUrlLabelSignal::slot_type LLUrlLabelCallback; +typedef LLUrlLabelSignal::slot_function_type LLUrlLabelCallback; /// /// LLUrlEntryBase is the base class of all Url types registered in the