Commit Graph

1462 Commits (bd008a170898e69beeb8bc0481b4bfd94de86c55)

Author SHA1 Message Date
Nat Goodspeed 218c0a1d4f Automated merge with ssh://bitbucket.org/nat_linden/viewer-llsingleton 2019-12-13 13:20:21 -05:00
Nat Goodspeed 24499ac66f Automated merge with ssh://bitbucket.org/lindenlab/viewer-release 2019-12-13 12:30:03 -05:00
Nat Goodspeed b2913b7cf1 DRTVWR-494: Defend LLInstanceTracker against multi-thread usage.
The previous implementation went to some effort to crash if anyone attempted
to create or destroy an LLInstanceTracker subclass instance during traversal.
That restriction is manageable within a single thread, but becomes unworkable
if it's possible that a given subclass might be used on more than one thread.

Remove LLInstanceTracker::instance_iter, beginInstances(), endInstances(),
also key_iter, beginKeys() and endKeys(). Instead, introduce key_snapshot()
and instance_snapshot(), the only means of iterating over LLInstanceTracker
instances. (These are intended to resemble functions, but in fact the current
implementation simply presents the classes.) Iterating over a captured
snapshot defends against container modifications during traversal. The term
'snapshot' reminds the coder that a new instance created during traversal will
not be considered. To defend against instance deletion during traversal, a
snapshot stores std::weak_ptrs which it lazily dereferences, skipping on the
fly any that have expired.

Dereferencing instance_snapshot::iterator gets you a reference rather than a
pointer. Because some use cases want to delete all existing instances, add an
instance_snapshot::deleteAll() method that extracts the pointer. Those cases
used to require explicitly copying instance pointers into a separate
container; instance_snapshot() now takes care of that. It remains the caller's
responsibility to ensure that all instances of that LLInstanceTracker subclass
were allocated on the heap.

Replace unkeyed static LLInstanceTracker::getInstance(T*) -- which returned
nullptr if that instance had been destroyed -- with new getWeak() method
returning std::weak_ptr<T>. Caller must detect expiration of that weak_ptr.

Adjust tests accordingly.

Use of std::weak_ptr to detect expired instances requires engaging
std::shared_ptr in the constructor. We now store shared_ptrs in the static
containers (std::map for keyed, std::set for unkeyed).

Make LLInstanceTrackerBase a template parameterized on the type of the static
data it manages. For that reason, hoist static data class declarations out of
the class definitions to an LLInstanceTrackerStuff namespace.

Remove the static atomic sIterationNestDepth and its methods incrementDepth(),
decrementDepth() and getDepth(), since they were used only to forbid creation
and destruction during traversal.

Add a std::mutex to static data. Introduce an internal LockStatic class that
locks the mutex while providing a pointer to static data, making that the only
way to access the static data.

The LLINSTANCETRACKER_DTOR_NOEXCEPT macro goes away because we no longer
expect ~LLInstanceTracker() to throw an exception in test programs.
That affects LLTrace::StatBase as well as LLInstanceTracker itself.

Adapt consumers to the new LLInstanceTracker API.
2019-12-02 14:39:24 -05:00
Nat Goodspeed 1cdcf2c780 Automated merge with ssh://bitbucket.org/nat_linden/viewer-sl-11216 2019-11-21 17:00:09 -05:00
Nat Goodspeed f5b8019281 SL-11216: Merge up to current viewer-release 2019-11-21 16:52:10 -05:00
AndreyL ProductEngine 84f3b2865f Merged in lindenlab/viewer-release 2019-11-12 00:39:07 +02:00
Nat Goodspeed 7ed993913c Automated merge with ssh://bitbucket.org/lindenlab/viewer-release 2019-11-11 16:45:37 -05:00
Nat Goodspeed 20383ecf8e DRTVWR-476: Mention LLApp::stepFrame() in LLAppViewer::idle()
which performs "by hand" the same sequence of calls found in stepFrame().

