Skip to content

Commit

Permalink
Merge branch '3.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
winterz committed Oct 9, 2024
2 parents a69ba18 + 22a3db4 commit a6105a2
Show file tree
Hide file tree
Showing 21 changed files with 124 additions and 80 deletions.
1 change: 1 addition & 0 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,5 @@ SpaceInEmptyParentheses: false
SpacesInAngles: false
SpacesInCStyleCastParentheses: true
SpacesInParentheses: false
StatementAttributeLikeMacros: [emit]
...
11 changes: 5 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
ci:
skip: [clang-format]
autoupdate_schedule: monthly

exclude: ^(3rdparty/|cmake/ECM/|cmake/KDAB/|launcher/ui/processlist.*|compat/qasconst.h|docs/api/doxygen-awesome.css|launcher/cli/completions/gammaray.zsh|ui/resources/gammaray/update_icon_sets.sh)
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
Expand All @@ -22,11 +21,11 @@ repos:
- id: destroyed-symlinks
- id: check-executables-have-shebangs
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v17.0.6
rev: v19.1.1
hooks:
- id: clang-format
- repo: https://github.com/PyCQA/pylint
rev: v3.2.4
rev: v3.3.1
hooks:
- id: pylint
exclude: ^(.cmake-format.py|conan/.*/conanfile.py)
Expand Down Expand Up @@ -54,12 +53,12 @@ repos:
language: ruby
files: \.(md|mdown|markdown)$
- repo: https://github.com/fsfe/reuse-tool
rev: v3.1.0a1
rev: v4.0.3
hooks:
- id: reuse
args: [--suppress-deprecation]
- repo: https://github.com/scop/pre-commit-shfmt
rev: v3.8.0-1
rev: v3.9.0-1
hooks:
- id: shfmt
- repo: https://github.com/shellcheck-py/shellcheck-py
Expand Down
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -547,9 +547,9 @@ set(HAVE_QT_SVG ${QtSvg_FOUND})
set(HAVE_QT_SCXML ${QtScxml_FOUND})
set(HAVE_QT_DESIGNER ${QtDesigner_FOUND})

