mirror of
https://github.com/hasherezade/bearparser
synced 2026-06-08 14:32:38 +00:00
406829819b
See https://github.com/hasherezade/bearparser/pull/28 for more details
41 lines
912 B
C++
41 lines
912 B
C++
#pragma once
|
|
|
|
#include <iostream>
|
|
#include <QtCore>
|
|
|
|
|
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
|
class WatchedLocker : public QMutexLocker<QMutex> {
|
|
#else
|
|
class WatchedLocker : public QMutexLocker {
|
|
#endif
|
|
public:
|
|
WatchedLocker(QMutex *mutex, bool show = false, const char *func = nullptr)
|
|
: QMutexLocker(mutex), showLock(show)
|
|
{
|
|
if (func) funcName = func;
|
|
if (showLock) {
|
|
std::cout << __FUNCTION__;
|
|
if (funcName.length()) {
|
|
std::cout << " : " << funcName;
|
|
}
|
|
std::cout << std::endl;
|
|
}
|
|
}
|
|
|
|
~WatchedLocker()
|
|
{
|
|
if (showLock) {
|
|
std::cout << __FUNCTION__;
|
|
if (funcName.length()) {
|
|
std::cout << " : " << funcName;
|
|
}
|
|
std::cout << std::endl;
|
|
}
|
|
}
|
|
|
|
protected:
|
|
std::string funcName;
|
|
bool showLock;
|
|
};
|