Skip to content

Commit

Permalink
chore: Bump to clang-format-18
Browse files Browse the repository at this point in the history
There's some styling differences.
  • Loading branch information
iamsergio committed Jul 19, 2024
1 parent b5bfc55 commit 27f6352
Show file tree
Hide file tree
Showing 24 changed files with 299 additions and 275 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ repos:
- id: destroyed-symlinks
- id: check-executables-have-shebangs
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v17.0.6
rev: v18.1.8
hooks:
- id: clang-format
exclude: (.json)
Expand Down
2 changes: 1 addition & 1 deletion src/core/Position.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ LayoutSaver::Position Positions::serialize() const
p.indexOfFloatingWindow = fw->beingDeleted()
? -1
: DockRegistry::self()->floatingWindows().indexOf(
fw);
fw);
} else {
p.mainWindowUniqueName = mainWindow->uniqueName();
assert(!p.mainWindowUniqueName.isEmpty());
Expand Down
2 changes: 1 addition & 1 deletion src/core/Separator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ Separator::Separator(LayoutingHost *host, Qt::Orientation orientation, Core::Ite
view()->show();
view()->init();
d->lazyResizeRubberBand = d->usesLazyResize ? Config::self().viewFactory()->createRubberBand(
rubberBandIsTopLevel() ? nullptr : view())
rubberBandIsTopLevel() ? nullptr : view())
: nullptr;
setVisible(true);
}
Expand Down
8 changes: 4 additions & 4 deletions src/core/TitleBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ using namespace KDDockWidgets::Core;

TitleBar::TitleBar(Group *parent)
: Controller(
ViewType::TitleBar,
Config::self().viewFactory()->createTitleBar(this, parent ? parent->view() : nullptr))
ViewType::TitleBar,
Config::self().viewFactory()->createTitleBar(this, parent ? parent->view() : nullptr))
, Draggable(view())
, d(new Private())
, m_group(parent)
Expand All @@ -67,8 +67,8 @@ TitleBar::TitleBar(Group *parent)

TitleBar::TitleBar(FloatingWindow *parent)
: Controller(
ViewType::TitleBar,
Config::self().viewFactory()->createTitleBar(this, parent ? parent->view() : nullptr))
ViewType::TitleBar,
Config::self().viewFactory()->createTitleBar(this, parent ? parent->view() : nullptr))
, Draggable(view())
, d(new Private())
, m_group(nullptr)
Expand Down
35 changes: 35 additions & 0 deletions tests/clang_format18_workaround.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2024 Klarälvdalens Datakonsult AB, a KDAB Group company <[email protected]>
Author: Sérgio Martins <[email protected]>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
Contact KDAB at <[email protected]> for commercial licensing options.
*/

#pragma once

#include "core/Platform.h"

/// These macros are workaround for clang-format-18 bug:
/// - KDDW_CO_AWAIT Platform::instance()->tests_wait(1);
/// + KDDW_CO_AWAIT Platform::instance() -> tests_wait(1);
/// This is avoided when wrapped in a macro.

#define EVENT_LOOP(millis) \
KDDW_CO_AWAIT \
KDDockWidgets::Core::Platform::instance()->tests_wait(millis)

#define WAIT_FOR_RESIZE(window) \
KDDW_CO_AWAIT \
KDDockWidgets::Core::Platform::instance()->tests_waitForResize(window)

#define WAIT_FOR_DELETED(window) \
KDDW_CO_AWAIT \
KDDockWidgets::Core::Platform::instance()->tests_waitForDeleted(window)

#define WAIT_FOR_EVENT(window, event) \
KDDW_CO_AWAIT \
KDDockWidgets::Core::Platform::instance()->tests_waitForEvent(window, event)
6 changes: 3 additions & 3 deletions tests/core/tst_dockwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ KDDW_QCORO_TASK tst_setGuestView()
CHECK(dw->guestView());
CHECK(dw->view());
dw->view()->show();
KDDW_CO_AWAIT Platform::instance()->tests_wait(500);
EVENT_LOOP(500);

CHECK(guest->controller());
CHECK(dw->floatingWindow());
Expand Down Expand Up @@ -187,7 +187,7 @@ KDDW_QCORO_TASK tst_dwCloseAndReopen()
}

// 1 event loop for DelayedDelete. Avoids LSAN warnings.
KDDW_CO_AWAIT Platform::instance()->tests_wait(1);
EVENT_LOOP(1);

KDDW_TEST_RETURN(true);
}
Expand All @@ -203,7 +203,7 @@ KDDW_QCORO_TASK tst_setSize()
}