if(TARGET Qt::Gui)
if(TARGET Qt${QtGui_VERSION_MAJOR}::Gui)
cmake_push_check_state()
set(CMAKE_REQUIRED_LIBRARIES Qt::Gui)
set(CMAKE_REQUIRED_LIBRARIES Qt${QtGui_VERSION_MAJOR}::Gui)
check_cxx_symbol_exists(QT_NO_OPENGL "QOpenGLContext" QT_NO_OPENGL)
cmake_pop_check_state()
endif()
Expand Down
2 changes: 1 addition & 1 deletion client/remotemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ QVariant RemoteModel::requestCreationDeclarationLocation(const QModelIndex &inde

QEventLoop loop;

auto conn = connect(this, &RemoteModel::declarationCreationLocationsReceived, this, [&creationLoc, &declarationLoc, &loop](const QVariant &d, const QVariant &c) {
auto conn = connect(this, &RemoteModel::declarationCreationLocationsReceived, this, [&creationLoc, &declarationLoc, &loop](const QVariant &d, const QVariant &c) { // clazy:exclude=lambda-in-connect
if (d.isValid())
declarationLoc = d;
if (c.isValid())
Expand Down
2 changes: 2 additions & 0 deletions core/probe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,8 @@ QRecursiveMutex *Probe::objectLock()
*/
void Probe::objectAdded(QObject *obj, bool fromCtor)
{
if (obj == nullptr)
return;
QMutexLocker lock(s_lock());

// attempt to ignore objects created by GammaRay itself, especially short-lived ones
Expand Down
8 changes: 4 additions & 4 deletions core/tools/messagehandler/messagehandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ static MessageHandlerCallback (*const installMessageHandler)(MessageHandlerCallb
static MessageModel *s_model = nullptr;
static MessageHandlerCallback s_handler = nullptr;
static bool s_handlerDisabled = false;
static QRecursiveMutex s_mutex;
Q_GLOBAL_STATIC(QRecursiveMutex, s_mutex)

static void handleMessage(QtMsgType type, const QMessageLogContext &context, const QString &msg)
{
Expand Down Expand Up @@ -86,7 +86,7 @@ static void handleMessage(QtMsgType type, const QMessageLogContext &context, con
// reset msg handler so the app still works as usual
// but make sure we don't let other threads bypass our
// handler during that time
QMutexLocker lock(&s_mutex);
QMutexLocker lock(s_mutex());
s_handlerDisabled = true;
if (s_handler) { // try a direct call to the previous handler first, that avoids triggering the recursion detection in Qt5
s_handler(type, context, msg);
Expand Down Expand Up @@ -139,7 +139,7 @@ MessageHandler::MessageHandler(Probe *probe, QObject *parent)

MessageHandler::~MessageHandler()
{
QMutexLocker lock(&s_mutex);
QMutexLocker lock(s_mutex());

s_model = nullptr;
MessageHandlerCallback oldHandler = installMessageHandler(s_handler);
Expand All @@ -157,7 +157,7 @@ void MessageHandler::generateFullTrace()

void MessageHandler::ensureHandlerInstalled()
{
QMutexLocker lock(&s_mutex);
QMutexLocker lock(s_mutex());

if (s_handlerDisabled)
return;
Expand Down
2 changes: 1 addition & 1 deletion core/tools/objectinspector/connectionsextension.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ using namespace GammaRay;

ConnectionsExtension::ConnectionsExtension(PropertyController *controller)
: ConnectionsExtensionInterface(
controller->objectBaseName() + ".connectionsExtension", controller)
controller->objectBaseName() + ".connectionsExtension", controller)
, PropertyControllerExtension(controller->objectBaseName() + ".connections")
{
m_inboundModel = new InboundConnectionsModel(controller);
Expand Down
3 changes: 2 additions & 1 deletion core/tools/objectinspector/methodsextension.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ void MethodsExtension::invokeMethod(Qt::ConnectionType connectionType)
return;
}

const QVector<MethodArgument> args = m_methodArgumentModel->arguments();
const QVector<MethodArgument> methodArgs = m_methodArgumentModel->arguments();
QVector<QGenericArgument> args(methodArgs.begin(), methodArgs.end());
// TODO retrieve return value and add it to the log in case of success
// TODO measure execution time and that to the log
const bool result = method.invoke(
Expand Down
2 changes: 1 addition & 1 deletion launcher/core/injector/basicwindllinjector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
do { \
} while (false)
#define ERROR_CHECK(condition) ERROR_ASSERT( \
condition, do {} while (false));
condition, do { } while (false));

BOOL BasicWinDllInjector::addDllDirectory(HANDLE destProcess, wchar_t *dllDirPath)
{
Expand Down
6 changes: 3 additions & 3 deletions launcher/ui/processlist_unix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

#include <algorithm>

static GammaRay::ProbeABIDetector s_abiDetector;
Q_GLOBAL_STATIC(GammaRay::ProbeABIDetector, s_abiDetector)

static bool isUnixProcessId(const QString &procname)
{
Expand Down Expand Up @@ -108,7 +108,7 @@ static ProcDataList unixProcessListPS(const ProcDataList &previous)
if (it != previous.constEnd())
procData.abi = it->abi;
else
procData.abi = s_abiDetector.abiForProcess(procData.ppid.toLongLong());
procData.abi = s_abiDetector->abiForProcess(procData.ppid.toLongLong());
rc.push_back(procData);
}
}
Expand Down Expand Up @@ -164,7 +164,7 @@ struct ProcIdToProcData
if (it != previous.constEnd())
proc.abi = it->abi;
else
proc.abi = s_abiDetector.abiForProcess(proc.ppid.toLongLong());
proc.abi = s_abiDetector->abiForProcess(proc.ppid.toLongLong());

return proc;
}
Expand Down
7 changes: 3 additions & 4 deletions plugins/localeinspector/localedataaccessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ void LocaleDataAccessorRegistry::init()

LOCALE_SIMPLE_ACCESSOR(TextDirection,
return locale.textDirection() == Qt::LeftToRight ? QStringLiteral(
"LTR")
"LTR")
: QStringLiteral("RTL");)

LOCALE_SIMPLE_DEFAULT_ACCESSOR(TimeFormatLong,
Expand Down Expand Up @@ -167,8 +167,7 @@ void LocaleDataAccessorRegistry::init()
const auto wds = locale.weekdays();
QStringList resultList;
resultList.reserve(wds.size());
for (Qt::DayOfWeek dayNumber
: wds) {
for (Qt::DayOfWeek dayNumber : wds) {
resultList << QLocale().dayName(dayNumber);
} return QLocale()
.createSeparatedList(resultList);)
Expand Down Expand Up @@ -213,7 +212,7 @@ void LocaleDataAccessorRegistry::init()
return locale.measurementSystem()
== QLocale::ImperialSystem
? QStringLiteral(
"Imperial")
"Imperial")
: QStringLiteral("Metric");)

LOCALE_SIMPLE_DEFAULT_ACCESSOR(FloatFormat,
Expand Down
4 changes: 2 additions & 2 deletions plugins/localeinspector/localedataaccessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ struct LocaleDataAccessor
{ \
explicit Locale##NAME##Accessor(LocaleDataAccessorRegistry *registry) \
: LocaleDataAccessor( \
registry) \
registry) \
{ \
} \
QString accessorName() override \
Expand All @@ -95,7 +95,7 @@ struct LocaleDataAccessor
{ \
explicit Locale##NAME##Accessor(LocaleDataAccessorRegistry *registry) \
: LocaleDataAccessor( \
registry, true) \
registry, true) \
{ \
} \
\
Expand Down
16 changes: 8 additions & 8 deletions plugins/network/networkreplywidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,14 @@ NetworkReplyWidget::NetworkReplyWidget(QWidget *parent)
}
#else

QTextCodec::ConverterState state;
QTextCodec *codec = QTextCodec::codecForName("UTF-8");
const QString text = codec->toUnicode(response.constData(), response.size(), &state);
if (state.invalidChars > 0) {
ui->responseTextEdit->setPlainText(tr("%1: Unable to show response preview").arg(qApp->applicationName()));
} else {
ui->responseTextEdit->setPlainText(text);
}
QTextCodec::ConverterState state;
QTextCodec *codec = QTextCodec::codecForName("UTF-8");
const QString text = codec->toUnicode(response.constData(), response.size(), &state);
if (state.invalidChars > 0) {
ui->responseTextEdit->setPlainText(tr("%1: Unable to show response preview").arg(qApp->applicationName()));
} else {
ui->responseTextEdit->setPlainText(text);
}
#endif
});
ui->responseTextEdit->setFont(QFontDatabase::systemFont(QFontDatabase::FixedFont));
Expand Down
6 changes: 3 additions & 3 deletions plugins/positioning/geopositioninfosourcefactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ QGeoPositionInfoSource *GeoPositionInfoSourceFactory::positionInfoSource(QObject
const auto rData = metaData.at(rhs).toCbor();
return lData.value(QStringLiteral("Priority")).toInteger() > rData.value(QStringLiteral("Priority")).toInteger();
#else
const auto lData = metaData.at(lhs).value(QStringLiteral("MetaData")).toObject();
const auto rData = metaData.at(rhs).value(QStringLiteral("MetaData")).toObject();
return lData.value(QStringLiteral("Priority")).toInt() > rData.value(QStringLiteral("Priority")).toInt();
const auto lData = metaData.at(lhs).value(QStringLiteral("MetaData")).toObject();
const auto rData = metaData.at(rhs).value(QStringLiteral("MetaData")).toObject();
return lData.value(QStringLiteral("Priority")).toInt() > rData.value(QStringLiteral("Priority")).toInt();
#endif
});

Expand Down
7 changes: 2 additions & 5 deletions plugins/quickinspector/quickinspector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -718,14 +718,11 @@ void QuickInspector::setSlowMode(bool slow)
auto it = connections.find(window);

if (it == connections.end()) {
connections.insert(window, connect(
window, &QQuickWindow::beforeRendering, this, [this, window]() {
connections.insert(window, connect(window, &QQuickWindow::beforeRendering, this, [this, window]() {
auto it = connections.find(window);
QUnifiedTimer::instance()->setSlowModeEnabled(m_slowDownEnabled);
QObject::disconnect(it.value());
connections.erase(it);
},
Qt::DirectConnection));
connections.erase(it); }, Qt::DirectConnection));
}
}

Expand Down
10 changes: 5 additions & 5 deletions plugins/quickinspector/quickscreengrabber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,13 @@ class QQuickItemPropertyCache
}
};

// We need random colors, but we also want the item
// to keep its random color during scene changes to avoid
// flickering due to color change.
static QHash<QQuickItem *, QColor> s_itemsColor;

static QColor colorForItem(QQuickItem *item)
{
// We need random colors, but we also want the item
// to keep its random color during scene changes to avoid
// flickering due to color change.
static QHash<QQuickItem *, QColor> s_itemsColor;

QColor color = s_itemsColor.value(item, QColor());

if (!color.isValid()) {
Expand Down
47 changes: 27 additions & 20 deletions plugins/sysinfo/sysinfomodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,35 +15,42 @@

#include <QLibraryInfo>
#include <QSysInfo>
#include <array>

using namespace GammaRay;

struct sysinfo_t
{
QString (*func)();
const char *name;
const QString name;
};

#define S(x) \
{ \
QSysInfo::x, #x \
#define S(x) \
sysinfo_t \
{ \
\
QSysInfo::x, QString::fromLatin1(#x) \
}
static const sysinfo_t sysInfoTable[] = {

static const std::array<sysinfo_t, 10> &sysInfoTable()
{
static const std::array<sysinfo_t, 10> t = {
#if !defined(Q_CC_MSVC) || _MSC_VER > 1600 // krazy:exclude=cpp to deal with older MS compilers
{ []() { return QString::fromLatin1(QLibraryInfo::build()); }, "build" },
sysinfo_t { []() { return QString::fromLatin1(QLibraryInfo::build()); }, "build" },
#endif
S(buildAbi),
S(buildCpuArchitecture),
S(currentCpuArchitecture),
S(kernelType),
S(kernelVersion),
S(machineHostName),
S(prettyProductName),
S(productType),
S(productVersion)
};
S(buildAbi),
S(buildCpuArchitecture),
S(currentCpuArchitecture),
S(kernelType),
S(kernelVersion),
S(machineHostName),
S(prettyProductName),
S(productType),
S(productVersion)
};
return t;
}
#undef S
static const auto sysInfoTableSize = sizeof(sysInfoTable) / sizeof(sysinfo_t);

SysInfoModel::SysInfoModel(QObject *parent)
: QAbstractTableModel(parent)
Expand All @@ -60,7 +67,7 @@ int SysInfoModel::rowCount(const QModelIndex &parent) const
{
if (parent.isValid())
return 0;
return sysInfoTableSize;
return ( int )sysInfoTable().size();
}

QVariant SysInfoModel::data(const QModelIndex &index, int role) const
Expand All @@ -71,9 +78,9 @@ QVariant SysInfoModel::data(const QModelIndex &index, int role) const
if (role == Qt::DisplayRole) {
switch (index.column()) {
case 0:
return sysInfoTable[index.row()].name;
return sysInfoTable()[index.row()].name;
case 1:
return sysInfoTable[index.row()].func();
return sysInfoTable()[index.row()].func();
}
}

Expand Down
Loading

0 comments on commit a6105a2

Please sign in to comment.