Simplify mutex handling here, use more RAII

That required improving UnusedVariableCheck to honor [[maybe_unused]].

Change-Id: I01f3fd92d78726582f873681c807315b029c4e89
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200032
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Tested-by: Jenkins
This commit is contained in:
Mike Kaganski
2026-02-23 14:38:56 +01:00
parent 973dd80774
commit 800e7fd2ff
3 changed files with 5 additions and 7 deletions
@@ -33,6 +33,7 @@ int main()
v4; // expected-error {{unused variable 'v4' [loplugin:unusedvariablecheck]}}
S v5; // expected-error {{unused variable 'v5' [loplugin:unusedvariablecheck]}}
S v6(nullptr);
[[maybe_unused]] S v7;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
@@ -50,7 +50,7 @@ bool UnusedVariableCheck::VisitVarDecl( const VarDecl* var )
{
if( ignoreLocation( var ))
return true;
if( var->isReferenced() || var->isUsed())
if( var->isReferenced() || var->isUsed() || var->hasAttr<UnusedAttr>())
return true;
if( var->isDefinedOutsideFunctionOrMethod())
return true;
+3 -6
View File
@@ -462,17 +462,14 @@ void SfxDocTplService::init_Impl()
if ( bNeedsUpdate )
{
aGuard.clear();
SolarMutexClearableGuard aSolarGuard;
SolarMutexGuard aSolarGuard;
VclPtrInstance< WaitWindow_Impl > pWin;
aSolarGuard.clear();
[[maybe_unused]] ScopedVclPtrInstance<WaitWindow_Impl> pWin;
{
SolarMutexReleaser aSolarReleaser;
osl::MutexGuard anotherGuard(maMutex);
doUpdate();
}
SolarMutexGuard aSecondSolarGuard;
pWin.disposeAndClear();
}
else if ( needsUpdate() )
// the UI should be shown only on the first update