Why not simply call stepFrame()? Hysterical reasons?
2019-10-22 16:36:16 -04:00
andreykproductengine af5c556270 Merge from viewer-release 2019-10-15 21:28:37 +03:00
Nat Goodspeed 279594dcc1 Automated merge with ssh://bitbucket.org/lindenlab/viewer-release 2019-10-15 13:56:39 -04:00
andreykproductengine 37eb735ba7 Merged in lindenlab/viewer-release 2019-09-10 20:30:25 +03:00
Nat Goodspeed 24c7d14199 Automated merge with ssh://bitbucket.org/lindenlab/viewer-release 2019-09-10 11:54:43 -04:00
andreykproductengine 27d391b2bb SL-11868 Fix cache init after purge 2019-09-04 19:20:52 +03:00
andreykproductengine 24a0601a50 DRTVWR-493 Reworked a number of inits 2019-08-13 20:19:46 +03:00
andreykproductengine 3c552696bf DRTVWR-493 LLWearableType to LLParamSingleton 2019-08-12 22:56:15 +03:00
andreykproductengine c61d0f4297 DRTVWR-493 LLUI to LLParamSingleton 2019-08-10 15:31:03 +03:00
AndreyL ProductEngine c2660070ce SL-11716 Fixed crash on initializing LLUI 2019-08-10 03:09:30 +03:00
andreykproductengine adeee613c6 DRTVWR-493 LLRender2D to LLParamSingleton 2019-07-25 18:20:17 +03:00
andreykproductengine 17fae30f72 DRTVWR-493 LLImage to LLParamSingleton 2019-07-25 15:17:11 +03:00
andreykproductengine 8df0583db0 DRTVWR-493 Cleanup LLSkinningUtil 2019-07-11 16:25:24 +03:00
andreykproductengine 47cbcb61f8 DRTVWR-493 Cleaned up unneded inits. 2019-07-04 20:24:38 +03:00
andreykproductengine 779b5627c5 DRTVWR-493 LLAvatarNameCache to singletone 2019-07-03 20:06:47 +03:00
andreykproductengine 8c54233ef9 SL-1566 Fixed watchdog killer event line missing from crash log 2019-07-01 21:24:52 +03:00
andreykproductengine 03f8125405 Backed out changeset: 920a0dbf290a Machine id is needed after singletons die 2019-06-27 18:44:29 +03:00
andreykproductengine 30cc3ff01f DRTVWR-493 LLViewerParcelMedia to singleton 2019-06-21 21:31:40 +03:00
andreykproductengine 8369276a49 DRTVWR-493 LLViewerMedia to singleton 2019-06-21 20:55:39 +03:00
andreykproductengine a2d91f3160 DRTVWR-493 LLLocalBitmapMgr to Singleton 2019-06-20 20:53:46 +03:00
andreykproductengine a74ea18116 DRTVWR-493 LLMachineId to singleton 2019-06-19 15:57:03 +03:00
andreykproductengine acf592419b DRTVWR-493 LLFollowCamMgr to singleton 2019-06-19 16:52:44 +03:00
andreykproductengine d72fcfba57 SL-11402 Resaving home image if file does not exist 2019-06-13 19:00:20 +03:00
andreykproductengine 04e67fa12d SL-11402 Last session image should be saved as png 2019-06-12 19:12:09 +03:00
andreykproductengine 19221d9ccf SL-11402 Save last session image per grid 2019-06-12 16:17:37 +03:00
Nat Goodspeed ebcfbf277e Automated merge with ssh://bitbucket.org/lindenlab/viewer-release 2019-06-05 14:15:15 -04:00
andreykproductengine 930bf680c2 SL-10423 Dump path data when missing critical file 2019-06-03 21:37:43 +03:00
Nat Goodspeed 13b0bd210f SL-11216: Try to pacify VS 2013. 2019-06-01 09:30:36 -04:00
Nat Goodspeed f706e85958 SL-11216: getViewerInfo() calls LLVersionInfo::getReleaseNotes().
Make LLAppViewer retrieve release notes from LLVersionInfo, rather than
synthesizing the release-notes URL itself based on the viewer version string.
2019-05-31 16:44:58 -04:00
Nat Goodspeed 0bb6f754a1 SL-11216: Convert LLVersionInfo to an LLSingleton.
This changeset is meant to exemplify how to convert a "namespace" class whose
methods are static -- and whose data are module-static -- to an LLSingleton.
LLVersionInfo has no initClass() or cleanupClass() methods, but the general
idea is the same.

* Derive the class from LLSingleton<T>:
  class LLSomeSingleton: public LLSingleton<LLSomeSingleton> { ... };
* Add LLSINGLETON(LLSomeSingleton); in the private section of the class. This
  usage implies a separate LLSomeSingleton::LLSomeSingleton() definition, as
  described in indra/llcommon/llsingleton.h.
* Move module-scope data in the .cpp file to non-static class members. Change
  any sVariableName to mVariableName to avoid being outright misleading.
* Make static class methods non-static. Remove '//static' comments from method
  definitions as needed.
* For LLVersionInfo specifically, the 'const std::string&' return type was
  replaced with 'std::string'. Returning a reference to a static or a member,
  const or otherwise, is an anti-pattern: the interface constrains the
  implementation, prohibiting possibly later returning a temporary (an
  expression).
* For LLVersionInfo specifically, 'const S32' return type was replaced with
  simple 'S32'. 'const' is just noise in that usage.
* Simple member initialization (e.g. the original initializer expressions for
  static variables) can be done with member{ value } initializers (no examples
  here though).
* Delete initClass() method.
* LLSingleton's forté is of course lazy initialization. It might work to
  simply delete any calls to initClass(). But if there are side effects that
  must happen at that moment, replace LLSomeSingleton::initClass() with
  (void)LLSomeSingleton::instance();
* Most initClass() initialization can be done in the constructor, as would
  normally be the case.
* Initialization that might cause a circular LLSingleton reference should be
  moved to initSingleton(). Override 'void initSingleton();' should be private.
* For LLVersionInfo specifically, certain initialization that used to be
  lazily performed was made unconditional, due to its low cost.
