diff options
author | Jacek Antonelli | 2008-08-15 23:44:50 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:44:50 -0500 |
commit | 89fe5dab825a62a0e3fd8d248cbc91c65eb2a426 (patch) | |
tree | bcff14b7888d04a2fec799c59369f6095224bd08 /linden/indra/llxml/llcontrol.cpp | |
parent | Second Life viewer sources 1.13.3.2 (diff) | |
download | meta-impy-89fe5dab825a62a0e3fd8d248cbc91c65eb2a426.zip meta-impy-89fe5dab825a62a0e3fd8d248cbc91c65eb2a426.tar.gz meta-impy-89fe5dab825a62a0e3fd8d248cbc91c65eb2a426.tar.bz2 meta-impy-89fe5dab825a62a0e3fd8d248cbc91c65eb2a426.tar.xz |
Second Life viewer sources 1.14.0.0
Diffstat (limited to 'linden/indra/llxml/llcontrol.cpp')
-rw-r--r-- | linden/indra/llxml/llcontrol.cpp | 75 |
1 files changed, 38 insertions, 37 deletions
diff --git a/linden/indra/llxml/llcontrol.cpp b/linden/indra/llxml/llcontrol.cpp index 79fd522..c365aed 100644 --- a/linden/indra/llxml/llcontrol.cpp +++ b/linden/indra/llxml/llcontrol.cpp | |||
@@ -132,7 +132,8 @@ void LLControlGroup::cleanup() | |||
132 | 132 | ||
133 | LLControlBase* LLControlGroup::getControl(const LLString& name) | 133 | LLControlBase* LLControlGroup::getControl(const LLString& name) |
134 | { | 134 | { |
135 | return mNameTable[name]; | 135 | ctrl_name_table_t::iterator iter = mNameTable.find(name); |
136 | return iter == mNameTable.end() ? NULL : (LLControlBase*)iter->second; | ||
136 | } | 137 | } |
137 | 138 | ||
138 | BOOL LLControlGroup::declareControl(const LLString& name, eControlType type, const LLSD initial_val, const LLString& comment, BOOL persist) | 139 | BOOL LLControlGroup::declareControl(const LLString& name, eControlType type, const LLSD initial_val, const LLString& comment, BOOL persist) |
@@ -143,9 +144,11 @@ BOOL LLControlGroup::declareControl(const LLString& name, eControlType type, con | |||
143 | LLControl* control = new LLControl(name, type, initial_val, comment, persist); | 144 | LLControl* control = new LLControl(name, type, initial_val, comment, persist); |
144 | mNameTable[name] = control; | 145 | mNameTable[name] = control; |
145 | return TRUE; | 146 | return TRUE; |
146 | } else | 147 | } |
148 | else | ||
147 | { | 149 | { |
148 | llwarns << "LLControlGroup::declareControl: Control named " << name << " already exists." << llendl; | 150 | llwarns << "LLControlGroup::declareControl: Control named " << name << " already exists." << llendl; |
151 | mNameTable.erase(name); | ||
149 | return FALSE; | 152 | return FALSE; |
150 | } | 153 | } |
151 | } | 154 | } |
@@ -207,7 +210,7 @@ BOOL LLControlGroup::declareColor3(const LLString& name, const LLColor3 &initial | |||
207 | 210 | ||
208 | LLSD LLControlGroup::registerListener(const LLString& name, LLSimpleListenerObservable *listener) | 211 | LLSD LLControlGroup::registerListener(const LLString& name, LLSimpleListenerObservable *listener) |
209 | { | 212 | { |
210 | LLControlBase *control = mNameTable[name]; | 213 | LLControlBase *control = getControl(name); |
211 | if (control) | 214 | if (control) |
212 | { | 215 | { |
213 | return control->registerListener(listener); | 216 | return control->registerListener(listener); |
@@ -217,7 +220,7 @@ LLSD LLControlGroup::registerListener(const LLString& name, LLSimpleListenerObse | |||
217 | 220 | ||
218 | BOOL LLControlGroup::getBOOL(const LLString& name) | 221 | BOOL LLControlGroup::getBOOL(const LLString& name) |
219 | { | 222 | { |
220 | LLControlBase* control = mNameTable[name]; | 223 | LLControlBase* control = getControl(name); |
221 | 224 | ||
222 | if (control && control->isType(TYPE_BOOLEAN)) | 225 | if (control && control->isType(TYPE_BOOLEAN)) |
223 | return control->get().asBoolean(); | 226 | return control->get().asBoolean(); |
@@ -230,7 +233,7 @@ BOOL LLControlGroup::getBOOL(const LLString& name) | |||
230 | 233 | ||
231 | S32 LLControlGroup::getS32(const LLString& name) | 234 | S32 LLControlGroup::getS32(const LLString& name) |
232 | { | 235 | { |
233 | LLControlBase* control = mNameTable[name]; | 236 | LLControlBase* control = getControl(name); |
234 | 237 | ||
235 | if (control && control->isType(TYPE_S32)) | 238 | if (control && control->isType(TYPE_S32)) |
236 | return control->get().asInteger(); | 239 | return control->get().asInteger(); |
@@ -243,7 +246,7 @@ S32 LLControlGroup::getS32(const LLString& name) | |||
243 | 246 | ||
244 | U32 LLControlGroup::getU32(const LLString& name) | 247 | U32 LLControlGroup::getU32(const LLString& name) |
245 | { | 248 | { |
246 | LLControlBase* control = mNameTable[name]; | 249 | LLControlBase* control = getControl(name); |
247 | 250 | ||
248 | if (control && control->isType(TYPE_U32)) | 251 | if (control && control->isType(TYPE_U32)) |
249 | return control->get().asInteger(); | 252 | return control->get().asInteger(); |
@@ -256,7 +259,7 @@ U32 LLControlGroup::getU32(const LLString& name) | |||
256 | 259 | ||
257 | F32 LLControlGroup::getF32(const LLString& name) | 260 | F32 LLControlGroup::getF32(const LLString& name) |
258 | { | 261 | { |
259 | LLControlBase* control = mNameTable[name]; | 262 | LLControlBase* control = getControl(name); |
260 | 263 | ||
261 | if (control && control->isType(TYPE_F32)) | 264 | if (control && control->isType(TYPE_F32)) |
262 | return (F32) control->get().asReal(); | 265 | return (F32) control->get().asReal(); |
@@ -269,7 +272,7 @@ F32 LLControlGroup::getF32(const LLString& name) | |||
269 | 272 | ||
270 | LLString LLControlGroup::findString(const LLString& name) | 273 | LLString LLControlGroup::findString(const LLString& name) |
271 | { | 274 | { |
272 | LLControlBase* control = mNameTable[name]; | 275 | LLControlBase* control = getControl(name); |
273 | 276 | ||
274 | if (control && control->isType(TYPE_STRING)) | 277 | if (control && control->isType(TYPE_STRING)) |
275 | return control->get().asString(); | 278 | return control->get().asString(); |
@@ -278,7 +281,7 @@ LLString LLControlGroup::findString(const LLString& name) | |||
278 | 281 | ||
279 | LLString LLControlGroup::getString(const LLString& name) | 282 | LLString LLControlGroup::getString(const LLString& name) |
280 | { | 283 | { |
281 | LLControlBase* control = mNameTable[name]; | 284 | LLControlBase* control = getControl(name); |
282 | 285 | ||
283 | if (control && control->isType(TYPE_STRING)) | 286 | if (control && control->isType(TYPE_STRING)) |
284 | return control->get().asString(); | 287 | return control->get().asString(); |
@@ -304,7 +307,7 @@ LLString LLControlGroup::getText(const LLString& name) | |||
304 | 307 | ||
305 | LLVector3 LLControlGroup::getVector3(const LLString& name) | 308 | LLVector3 LLControlGroup::getVector3(const LLString& name) |
306 | { | 309 | { |
307 | LLControlBase* control = mNameTable[name]; | 310 | LLControlBase* control = getControl(name); |
308 | 311 | ||
309 | if (control && control->isType(TYPE_VEC3)) | 312 | if (control && control->isType(TYPE_VEC3)) |
310 | return control->get(); | 313 | return control->get(); |
@@ -317,7 +320,7 @@ LLVector3 LLControlGroup::getVector3(const LLString& name) | |||
317 | 320 | ||
318 | LLVector3d LLControlGroup::getVector3d(const LLString& name) | 321 | LLVector3d LLControlGroup::getVector3d(const LLString& name) |
319 | { | 322 | { |
320 | LLControlBase* control = mNameTable[name]; | 323 | LLControlBase* control = getControl(name); |
321 | 324 | ||
322 | if (control && control->isType(TYPE_VEC3D)) | 325 | if (control && control->isType(TYPE_VEC3D)) |
323 | return control->get(); | 326 | return control->get(); |
@@ -330,7 +333,7 @@ LLVector3d LLControlGroup::getVector3d(const LLString& name) | |||
330 | 333 | ||
331 | LLRect LLControlGroup::getRect(const LLString& name) | 334 | LLRect LLControlGroup::getRect(const LLString& name) |
332 | { | 335 | { |
333 | LLControlBase* control = mNameTable[name]; | 336 | LLControlBase* control = getControl(name); |
334 | 337 | ||
335 | if (control && control->isType(TYPE_RECT)) | 338 | if (control && control->isType(TYPE_RECT)) |
336 | return control->get(); | 339 | return control->get(); |
@@ -376,7 +379,7 @@ LLColor4 LLControlGroup::getColor(const LLString& name) | |||
376 | 379 | ||
377 | LLColor4U LLControlGroup::getColor4U(const LLString& name) | 380 | LLColor4U LLControlGroup::getColor4U(const LLString& name) |
378 | { | 381 | { |
379 | LLControlBase* control = mNameTable[name]; | 382 | LLControlBase* control = getControl(name); |
380 | 383 | ||
381 | if (control && control->isType(TYPE_COL4U)) | 384 | if (control && control->isType(TYPE_COL4U)) |
382 | return control->get(); | 385 | return control->get(); |
@@ -389,7 +392,7 @@ LLColor4U LLControlGroup::getColor4U(const LLString& name) | |||
389 | 392 | ||
390 | LLColor4 LLControlGroup::getColor4(const LLString& name) | 393 | LLColor4 LLControlGroup::getColor4(const LLString& name) |
391 | { | 394 | { |
392 | LLControlBase* control = mNameTable[name]; | 395 | LLControlBase* control = getControl(name); |
393 | 396 | ||
394 | if (control && control->isType(TYPE_COL4)) | 397 | if (control && control->isType(TYPE_COL4)) |
395 | return control->get(); | 398 | return control->get(); |
@@ -402,7 +405,7 @@ LLColor4 LLControlGroup::getColor4(const LLString& name) | |||
402 | 405 | ||
403 | LLColor3 LLControlGroup::getColor3(const LLString& name) | 406 | LLColor3 LLControlGroup::getColor3(const LLString& name) |
404 | { | 407 | { |
405 | LLControlBase* control = mNameTable[name]; | 408 | LLControlBase* control = getControl(name); |
406 | 409 | ||
407 | if (control && control->isType(TYPE_COL3)) | 410 | if (control && control->isType(TYPE_COL3)) |
408 | return control->get(); | 411 | return control->get(); |
@@ -415,9 +418,8 @@ LLColor3 LLControlGroup::getColor3(const LLString& name) | |||
415 | 418 | ||
416 | BOOL LLControlGroup::controlExists(const LLString& name) | 419 | BOOL LLControlGroup::controlExists(const LLString& name) |
417 | { | 420 | { |
418 | void *control = mNameTable[name]; | 421 | ctrl_name_table_t::iterator iter = mNameTable.find(name); |
419 | 422 | return iter != mNameTable.end(); | |
420 | return (control != 0); | ||
421 | } | 423 | } |
422 | 424 | ||
423 | //------------------------------------------------------------------- | 425 | //------------------------------------------------------------------- |
@@ -426,7 +428,7 @@ BOOL LLControlGroup::controlExists(const LLString& name) | |||
426 | 428 | ||
427 | void LLControlGroup::setBOOL(const LLString& name, BOOL val) | 429 | void LLControlGroup::setBOOL(const LLString& name, BOOL val) |
428 | { | 430 | { |
429 | LLControlBase* control = mNameTable[name]; | 431 | LLControlBase* control = getControl(name); |
430 | 432 | ||
431 | if (control && control->isType(TYPE_BOOLEAN)) | 433 | if (control && control->isType(TYPE_BOOLEAN)) |
432 | { | 434 | { |
@@ -441,7 +443,7 @@ void LLControlGroup::setBOOL(const LLString& name, BOOL val) | |||
441 | 443 | ||
442 | void LLControlGroup::setS32(const LLString& name, S32 val) | 444 | void LLControlGroup::setS32(const LLString& name, S32 val) |
443 | { | 445 | { |
444 | LLControlBase* control = mNameTable[name]; | 446 | LLControlBase* control = getControl(name); |
445 | 447 | ||
446 | if (control && control->isType(TYPE_S32)) | 448 | if (control && control->isType(TYPE_S32)) |
447 | { | 449 | { |
@@ -456,7 +458,7 @@ void LLControlGroup::setS32(const LLString& name, S32 val) | |||
456 | 458 | ||
457 | void LLControlGroup::setF32(const LLString& name, F32 val) | 459 | void LLControlGroup::setF32(const LLString& name, F32 val) |
458 | { | 460 | { |
459 | LLControlBase* control = mNameTable[name]; | 461 | LLControlBase* control = getControl(name); |
460 | 462 | ||
461 | if (control && control->isType(TYPE_F32)) | 463 | if (control && control->isType(TYPE_F32)) |
462 | { | 464 | { |
@@ -471,7 +473,7 @@ void LLControlGroup::setF32(const LLString& name, F32 val) | |||
471 | 473 | ||
472 | void LLControlGroup::setU32(const LLString& name, U32 val) | 474 | void LLControlGroup::setU32(const LLString& name, U32 val) |
473 | { | 475 | { |
474 | LLControlBase* control = mNameTable[name]; | 476 | LLControlBase* control = getControl(name); |
475 | 477 | ||
476 | if (control && control->isType(TYPE_U32)) | 478 | if (control && control->isType(TYPE_U32)) |
477 | { | 479 | { |
@@ -486,7 +488,7 @@ void LLControlGroup::setU32(const LLString& name, U32 val) | |||
486 | 488 | ||
487 | void LLControlGroup::setString(const LLString& name, const LLString &val) | 489 | void LLControlGroup::setString(const LLString& name, const LLString &val) |
488 | { | 490 | { |
489 | LLControlBase* control = mNameTable[name]; | 491 | LLControlBase* control = getControl(name); |
490 | 492 | ||
491 | if (control && control->isType(TYPE_STRING)) | 493 | if (control && control->isType(TYPE_STRING)) |
492 | { | 494 | { |
@@ -501,7 +503,7 @@ void LLControlGroup::setString(const LLString& name, const LLString &val) | |||
501 | 503 | ||
502 | void LLControlGroup::setVector3(const LLString& name, const LLVector3 &val) | 504 | void LLControlGroup::setVector3(const LLString& name, const LLVector3 &val) |
503 | { | 505 | { |
504 | LLControlBase* control = mNameTable[name]; | 506 | LLControlBase* control = getControl(name); |
505 | 507 | ||
506 | if (control && control->isType(TYPE_VEC3)) | 508 | if (control && control->isType(TYPE_VEC3)) |
507 | { | 509 | { |
@@ -515,7 +517,7 @@ void LLControlGroup::setVector3(const LLString& name, const LLVector3 &val) | |||
515 | 517 | ||
516 | void LLControlGroup::setVector3d(const LLString& name, const LLVector3d &val) | 518 | void LLControlGroup::setVector3d(const LLString& name, const LLVector3d &val) |
517 | { | 519 | { |
518 | LLControlBase* control = mNameTable[name]; | 520 | LLControlBase* control = getControl(name); |
519 | 521 | ||
520 | if (control && control->isType(TYPE_VEC3D)) | 522 | if (control && control->isType(TYPE_VEC3D)) |
521 | { | 523 | { |
@@ -529,7 +531,7 @@ void LLControlGroup::setVector3d(const LLString& name, const LLVector3d &val) | |||
529 | 531 | ||
530 | void LLControlGroup::setRect(const LLString& name, const LLRect &val) | 532 | void LLControlGroup::setRect(const LLString& name, const LLRect &val) |
531 | { | 533 | { |
532 | LLControlBase* control = mNameTable[name]; | 534 | LLControlBase* control = getControl(name); |
533 | 535 | ||
534 | if (control && control->isType(TYPE_RECT)) | 536 | if (control && control->isType(TYPE_RECT)) |
535 | { | 537 | { |
@@ -543,7 +545,7 @@ void LLControlGroup::setRect(const LLString& name, const LLRect &val) | |||
543 | 545 | ||
544 | void LLControlGroup::setColor4U(const LLString& name, const LLColor4U &val) | 546 | void LLControlGroup::setColor4U(const LLString& name, const LLColor4U &val) |
545 | { | 547 | { |
546 | LLControlBase* control = mNameTable[name]; | 548 | LLControlBase* control = getControl(name); |
547 | 549 | ||
548 | if (control && control->isType(TYPE_COL4U)) | 550 | if (control && control->isType(TYPE_COL4U)) |
549 | { | 551 | { |
@@ -557,7 +559,7 @@ void LLControlGroup::setColor4U(const LLString& name, const LLColor4U &val) | |||
557 | 559 | ||
558 | void LLControlGroup::setColor4(const LLString& name, const LLColor4 &val) | 560 | void LLControlGroup::setColor4(const LLString& name, const LLColor4 &val) |
559 | { | 561 | { |
560 | LLControlBase* control = mNameTable[name]; | 562 | LLControlBase* control = getControl(name); |
561 | 563 | ||
562 | if (control && control->isType(TYPE_COL4)) | 564 | if (control && control->isType(TYPE_COL4)) |
563 | { | 565 | { |
@@ -576,7 +578,7 @@ void LLControlGroup::setValue(const LLString& name, const LLSD& val) | |||
576 | return; | 578 | return; |
577 | } | 579 | } |
578 | 580 | ||
579 | LLControlBase* control = mNameTable[name]; | 581 | LLControlBase* control = getControl(name); |
580 | 582 | ||
581 | if (control) | 583 | if (control) |
582 | { | 584 | { |
@@ -599,7 +601,7 @@ U32 LLControlGroup::loadFromFileLegacy(const LLString& filename, BOOL require_de | |||
599 | llifstream file; | 601 | llifstream file; |
600 | S32 version; | 602 | S32 version; |
601 | 603 | ||
602 | file.open(filename.c_str()); | 604 | file.open(filename.c_str()); /*Flawfinder: ignore*/ |
603 | 605 | ||
604 | if (!file) | 606 | if (!file) |
605 | { | 607 | { |
@@ -629,7 +631,7 @@ U32 LLControlGroup::loadFromFileLegacy(const LLString& filename, BOOL require_de | |||
629 | if (name.substr(0,2) == "//") | 631 | if (name.substr(0,2) == "//") |
630 | { | 632 | { |
631 | // This is a comment. | 633 | // This is a comment. |
632 | char buffer[MAX_STRING]; | 634 | char buffer[MAX_STRING]; /*Flawfinder: ignore*/ |
633 | file.getline(buffer, MAX_STRING); | 635 | file.getline(buffer, MAX_STRING); |
634 | continue; | 636 | continue; |
635 | } | 637 | } |
@@ -643,7 +645,7 @@ U32 LLControlGroup::loadFromFileLegacy(const LLString& filename, BOOL require_de | |||
643 | if (!name.empty()) | 645 | if (!name.empty()) |
644 | { | 646 | { |
645 | //read in to end of line | 647 | //read in to end of line |
646 | char buffer[MAX_STRING]; | 648 | char buffer[MAX_STRING]; /*Flawfinder: ignore*/ |
647 | file.getline(buffer, MAX_STRING); | 649 | file.getline(buffer, MAX_STRING); |
648 | llwarns << "LLControlGroup::loadFromFile() : Trying to set \"" << name << "\", setting doesn't exist." << llendl; | 650 | llwarns << "LLControlGroup::loadFromFile() : Trying to set \"" << name << "\", setting doesn't exist." << llendl; |
649 | } | 651 | } |
@@ -709,7 +711,7 @@ U32 LLControlGroup::loadFromFileLegacy(const LLString& filename, BOOL require_de | |||
709 | break; | 711 | break; |
710 | case TYPE_BOOLEAN: | 712 | case TYPE_BOOLEAN: |
711 | { | 713 | { |
712 | char boolstring[256]; | 714 | char boolstring[256]; /*Flawfinder: ignore*/ |
713 | BOOL valid = FALSE; | 715 | BOOL valid = FALSE; |
714 | BOOL initial = FALSE; | 716 | BOOL initial = FALSE; |
715 | 717 | ||
@@ -858,7 +860,7 @@ U32 LLControlGroup::loadFromFile(const LLString& filename, BOOL require_declarat | |||
858 | { | 860 | { |
859 | name = child_nodep->getName(); | 861 | name = child_nodep->getName(); |
860 | 862 | ||
861 | BOOL declared = (mNameTable[name].notNull()); | 863 | BOOL declared = controlExists(name); |
862 | 864 | ||
863 | if (require_declaration && !declared) | 865 | if (require_declaration && !declared) |
864 | { | 866 | { |
@@ -1045,8 +1047,7 @@ U32 LLControlGroup::saveToFile(const LLString& filename, BOOL nondefault_only) | |||
1045 | break; | 1047 | break; |
1046 | } | 1048 | } |
1047 | 1049 | ||
1048 | LLControlBase* control = (LLControlBase *)mNameTable[name]; | 1050 | LLControlBase* control = (LLControlBase *)iter->second; |
1049 | |||
1050 | if (!control) | 1051 | if (!control) |
1051 | { | 1052 | { |
1052 | llwarns << "Tried to save invalid control: " << name << llendl; | 1053 | llwarns << "Tried to save invalid control: " << name << llendl; |
@@ -1067,7 +1068,7 @@ U32 LLControlGroup::saveToFile(const LLString& filename, BOOL nondefault_only) | |||
1067 | } | 1068 | } |
1068 | 1069 | ||
1069 | llofstream file; | 1070 | llofstream file; |
1070 | file.open(filename.c_str()); | 1071 | file.open(filename.c_str()); /*Flawfinder: ignore*/ |
1071 | 1072 | ||
1072 | if (!file.is_open()) | 1073 | if (!file.is_open()) |
1073 | { | 1074 | { |