diff options
author | Armin Weatherwax | 2012-01-20 11:59:46 +0100 |
---|---|---|
committer | Armin Weatherwax | 2012-01-20 11:59:46 +0100 |
commit | b2bc53937f427f6ff7864f9c5d13e4e197e7d4b6 (patch) | |
tree | 7ca676bd1401006065554e58212b61578f90fd40 | |
parent | Followup of the last commit (also Henri Beauchamp) (diff) | |
download | meta-impy-b2bc53937f427f6ff7864f9c5d13e4e197e7d4b6.zip meta-impy-b2bc53937f427f6ff7864f9c5d13e4e197e7d4b6.tar.gz meta-impy-b2bc53937f427f6ff7864f9c5d13e4e197e7d4b6.tar.bz2 meta-impy-b2bc53937f427f6ff7864f9c5d13e4e197e7d4b6.tar.xz |
fix 3 possible memleaks in the new inventory code
-rw-r--r-- | linden/indra/newview/llfloateropenobject.cpp | 5 | ||||
-rw-r--r-- | linden/indra/newview/llinventorymodel.cpp | 36 |
2 files changed, 28 insertions, 13 deletions
diff --git a/linden/indra/newview/llfloateropenobject.cpp b/linden/indra/newview/llfloateropenobject.cpp index 4190c3e..3e672b5 100644 --- a/linden/indra/newview/llfloateropenobject.cpp +++ b/linden/indra/newview/llfloateropenobject.cpp | |||
@@ -195,6 +195,11 @@ void LLFloaterOpenObject::moveToInventory(bool wear) | |||
195 | void LLFloaterOpenObject::callbackCreateInventoryCategory(const LLSD& result, void* data) | 195 | void LLFloaterOpenObject::callbackCreateInventoryCategory(const LLSD& result, void* data) |
196 | { | 196 | { |
197 | LLCategoryCreate* cat_data = (LLCategoryCreate*)data; | 197 | LLCategoryCreate* cat_data = (LLCategoryCreate*)data; |
198 | if (result.has("failure") and result["failure"]) | ||
199 | { | ||
200 | delete cat_data; | ||
201 | return; | ||
202 | } | ||
198 | 203 | ||
199 | LLUUID category_id = result["folder_id"].asUUID(); | 204 | LLUUID category_id = result["folder_id"].asUUID(); |
200 | LLCatAndWear* wear_data = new LLCatAndWear; | 205 | LLCatAndWear* wear_data = new LLCatAndWear; |
diff --git a/linden/indra/newview/llinventorymodel.cpp b/linden/indra/newview/llinventorymodel.cpp index 0200ed0..dc216e3 100644 --- a/linden/indra/newview/llinventorymodel.cpp +++ b/linden/indra/newview/llinventorymodel.cpp | |||
@@ -60,6 +60,7 @@ | |||
60 | #include "llvoavatar.h" | 60 | #include "llvoavatar.h" |
61 | #include "llsdutil.h" | 61 | #include "llsdutil.h" |
62 | #include <deque> | 62 | #include <deque> |
63 | #include "llfloateropenobject.h" | ||
63 | 64 | ||
64 | // [RLVa:KB] | 65 | // [RLVa:KB] |
65 | #include "rlvhandler.h" | 66 | #include "rlvhandler.h" |
@@ -454,17 +455,25 @@ LLUUID LLInventoryModel::createNewCategory(const LLUUID& parent_id, | |||
454 | void (*callback)(const LLSD&, void*), | 455 | void (*callback)(const LLSD&, void*), |
455 | void* user_data) | 456 | void* user_data) |
456 | { | 457 | { |
458 | llassert_always(NULL != callback); | ||
459 | |||
457 | LLUUID id; | 460 | LLUUID id; |
461 | |||
458 | if(!isInventoryUsable()) | 462 | if(!isInventoryUsable()) |
459 | { | 463 | { |
460 | llwarns << "Inventory is broken." << llendl; | 464 | llwarns << "Inventory is broken." << llendl; |
461 | return id; | 465 | LLSD result; |
462 | } | 466 | result["failure"] = true; |
467 | callback(result, user_data); | ||
468 | } | ||
469 | |||
463 | 470 | ||
464 | if(preferred_type == LLAssetType::AT_SIMSTATE) | 471 | if(preferred_type == LLAssetType::AT_SIMSTATE) |
465 | { | 472 | { |
466 | LL_DEBUGS("Inventory") << "Attempt to create simstate category." << LL_ENDL; | 473 | LL_DEBUGS("Inventory") << "Attempt to create simstate category." << LL_ENDL; |
467 | return id; | 474 | LLSD result; |
475 | result["failure"] = true; | ||
476 | callback(result, user_data); | ||
468 | } | 477 | } |
469 | 478 | ||
470 | id.generate(); | 479 | id.generate(); |
@@ -483,15 +492,17 @@ LLUUID LLInventoryModel::createNewCategory(const LLUUID& parent_id, | |||
483 | name.assign(NEW_CATEGORY_NAME); | 492 | name.assign(NEW_CATEGORY_NAME); |
484 | } | 493 | } |
485 | 494 | ||
486 | if (callback && user_data) // callback required for acked message. | 495 | if (user_data) // callback required for acked message. |
487 | { | 496 | { |
488 | 497 | ||
489 | 498 | ||
490 | LLViewerRegion* viewer_region = gAgent.getRegion(); | 499 | LLViewerRegion* viewer_region = gAgent.getRegion(); |
491 | if (!viewer_region->capabilitiesReceived())//awfixme | 500 | |
501 | if (!viewer_region->capabilitiesReceived()) | ||
492 | { | 502 | { |
493 | LL_DEBUGS("Inventory") << "HIPPOS! not capabilitiesReceived()" << LL_ENDL; | 503 | LL_DEBUGS("Inventory") << "We didn't get the region caps yet." << LL_ENDL; |
494 | } | 504 | } |
505 | |||
495 | std::string url; | 506 | std::string url; |
496 | if (viewer_region) | 507 | if (viewer_region) |
497 | { | 508 | { |
@@ -517,17 +528,16 @@ LLUUID LLInventoryModel::createNewCategory(const LLUUID& parent_id, | |||
517 | user_data)); | 528 | user_data)); |
518 | return LLUUID::null; | 529 | return LLUUID::null; |
519 | } | 530 | } |
520 | else//awfixme | 531 | else |
521 | { | 532 | { |
522 | LL_DEBUGS("Inventory") << "HIPPOS! cap url empty" << LL_ENDL; | 533 | LL_DEBUGS("Inventory") << "Cap url empty" << LL_ENDL; |
523 | } | 534 | } |
524 | } | 535 | } |
525 | else//awfixme | 536 | else //NULL == user_data |
526 | { | 537 | { |
527 | LL_DEBUGS("Inventory") << "HIPPOS! callback: " | 538 | // user_data is a LLCategoryCreate object instantiated in the calling |
528 | << (callback ? "true" : "false") | 539 | // function - bug (or low memory - any leaks?). |
529 | << "user_data" << ((NULL!= user_data) ? "!NULL" : "NULL") | 540 | llwarns << "NULL user_data" << llendl; |
530 | << LL_ENDL; | ||
531 | } | 541 | } |
532 | 542 | ||
533 | // Add the category to the internal representation | 543 | // Add the category to the internal representation |