summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Zaporozhan <dzaporozhan@productengine.com>2009-12-03 17:55:17 +0200
committerDmitry Zaporozhan <dzaporozhan@productengine.com>2009-12-03 17:55:17 +0200
commit7dce1bad0c4e7d3f9cebd11173146fc775f687f3 (patch)
tree473b73ef540752472ac9b49b781d1dd0b9cc00f6
parent8275ea26804689fbb451b5a84e927b295b06f70c (diff)
Fixed normal bug EXT-3021 - Viewer crashes on receiving notification for creating script(offer) chiclet for same object in second time.
--HG-- branch : product-engine
-rw-r--r--indra/newview/llscriptfloater.cpp46
-rw-r--r--indra/newview/llscriptfloater.h9
2 files changed, 42 insertions, 13 deletions
diff --git a/indra/newview/llscriptfloater.cpp b/indra/newview/llscriptfloater.cpp
index ad95c8b06e..088884178b 100644
--- a/indra/newview/llscriptfloater.cpp
+++ b/indra/newview/llscriptfloater.cpp
@@ -64,13 +64,13 @@ LLUUID notification_id_to_object_id(const LLUUID& notification_id)
LLScriptFloater::LLScriptFloater(const LLSD& key)
: LLDockableFloater(NULL, true, key)
, mScriptForm(NULL)
-, mObjectId(key.asUUID())
{
}
bool LLScriptFloater::toggle(const LLUUID& object_id)
{
- LLScriptFloater* floater = LLFloaterReg::findTypedInstance<LLScriptFloater>("script_floater", object_id);
+ LLUUID notification_id = LLScriptFloaterManager::getInstance()->findNotificationId(object_id);
+ LLScriptFloater* floater = LLFloaterReg::findTypedInstance<LLScriptFloater>("script_floater", notification_id);
// show existing floater
if(floater)
@@ -97,7 +97,10 @@ bool LLScriptFloater::toggle(const LLUUID& object_id)
LLScriptFloater* LLScriptFloater::show(const LLUUID& object_id)
{
- LLScriptFloater* floater = LLFloaterReg::showTypedInstance<LLScriptFloater>("script_floater", object_id);
+ LLUUID notification_id = LLScriptFloaterManager::getInstance()->findNotificationId(object_id);
+
+ LLScriptFloater* floater = LLFloaterReg::showTypedInstance<LLScriptFloater>("script_floater", notification_id);
+ floater->setObjectId(object_id);
floater->createForm(object_id);
if (floater->getDockControl() == NULL)
@@ -156,7 +159,10 @@ void LLScriptFloater::createForm(const LLUUID& object_id)
void LLScriptFloater::onClose(bool app_quitting)
{
- LLScriptFloaterManager::getInstance()->removeNotificationByObjectId(getObjectId());
+ if(getObjectId().notNull())
+ {
+ LLScriptFloaterManager::getInstance()->removeNotificationByObjectId(getObjectId());
+ }
}
void LLScriptFloater::setDocked(bool docked, bool pop_on_undock /* = true */)
@@ -206,7 +212,7 @@ void LLScriptFloaterManager::onAddNotification(const LLUUID& notification_id)
script_notification_map_t::iterator it = mNotifications.find(object_id);
if(it != mNotifications.end())
{
- onRemoveNotification(notification_id);
+ onRemoveNotification(it->second.notification_id);
}
LLNotificationData nd = {notification_id};
@@ -228,7 +234,7 @@ void LLScriptFloaterManager::onAddNotification(const LLUUID& notification_id)
void LLScriptFloaterManager::onRemoveNotification(const LLUUID& notification_id)
{
- LLUUID object_id = notification_id_to_object_id(notification_id);
+ LLUUID object_id = findObjectId(notification_id);
if(object_id.isNull())
{
llwarns << "Invalid notification, no object id" << llendl;
@@ -241,22 +247,24 @@ void LLScriptFloaterManager::onRemoveNotification(const LLUUID& notification_id)
LLUUID channel_id(gSavedSettings.getString("NotificationChannelUUID"));
LLScreenChannel* channel = dynamic_cast<LLScreenChannel*>
(LLChannelManager::getInstance()->findChannelByID(channel_id));
- if(channel)
+ LLUUID n_toast_id = findNotificationToastId(object_id);
+ if(channel && n_toast_id.notNull())
{
- channel->killToastByNotificationID(findNotificationToastId(object_id));
+ channel->killToastByNotificationID(n_toast_id);
}
- mNotifications.erase(object_id);
-
// remove related chiclet
LLBottomTray::getInstance()->getChicletPanel()->removeChiclet(object_id);
// close floater
- LLScriptFloater* floater = LLFloaterReg::findTypedInstance<LLScriptFloater>("script_floater", object_id);
+ LLScriptFloater* floater = LLFloaterReg::findTypedInstance<LLScriptFloater>("script_floater", notification_id);
if(floater)
{
+ floater->setObjectId(LLUUID::null);
floater->closeFloater();
}
+
+ mNotifications.erase(object_id);
}
void LLScriptFloaterManager::removeNotificationByObjectId(const LLUUID& object_id)
@@ -301,6 +309,22 @@ void LLScriptFloaterManager::setNotificationToastId(const LLUUID& object_id, con
}
}
+LLUUID LLScriptFloaterManager::findObjectId(const LLUUID& notification_id)
+{
+ if(notification_id.notNull())
+ {
+ script_notification_map_t::const_iterator it = mNotifications.begin();
+ for(; mNotifications.end() != it; ++it)
+ {
+ if(notification_id == it->second.notification_id)
+ {
+ return it->first;
+ }
+ }
+ }
+ return LLUUID::null;
+}
+
LLUUID LLScriptFloaterManager::findNotificationId(const LLUUID& object_id)
{
script_notification_map_t::const_iterator it = mNotifications.find(object_id);
diff --git a/indra/newview/llscriptfloater.h b/indra/newview/llscriptfloater.h
index 944b0ba0a2..8b5a266691 100644
--- a/indra/newview/llscriptfloater.h
+++ b/indra/newview/llscriptfloater.h
@@ -43,6 +43,9 @@ class LLToastNotifyPanel;
*/
class LLScriptFloaterManager : public LLSingleton<LLScriptFloaterManager>
{
+ // *TODO
+ // LLScriptFloaterManager and LLScriptFloater will need some refactoring after we
+ // know how script notifications should look like.
public:
/**
@@ -69,6 +72,8 @@ public:
*/
void toggleScriptFloater(const LLUUID& object_id);
+ LLUUID findObjectId(const LLUUID& notification_id);
+
LLUUID findNotificationId(const LLUUID& object_id);
LLUUID findNotificationToastId(const LLUUID& object_id);
@@ -125,6 +130,8 @@ public:
const LLUUID& getObjectId() { return mObjectId; }
+ void setObjectId(const LLUUID& id) { mObjectId = id; }
+
/**
* Close notification if script floater is closed.
*/
@@ -154,8 +161,6 @@ protected:
*/
static void hideToastsIfNeeded();
- void setObjectId(const LLUUID& id) { mObjectId = id; }
-
private:
LLToastNotifyPanel* mScriptForm;
LLUUID mObjectId;