Files
qt-creator/src/libs/utils/guard.h
Christian Kandeler bd2ca236e1 CPlusPlus: Check maximum include depth in lexer
We use a value of 200, which is also GCC's default.

Fixes: QTCREATORBUG-28770
Change-Id: Id02b324cd2ffa81a709441a5d93856bcd06501c3
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2023-02-08 12:53:31 +00:00

43 lines
887 B
C++

// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once
#include "utils_global.h"
#include <QtGlobal>
namespace Utils {
class QTCREATOR_UTILS_EXPORT Guard
{
Q_DISABLE_COPY(Guard)
public:
Guard();
~Guard();
bool isLocked() const;
int lockCount() const { return m_lockCount; }
// Prefer using GuardLocker when possible. These two methods are provided only for cases
// when locking and unlocking are done in separate methods, so that GuardLocker can't be
// used.
void lock();
void unlock();
private:
int m_lockCount = 0;
friend class GuardLocker;
};
class QTCREATOR_UTILS_EXPORT GuardLocker
{
Q_DISABLE_COPY(GuardLocker)
public:
GuardLocker(Guard &guard);
~GuardLocker();
private:
Guard &m_guard;
};
} // namespace Utils