Skip to content
Snippets Groups Projects
Commit fc5030fc authored by Merov Linden's avatar Merov Linden
Browse files

EXP-1286 : Clean-up the mess I added to llcommandmanager. All CommandId now...

EXP-1286 : Clean-up the mess I added to llcommandmanager. All CommandId now have a trusted UUID which is the base for indexing and comparison.
parent 55d2e002
No related branches found
No related tags found
No related merge requests found
...@@ -114,7 +114,7 @@ LLCommand * LLCommandManager::getCommand(const LLCommandId& commandId) ...@@ -114,7 +114,7 @@ LLCommand * LLCommandManager::getCommand(const LLCommandId& commandId)
{ {
LLCommand * command_match = NULL; LLCommand * command_match = NULL;
CommandIndexMap::const_iterator found = mCommandIndices.find(commandId); CommandIndexMap::const_iterator found = mCommandIndices.find(commandId.uuid());
if (found != mCommandIndices.end()) if (found != mCommandIndices.end())
{ {
...@@ -124,25 +124,10 @@ LLCommand * LLCommandManager::getCommand(const LLCommandId& commandId) ...@@ -124,25 +124,10 @@ LLCommand * LLCommandManager::getCommand(const LLCommandId& commandId)
return command_match; return command_match;
} }
LLCommand * LLCommandManager::getCommand(const LLUUID& commandUUID)
{
LLCommand * command_match = NULL;
CommandUUIDMap::const_iterator found = mCommandUUIDs.find(commandUUID);
if (found != mCommandUUIDs.end())
{
command_match = mCommands[found->second];
}
return command_match;
}
void LLCommandManager::addCommand(LLCommand * command) void LLCommandManager::addCommand(LLCommand * command)
{ {
LLCommandId command_id = command->id(); LLCommandId command_id = command->id();
mCommandIndices[command_id] = mCommands.size(); mCommandIndices[command_id.uuid()] = mCommands.size();
mCommandUUIDs[command_id.uuid()] = mCommands.size();
mCommands.push_back(command); mCommands.push_back(command);
lldebugs << "Successfully added command: " << command->id().name() << llendl; lldebugs << "Successfully added command: " << command->id().name() << llendl;
......
...@@ -62,17 +62,24 @@ class LLCommandId ...@@ -62,17 +62,24 @@ class LLCommandId
mUUID = LLUUID::generateNewID(p.name); mUUID = LLUUID::generateNewID(p.name);
} }
LLCommandId(const LLUUID& uuid)
: mName(""),
mUUID(uuid)
{
}
const std::string& name() const { return mName; } const std::string& name() const { return mName; }
const LLUUID& uuid() const { return mUUID; } const LLUUID& uuid() const { return mUUID; }
bool operator!=(const LLCommandId& command) const bool operator!=(const LLCommandId& command) const
{ {
return (mName != command.mName); return (mUUID != command.mUUID);
} }
bool operator==(const LLCommandId& command) const bool operator==(const LLCommandId& command) const
{ {
return (mName == command.mName); return (mUUID == command.mUUID);
} }
bool operator<(const LLCommandId& command) const bool operator<(const LLCommandId& command) const
...@@ -178,7 +185,6 @@ class LLCommandManager ...@@ -178,7 +185,6 @@ class LLCommandManager
U32 commandCount() const; U32 commandCount() const;
LLCommand * getCommand(U32 commandIndex); LLCommand * getCommand(U32 commandIndex);
LLCommand * getCommand(const LLCommandId& commandId); LLCommand * getCommand(const LLCommandId& commandId);
LLCommand * getCommand(const LLUUID& commandUUID);
static bool load(); static bool load();
...@@ -186,13 +192,11 @@ class LLCommandManager ...@@ -186,13 +192,11 @@ class LLCommandManager
void addCommand(LLCommand * command); void addCommand(LLCommand * command);
private: private:
typedef std::map<LLUUID, U32> CommandUUIDMap; typedef std::map<LLUUID, U32> CommandIndexMap;
typedef std::map<LLCommandId, U32> CommandIndexMap;
typedef std::vector<LLCommand *> CommandVector; typedef std::vector<LLCommand *> CommandVector;
CommandVector mCommands; CommandVector mCommands;
CommandIndexMap mCommandIndices; CommandIndexMap mCommandIndices;
CommandUUIDMap mCommandUUIDs;
}; };
......
...@@ -373,7 +373,8 @@ BOOL LLToolBarView::handleDrop( void* cargo_data, S32 x, S32 y, LLToolBar* toolb ...@@ -373,7 +373,8 @@ BOOL LLToolBarView::handleDrop( void* cargo_data, S32 x, S32 y, LLToolBar* toolb
//llinfos << "Merov debug : handleDrop. Drop source is a widget -> drop it in place..." << llendl; //llinfos << "Merov debug : handleDrop. Drop source is a widget -> drop it in place..." << llendl;
// Get the command from its uuid // Get the command from its uuid
LLCommandManager& mgr = LLCommandManager::instance(); LLCommandManager& mgr = LLCommandManager::instance();
LLCommand* command = mgr.getCommand(inv_item->getUUID()); LLCommandId command_id(inv_item->getUUID());
LLCommand* command = mgr.getCommand(command_id);
if (command) if (command)
{ {
// Convert the (x,y) position in rank in toolbar // Convert the (x,y) position in rank in toolbar
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment