template static field appearing in two different CUs
I saw some warnings and got suspicious, so I converted the OSL_ENSURE to assert, and then found that we have two copies of the s_nRefCount static field, which obviously causes trouble. I tried to fix this by removing usage of this dubious template class, but the templates classes are intertwined, and that lead to a very large patch with weird failures. So this is a hacky minimal fix, using explicit template instantiation to force the code to only be emitted in a single library. Change-Id: I634afb8b40570f2e7e0f8da541b8a2b6325fdc29 Reviewed-on: https://gerrit.collaboraoffice.com/c/core/+/904 Reviewed-by: Noel Grandin <noel.grandin@collabora.com> Tested-by: Jenkins CPCI <releng@collaboraoffice.com> (cherry picked from commit af69817a343ccf1411f6f8980c94ed1f696769b4) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/207023 Reviewed-by: Julien Nabet <serval2412@yahoo.fr> Tested-by: Jenkins
This commit is contained in:
committed by
Julien Nabet
parent
af0be53ef9
commit
eb3cee606e
@@ -100,7 +100,7 @@ template <class TYPE>
|
||||
OPropertyArrayUsageHelper<TYPE>::~OPropertyArrayUsageHelper()
|
||||
{
|
||||
std::unique_lock aGuard(theMutex());
|
||||
OSL_ENSURE(s_nRefCount > 0, "OPropertyArrayUsageHelper::~OPropertyArrayUsageHelper : suspicious call : have a refcount of 0 !");
|
||||
assert(s_nRefCount > 0 && "OPropertyArrayUsageHelper::~OPropertyArrayUsageHelper : suspicious call : have a refcount of 0 !");
|
||||
if (!--s_nRefCount)
|
||||
{
|
||||
delete s_pProps;
|
||||
@@ -111,12 +111,12 @@ OPropertyArrayUsageHelper<TYPE>::~OPropertyArrayUsageHelper()
|
||||
template <class TYPE>
|
||||
::cppu::IPropertyArrayHelper* OPropertyArrayUsageHelper<TYPE>::getArrayHelper()
|
||||
{
|
||||
OSL_ENSURE(s_nRefCount, "OPropertyArrayUsageHelper::getArrayHelper : suspicious call : have a refcount of 0 !");
|
||||
std::unique_lock aGuard(theMutex());
|
||||
assert(s_nRefCount && "OPropertyArrayUsageHelper::getArrayHelper : suspicious call : have a refcount of 0 !");
|
||||
if (!s_pProps)
|
||||
{
|
||||
s_pProps = createArrayHelper();
|
||||
OSL_ENSURE(s_pProps, "OPropertyArrayUsageHelper::getArrayHelper : createArrayHelper returned nonsense !");
|
||||
assert(s_pProps && "OPropertyArrayUsageHelper::getArrayHelper : createArrayHelper returned nonsense !");
|
||||
}
|
||||
return s_pProps;
|
||||
}
|
||||
|
||||
@@ -45,6 +45,14 @@ namespace weld { class Toolbar; }
|
||||
|
||||
class ToolBox;
|
||||
|
||||
namespace svt
|
||||
{
|
||||
class ToolboxController;
|
||||
}
|
||||
|
||||
// extern template otherwise the ref-counting magic here ends up duplicated across multiple libraries
|
||||
extern template class SAL_DLLPUBLIC_TEMPLATE comphelper::OPropertyArrayUsageHelper<svt::ToolboxController>;
|
||||
|
||||
namespace svt
|
||||
{
|
||||
|
||||
|
||||
@@ -48,6 +48,8 @@ using namespace css::beans;
|
||||
using namespace css::lang;
|
||||
using namespace css::frame;
|
||||
|
||||
template class comphelper::OPropertyArrayUsageHelper<svt::ToolboxController>;
|
||||
|
||||
namespace svt
|
||||
{
|
||||
|
||||
|
||||
Reference in New Issue
Block a user