From 727d519046f3fd15d491a9daad9ba3327e1ad31a Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Sat, 24 Sep 2022 19:42:07 +0200 Subject: [PATCH] cleanup: use singleton pattern for getPrintingTemplatePath*() Function-local statics are initialized on first invocation. No point in extra logic. Signed-off-by: Berthold Stoeger --- core/qthelper.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/core/qthelper.cpp b/core/qthelper.cpp index 369d12bc3..24426d36c 100644 --- a/core/qthelper.cpp +++ b/core/qthelper.cpp @@ -719,17 +719,17 @@ static const char *printing_templates = "printing_templates"; QString getPrintingTemplatePathUser() { - static QString path = QString(); - if (path.isEmpty()) - path = QString(system_default_directory()) + QDir::separator() + QString(printing_templates); + // Function-local statics are initialized on first invocation + static QString path(QString(system_default_directory()) + + QDir::separator() + + QString(printing_templates)); return path; } QString getPrintingTemplatePathBundle() { - static QString path = QString(); - if (path.isEmpty()) - path = getSubsurfaceDataPath(printing_templates); + // Function-local statics are initialized on first invocation + static QString path(getSubsurfaceDataPath(printing_templates)); return path; }