PATH-187: Using handles instead of pointers for safer implementation.

meow-7.2.2
Todd Stinson 2012-01-30 11:10:53 -08:00
parent 00693fc728
commit 588dc1b020
2 changed files with 66 additions and 45 deletions

View File

@ -32,7 +32,7 @@
#include "v3math.h"
#include "lltextvalidate.h"
#include "llagent.h"
#include "llfloater.h"
#include "llhandle.h"
#include "llfloaterreg.h"
#include "lltextbase.h"
#include "lllineeditor.h"
@ -59,7 +59,8 @@
class NavMeshDataGetResponder : public LLHTTPClient::Responder
{
public:
NavMeshDataGetResponder(const std::string& pNavMeshDataGetURL, LLFloaterPathfindingLinksets *pLinksetsFloater);
NavMeshDataGetResponder(const std::string& pNavMeshDataGetURL,
const LLHandle<LLFloaterPathfindingLinksets> &pLinksetsHandle);
virtual ~NavMeshDataGetResponder();
virtual void result(const LLSD& pContent);
@ -68,8 +69,8 @@ public:
private:
NavMeshDataGetResponder(const NavMeshDataGetResponder& pOther);
std::string mNavMeshDataGetURL;
LLFloaterPathfindingLinksets *mLinksetsFloater;
std::string mNavMeshDataGetURL;
LLHandle<LLFloaterPathfindingLinksets> mLinksetsFloaterHandle;
};
//---------------------------------------------------------------------------
@ -79,7 +80,8 @@ private:
class NavMeshDataPutResponder : public LLHTTPClient::Responder
{
public:
NavMeshDataPutResponder(const std::string& pNavMeshDataPutURL, LLFloaterPathfindingLinksets *pLinksetsFloater);
NavMeshDataPutResponder(const std::string& pNavMeshDataPutURL,
const LLHandle<LLFloaterPathfindingLinksets> &pLinksetsHandle);
virtual ~NavMeshDataPutResponder();
virtual void result(const LLSD& pContent);
@ -88,8 +90,8 @@ public:
private:
NavMeshDataPutResponder(const NavMeshDataPutResponder& pOther);
std::string mNavMeshDataPutURL;
LLFloaterPathfindingLinksets *mLinksetsFloater;
std::string mNavMeshDataPutURL;
LLHandle<LLFloaterPathfindingLinksets> mLinksetsFloaterHandle;
};
//---------------------------------------------------------------------------
@ -232,6 +234,7 @@ BOOL LLFloaterPathfindingLinksets::isMessagingInProgress() const
LLFloaterPathfindingLinksets::LLFloaterPathfindingLinksets(const LLSD& pSeed)
: LLFloater(pSeed),
mSelfHandle(),
mPathfindingLinksets(),
mMessagingState(kMessagingInitial),
mLinksetsScrollList(NULL),
@ -257,6 +260,7 @@ LLFloaterPathfindingLinksets::LLFloaterPathfindingLinksets(const LLSD& pSeed)
mEditPhantom(NULL),
mApplyEdits(NULL)
{
mSelfHandle.bind(this);
}
LLFloaterPathfindingLinksets::~LLFloaterPathfindingLinksets()
@ -287,7 +291,7 @@ void LLFloaterPathfindingLinksets::sendNavMeshDataGetRequest()
else
{
setMessagingState(kMessagingFetchRequestSent);
LLHTTPClient::get(navMeshDataURL, new NavMeshDataGetResponder(navMeshDataURL, this));
LLHTTPClient::get(navMeshDataURL, new NavMeshDataGetResponder(navMeshDataURL, mSelfHandle));
}
}
}
@ -303,7 +307,7 @@ void LLFloaterPathfindingLinksets::sendNavMeshDataPutRequest(const LLSD& pPostDa
}
else
{
LLHTTPClient::put(navMeshDataURL, pPostData, new NavMeshDataPutResponder(navMeshDataURL, this));
LLHTTPClient::put(navMeshDataURL, pPostData, new NavMeshDataPutResponder(navMeshDataURL, mSelfHandle));
}
}
}
@ -756,48 +760,64 @@ void LLFloaterPathfindingLinksets::setPathState(LLPathfindingLinkset::EPathState
// NavMeshDataGetResponder
//---------------------------------------------------------------------------
NavMeshDataGetResponder::NavMeshDataGetResponder(const std::string& pNavMeshDataGetURL, LLFloaterPathfindingLinksets *pLinksetsFloater)
NavMeshDataGetResponder::NavMeshDataGetResponder(const std::string& pNavMeshDataGetURL,
const LLHandle<LLFloaterPathfindingLinksets> &pLinksetsHandle)
: mNavMeshDataGetURL(pNavMeshDataGetURL),
mLinksetsFloater(pLinksetsFloater)
mLinksetsFloaterHandle(pLinksetsHandle)
{
}
NavMeshDataGetResponder::~NavMeshDataGetResponder()
{
mLinksetsFloater = NULL;
}
void NavMeshDataGetResponder::result(const LLSD& pContent)
{
mLinksetsFloater->handleNavMeshDataGetReply(pContent);
LLFloaterPathfindingLinksets *linksetsFloater = mLinksetsFloaterHandle.get();
if (linksetsFloater != NULL)
{
linksetsFloater->handleNavMeshDataGetReply(pContent);
}
}
void NavMeshDataGetResponder::error(U32 status, const std::string& reason)
{
mLinksetsFloater->handleNavMeshDataGetError(mNavMeshDataGetURL, reason);
LLFloaterPathfindingLinksets *linksetsFloater = mLinksetsFloaterHandle.get();
if (linksetsFloater != NULL)
{
linksetsFloater->handleNavMeshDataGetError(mNavMeshDataGetURL, reason);
}
}
//---------------------------------------------------------------------------
// NavMeshDataPutResponder
//---------------------------------------------------------------------------
NavMeshDataPutResponder::NavMeshDataPutResponder(const std::string& pNavMeshDataPutURL, LLFloaterPathfindingLinksets *pLinksetsFloater)
NavMeshDataPutResponder::NavMeshDataPutResponder(const std::string& pNavMeshDataPutURL,
const LLHandle<LLFloaterPathfindingLinksets> &pLinksetsHandle)
: mNavMeshDataPutURL(pNavMeshDataPutURL),
mLinksetsFloater(pLinksetsFloater)
mLinksetsFloaterHandle(pLinksetsHandle)
{
}
NavMeshDataPutResponder::~NavMeshDataPutResponder()
{
mLinksetsFloater = NULL;
}
void NavMeshDataPutResponder::result(const LLSD& pContent)
{
mLinksetsFloater->handleNavMeshDataPutReply(pContent);
LLFloaterPathfindingLinksets *linksetsFloater = mLinksetsFloaterHandle.get();
if (linksetsFloater != NULL)
{
linksetsFloater->handleNavMeshDataPutReply(pContent);
}
}
void NavMeshDataPutResponder::error(U32 status, const std::string& reason)
{
mLinksetsFloater->handleNavMeshDataPutError(mNavMeshDataPutURL, reason);
LLFloaterPathfindingLinksets *linksetsFloater = mLinksetsFloaterHandle.get();
if (linksetsFloater != NULL)
{
linksetsFloater->handleNavMeshDataPutError(mNavMeshDataPutURL, reason);
}
}

View File

@ -28,13 +28,13 @@
#ifndef LL_LLFLOATERPATHFINDINGLINKSETS_H
#define LL_LLFLOATERPATHFINDINGLINKSETS_H
#include "llsd.h"
#include "v3math.h"
#include "llhandle.h"
#include "llfloater.h"
#include "lluuid.h"
#include "llpathfindinglinkset.h"
#include "llfilteredpathfindinglinksets.h"
class LLSD;
class LLTextBase;
class LLScrollListCtrl;
class LLLineEditor;
@ -76,30 +76,31 @@ public:
protected:
private:
LLFilteredPathfindingLinksets mPathfindingLinksets;
EMessagingState mMessagingState;
LLScrollListCtrl *mLinksetsScrollList;
LLTextBase *mLinksetsStatus;
LLLineEditor *mFilterByName;
LLLineEditor *mFilterByDescription;
LLCheckBoxCtrl *mFilterByWalkable;
LLCheckBoxCtrl *mFilterByObstacle;
LLCheckBoxCtrl *mFilterByIgnored;
LLRadioGroup *mEditPathState;
LLUICtrl *mEditPathStateWalkable;
LLUICtrl *mEditPathStateObstacle;
LLUICtrl *mEditPathStateIgnored;
LLTextBase *mLabelWalkabilityCoefficients;
LLTextBase *mLabelEditA;
LLTextBase *mLabelEditB;
LLTextBase *mLabelEditC;
LLTextBase *mLabelEditD;
LLLineEditor *mEditA;
LLLineEditor *mEditB;
LLLineEditor *mEditC;
LLLineEditor *mEditD;
LLCheckBoxCtrl *mEditPhantom;
LLButton *mApplyEdits;
LLRootHandle<LLFloaterPathfindingLinksets> mSelfHandle;
LLFilteredPathfindingLinksets mPathfindingLinksets;
EMessagingState mMessagingState;
LLScrollListCtrl *mLinksetsScrollList;
LLTextBase *mLinksetsStatus;
LLLineEditor *mFilterByName;
LLLineEditor *mFilterByDescription;
LLCheckBoxCtrl *mFilterByWalkable;
LLCheckBoxCtrl *mFilterByObstacle;
LLCheckBoxCtrl *mFilterByIgnored;
LLRadioGroup *mEditPathState;
LLUICtrl *mEditPathStateWalkable;
LLUICtrl *mEditPathStateObstacle;
LLUICtrl *mEditPathStateIgnored;
LLTextBase *mLabelWalkabilityCoefficients;
LLTextBase *mLabelEditA;
LLTextBase *mLabelEditB;
LLTextBase *mLabelEditC;
LLTextBase *mLabelEditD;
LLLineEditor *mEditA;
LLLineEditor *mEditB;
LLLineEditor *mEditC;
LLLineEditor *mEditD;
LLCheckBoxCtrl *mEditPhantom;
LLButton *mApplyEdits;
// Does its own instance management, so clients not allowed
// to allocate or destroy.