// 1 event loop for DelayedDelete. Avoids LSAN warnings.
KDDW_CO_AWAIT Platform::instance()->tests_wait(1);
EVENT_LOOP(1);

KDDW_TEST_RETURN(true);
}
Expand Down
3 changes: 2 additions & 1 deletion tests/core/tst_droparea.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "core/ViewFactory.h"
#include "core/Platform.h"
#include "tests/utils.h"
#include "../clang_format18_workaround.h"

using namespace KDDockWidgets;

Expand Down Expand Up @@ -54,7 +55,7 @@ KDDW_QCORO_TASK tst_addWidgetHidden()

auto group = dw->dptr()->group();
delete dw;
KDDW_CO_AWAIT Core::Platform::instance()->tests_waitForDeleted(group);
WAIT_FOR_DELETED(group);

KDDW_TEST_RETURN(true);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/core/tst_floatingwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ KDDW_QCORO_TASK tst_floatingWindowCtor()
CHECK(dw->floatingWindow());

/// Wait for FloatingWindow to be created
KDDW_CO_AWAIT Platform::instance()->tests_wait(100);
EVENT_LOOP(100);

auto rootView = dw->view()->rootView();
CHECK(rootView);
Expand Down
4 changes: 3 additions & 1 deletion tests/core/tst_tabbar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include "kddockwidgets/Config.h"
#include "core/ViewFactory.h"

#include "../clang_format18_workaround.h"

using namespace KDDockWidgets;
using namespace KDDockWidgets::Core;

Expand Down Expand Up @@ -205,7 +207,7 @@ KDDW_QCORO_TASK tst_tabBarDWClosed()
}

// 1 event loop for DelayedDelete. Avoids LSAN warnings.
KDDW_CO_AWAIT Platform::instance()->tests_wait(1);
EVENT_LOOP(1);

KDDW_TEST_RETURN(true);
}
Expand Down
6 changes: 3 additions & 3 deletions tests/qtquick/tst_qtquick.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ void TestQtQuick::tst_isFloatingIsEmitted()
}

// 1 event loop for DelayedDelete. Avoids LSAN warnings.
KDDW_CO_AWAIT Platform::instance()->tests_wait(1);
EVENT_LOOP(1);
}

void TestQtQuick::tst_shutdownCrash()
Expand Down Expand Up @@ -304,7 +304,7 @@ void TestQtQuick::tst_childQmlContext()
}

// 1 event loop for DelayedDelete. Avoids LSAN warnings.
KDDW_CO_AWAIT Platform::instance()->tests_wait(1);
EVENT_LOOP(1);
}

void TestQtQuick::tst_focusBetweenTabs()
Expand All @@ -321,7 +321,7 @@ void TestQtQuick::tst_focusBetweenTabs()
auto floatingDock = DockRegistry::self()->dockByName("floatingDock");

dock1->view()->rootView()->activateWindow();
KDDW_CO_AWAIT Platform::instance()->tests_wait(2000);
EVENT_LOOP(2000);
dock1->dptr()->group()->focus();

QVERIFY(dock1->isFocused());
Expand Down
6 changes: 3 additions & 3 deletions tests/qtwidgets/tst_qtwidgets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2410,14 +2410,14 @@ void TestQtWidgets::tst_focusBetweenTabs()
leFloating->setFocus();
QVERIFY(dock3->dockWidget()->isCurrentTab());
m1->view()->activateWindow();
KDDW_CO_AWAIT Platform::instance()->tests_wait(1);
EVENT_LOOP(1);
le3->setFocus();

QVERIFY(le3->hasFocus());
dock2->setAsCurrentTab();
QVERIFY(dock2->dockWidget()->isCurrentTab());
le2->setFocus();
KDDW_CO_AWAIT Platform::instance()->tests_wait(1);
EVENT_LOOP(1);
QVERIFY(le2->hasFocus());

// 2. Now, cycling tabs should toggle focus between le2 and le3
Expand All @@ -2443,7 +2443,7 @@ void TestQtWidgets::tst_focusBetweenTabs()
auto titlebarFloating = floatingDock->actualTitleBar()->view();
QVERIFY(titlebarFloating->isVisible());
titlebarFloating->setFocus(Qt::MouseFocusReason);
KDDW_CO_AWAIT Platform::instance()->tests_wait(1000);
EVENT_LOOP(1000);

QVERIFY(leFloating->hasFocus());
QVERIFY(!le1->hasFocus());
Expand Down
Loading

0 comments on commit 27f6352

Please sign in to comment.