mirror of
https://github.com/opencv/opencv.git
synced 2025-01-13 00:01:27 +08:00
Fixed bug #3489: The code assumed that two global variables would be constructed in a particular order, but global variable initialization order is compiler-dependent.
(cherry picked from commit 6bf599b1bc
)
This commit is contained in:
parent
cdea6b532f
commit
6cb7a7be18
@ -1129,17 +1129,24 @@ public:
|
||||
}
|
||||
}
|
||||
};
|
||||
static TLSContainerStorage tlsContainerStorage;
|
||||
|
||||
// This is a wrapper function that will ensure 'tlsContainerStorage' is constructed on first use.
|
||||
// For more information: http://www.parashift.com/c++-faq/static-init-order-on-first-use.html
|
||||
static TLSContainerStorage& getTLSContainerStorage()
|
||||
{
|
||||
static TLSContainerStorage *tlsContainerStorage = new TLSContainerStorage();
|
||||
return *tlsContainerStorage;
|
||||
}
|
||||
|
||||
TLSDataContainer::TLSDataContainer()
|
||||
: key_(-1)
|
||||
{
|
||||
key_ = tlsContainerStorage.allocateKey(this);
|
||||
key_ = getTLSContainerStorage().allocateKey(this);
|
||||
}
|
||||
|
||||
TLSDataContainer::~TLSDataContainer()
|
||||
{
|
||||
tlsContainerStorage.releaseKey(key_, this);
|
||||
getTLSContainerStorage().releaseKey(key_, this);
|
||||
key_ = -1;
|
||||
}
|
||||
|
||||
@ -1164,7 +1171,7 @@ TLSStorage::~TLSStorage()
|
||||
void*& data = tlsData_[i];
|
||||
if (data)
|
||||
{
|
||||
tlsContainerStorage.destroyData(i, data);
|
||||
getTLSContainerStorage().destroyData(i, data);
|
||||
data = NULL;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user