mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 03:15:11 +00:00
Bug 1733465 part 4: Convert nsViewManager::gViewManagers to StaticAutoPtr so that we don't have to manually delete it. r=tnikkel
This removes an explicit 'delete', by letting the StaticAutoPtr type handle the deletion for us automatically and atomically when we clear its value. Benefits/justification: * This reduces the potential for double-free bugs. * This matches existing patterns elsewhere in our code (search for e.g. "StaticAutoPtr<nsTArray") * This reduces (by 1) the number of explicit `delete` calls that we need to consider, when auditing the codebase for potential memory safety issues. Differential Revision: https://phabricator.services.mozilla.com/D127185
This commit is contained in:
parent
70f76180d5
commit
1d08981c37
@ -50,7 +50,7 @@ using namespace mozilla::layers;
|
||||
#undef DEBUG_MOUSE_LOCATION
|
||||
|
||||
// Weakly held references to all of the view managers
|
||||
nsTArray<nsViewManager*>* nsViewManager::gViewManagers = nullptr;
|
||||
StaticAutoPtr<nsTArray<nsViewManager*>> nsViewManager::gViewManagers;
|
||||
uint32_t nsViewManager::gLastUserEventTime = 0;
|
||||
|
||||
nsViewManager::nsViewManager()
|
||||
@ -91,7 +91,6 @@ nsViewManager::~nsViewManager() {
|
||||
if (gViewManagers->IsEmpty()) {
|
||||
// There aren't any more view managers so
|
||||
// release the global array of view managers
|
||||
delete gViewManagers;
|
||||
gViewManagers = nullptr;
|
||||
}
|
||||
|
||||
|
@ -424,7 +424,7 @@ class nsViewManager final {
|
||||
// from here to public should be static and locked... MMP
|
||||
|
||||
// list of view managers
|
||||
static nsTArray<nsViewManager*>* gViewManagers;
|
||||
static mozilla::StaticAutoPtr<nsTArray<nsViewManager*>> gViewManagers;
|
||||
};
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user