* For LLVersionInfo specifically, certain initialization involved calling
  methods that have become non-static. This was moved to initSingleton()
  because, in a constructor body, 'this' does not yet point to the enclosing
  class.
* Delete cleanupClass() method.
* There is already a generic LLSingletonBase::deleteAll() call in
  LLAppViewer::cleanup(). It might work to let this new LLSingleton be cleaned
  up with all the rest. But if there are side effects that must happen at that
  moment, replace LLSomeSingleton::cleanupClass() with
  LLSomeSingleton::deleteSingleton(). That said, much of the benefit of
  converting to LLSingleton is deleteAll()'s guarantee that cross-LLSingleton
  dependencies will be properly honored: we're trying to migrate the code base
  away from the present fragile manual cleanup sequence.
* Most cleanupClass() cleanup can be done in the destructor, as would normally
  be the case.
* Cleanup that might throw an exception should be moved to cleanupSingleton().
  Override 'void cleanupSingleton();' should be private.
* Within LLSomeSingleton methods, remove any existing
  LLSomeSingleton::methodName() qualification: simple methodName() is better.
* In the rest of the code base, convert most LLSomeSingleton::methodName()
  references to LLSomeSingleton::instance().methodName(). (Prefer instance() to
  getInstance() because a reference does not admit the possibility of NULL.)
* Of course, LLSomeSingleton::ENUM_VALUE can remain unchanged.

In general, for many successive references to an LLSingleton instance, it
can be useful to capture the instance() as in:

auto& versionInfo{LLVersionInfo::instance()};
// ... versionInfo.getVersion() ...

We did not do that here only to simplify the code review.

The STRINGIZE(expression) macro encapsulates:
std::ostringstream out;
out << expression;
return out.str();
We used that in a couple places.

For LLVersionInfo specifically, lllogininstance_test.cpp used to dummy out a
couple specific static methods. It's harder to dummy out
LLSingleton::instance() references, so we add the real class to that test.
2019-05-30 10:39:37 -04:00
Nat Goodspeed ca1d051a15 SL-11216: Remove LLSingletonBase::cleanupAll().
Remove call from LLAppViewer::cleanup().

Instead, make each LLSingleton<T>::deleteSingleton() call cleanupSingleton()
just before destroying the instance. Since deleteSingleton() is not a
destructor, it's fine to call cleanupSingleton() from there; and since
deleteAll() calls deleteSingleton() on every remaining instance, the former
cleanupAll() functionality has been subsumed into deleteAll().

Since cleanupSingleton() is now called at exactly one point in the instance's
lifetime, we no longer need a bool indicating whether it has been called.

The previous protocol of calling cleanupAll() before deleteAll() implemented a
two-phase cleanup strategy for the application. That is no longer needed.
Moreover, the cleanupAll() / deleteAll() sequence created a time window during
which individual LLSingleton<T> instances weren't usable (to the extent that
their cleanupSingleton() methods released essential resources) but still
existed -- so a getInstance() call would return the crippled instance rather
than recreating it.

Remove cleanupAll() calls from tests; adjust to new order of expected side
effects: instead of A::cleanupSingleton(), B::cleanupSingleton(), ~A(), ~B(),
now we get A::cleanupSingleton(), ~A(), B::cleanupSingleton(), ~B().
2019-05-30 08:23:32 -04:00
AndreyL ProductEngine f5e63b0627 Merged in lindenlab/viewer-bear 2019-05-21 18:27:35 +03:00
Steven Harrison (steven) 59c93cb861 SL-11213 No longer embedding the channel in the viewer release note urls. Update base URLs to match new viewer release note URL 2019-05-17 02:23:49 +00:00
AndreyL ProductEngine 5e5c5ca09c Merged SL-10400 and SL-10401 2019-04-26 21:02:00 +03:00
Brad Payne (Vir Linden) d1f5e87ad0 via viewer-neko - don't crash test viewer due to missing version checker 2019-04-23 15:31:25 +01:00
AndreyL ProductEngine 1470e82c89 Merged in lindenlab/viewer-release 2019-04-02 21:51:54 +03:00
Brad Payne (Vir Linden) 4e73121719 Don't create updater when running under debugger. 2019-03-04 20:24:00 +00:00
AndreyL ProductEngine 5715cda6e0 Merged in lindenlab/viewer-release 2019-03-01 10:55:47 +02:00
AndreyL ProductEngine 36cb6933e6 Merged in lindenlab/viewer-release 2019-03-01 02:24:00 +02:00
andreykproductengine 26fae750ba SL-10291 Replace apr_mutex with standard C++11 functionality 2019-01-14 22:04:44 +02:00
Nat Goodspeed d2c581c344 Automated merge with ssh://bitbucket.org/lindenlab/viewer-release 2018-12-28 14:46:49 -05:00
andreykproductengine c94e981f40 SL-10080 clamp instead of llmax 2018-12-03 17:30:35 +02:00
andreykproductengine e2442851c6 SL-10080 Limit LOD factor to 4 2018-11-27 20:07:41 +02:00