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
meow-7.2.2
Dmitry Zaporozhan 2009-12-03 17:55:17 +02:00
parent 8275ea2680
commit 7dce1bad0c
2 changed files with 42 additions and 13 deletions

View File

@ -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);

View File

@ -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;