Skip to content

Commit

Permalink
Merge branch 'main' into add-1.0.4-to-main
Browse files Browse the repository at this point in the history
  • Loading branch information
LeonMatthesKDAB committed Jan 19, 2024
2 parents 8403345 + 1a03c81 commit 0c50827
Show file tree
Hide file tree
Showing 18 changed files with 1,105 additions and 269 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# SPDX-FileCopyrightText: 2023 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
#
# SPDX-License-Identifier: MIT

name: CI

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os:
- ubuntu-latest
- windows-latest
- macos-latest

steps:
- name: Checkout sources
uses: actions/checkout@v4

- name: Install ninja-build tool
uses: turtlesec-no/get-ninja@main

- name: Make sure MSVC is found when Ninja generator is in use
uses: ilammy/msvc-dev-cmd@v1
if: ${{ runner.os == 'Windows' }}

- name: Configure project
run: cmake --preset=ci

- name: Build Project
run: cmake --build --preset=ci

- name: Run tests
run: ctest --preset=ci

- name: Read tests log when it fails
uses: andstor/file-reader-action@v1
if: ${{ failure() }}
with:
path: "./build/Testing/Temporary/LastTest.log"
51 changes: 51 additions & 0 deletions .github/workflows/static_checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# SPDX-FileCopyrightText: 2024 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
#
# SPDX-License-Identifier: MIT

name: CI Static Checks

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest

config:
- name: clang-tidy

- name: clazy
apt_pgks:
- clazy

steps:
- name: Install ninja-build tool
uses: turtlesec-no/get-ninja@main

- name: Install dependencies on Ubuntu (${{ join(matrix.config.apt_pgks, ' ') }})
if: ${{ runner.os == 'Linux' && matrix.config.apt_pgks }}
run: |
sudo apt update -qq
echo ${{ join(matrix.config.apt_pgks, ' ') }} | xargs sudo apt install -y
- uses: actions/checkout@v4

- name: Fetch Git submodules
run: git submodule update --init --recursive

- name: Configure project
run: cmake --preset=${{ matrix.config.name }}

- name: Build Project
id: ctest
run: cmake --build --preset=${{ matrix.config.name }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ imgui.ini

.vscode/*
build/*
build-*
serenity_metatype.*
output.json

Expand Down
6 changes: 1 addition & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ cmake_minimum_required(VERSION 3.12) # for `project(... HOMEPAGE_URL ...)`
project(KDBindings
DESCRIPTION "Bindings, from the comfort and speed of C++ and without Qt"
LANGUAGES CXX
VERSION 1.0.1
VERSION 1.0.95
HOMEPAGE_URL "https://github.com/KDAB/KDBindings"
)

Expand Down Expand Up @@ -94,10 +94,6 @@ endif()

if(${PROJECT_NAME}_DOCS)
add_subdirectory(docs) # needs to go last, in case there are build source files
else()
add_custom_target(docs
COMMAND ${CMAKE_COMMAND} -E echo "Sorry, there is no docs target since KDBindings_DOCS=OFF."
"Re-run cmake with the -DKDBindings_DOCS=ON option if you want to generate the documentation.")
endif()

if(${PROJECT_NAME}_IS_ROOT_PROJECT)
Expand Down
99 changes: 99 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
{
"version": 2,
"configurePresets": [
{
"name": "dev",
"displayName": "dev",
"generator": "Ninja",
"binaryDir": "${sourceDir}/build-dev",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_EXPORT_COMPILE_COMMANDS" : "ON",
"KDBindings_TESTS" : "ON",
"KDBindings_EXAMPLES" : "ON"
}
},
{
"name": "ci",
"displayName": "ci",
"generator": "Ninja",
"binaryDir": "${sourceDir}/build-ci",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"CMAKE_EXPORT_COMPILE_COMMANDS" : "ON",
"KDBindings_TESTS" : "ON",
"KDBindings_EXAMPLES" : "ON",
"KDBindings_DOCS" : "ON"
}
},
{
"name": "clazy",
"displayName": "clazy",
"generator": "Ninja",
"binaryDir": "${sourceDir}/build-clazy",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_CXX_COMPILER" : "clazy",
"KDBindings_TESTS" : "ON",
"KDBindings_EXAMPLES" : "ON"
},
"warnings": {
"uninitialized": true
},
"errors": {
"dev": true
}
},
{
"name": "clang-tidy",
"displayName": "clang-tidy",
"generator": "Ninja",
"binaryDir": "${sourceDir}/build-clang-tidy",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_CXX_CLANG_TIDY" : "clang-tidy",
"KDBindings_TESTS" : "ON",
"KDBindings_EXAMPLES" : "ON"
},
"warnings": {
"uninitialized": true
},
"errors": {
"dev": true
}
}

],
"buildPresets": [
{
"name": "ci",
"configurePreset": "ci"
},
{
"name": "dev",
"configurePreset": "dev"
},
{
"name": "clazy",
"configurePreset": "clazy"
},
{
"name": "clang-tidy",
"configurePreset": "clang-tidy"
}
],
"testPresets": [
{
"name": "ci",
"configurePreset": "ci",
"output": {"outputOnFailure": true},
"execution": {"noTestsAction": "error", "stopOnFailure": true}
},
{
"name": "dev",
"configurePreset": "dev",
"output": {"outputOnFailure": true},
"execution": {"noTestsAction": "error", "stopOnFailure": false}
}
]
}
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
* v1.1.0 (unreleased)
- Feature: ConnectionEvaluator for deferred Signal/Slot evaluation and easy integration into multi-threaded environments (#48)
- Feature: Add ScopedConnection for RAII-style connection management (#31)

* v1.0.4
- Avoid error in presence of Windows min/max macros (#63)
- Fix Clang-Tidy failures (#49)
Expand Down
85 changes: 0 additions & 85 deletions appveyor.yml

This file was deleted.

16 changes: 16 additions & 0 deletions examples/08-managing-connections/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# This file is part of KDBindings.
#
# SPDX-FileCopyrightText: 2021 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
# Author: Leon Matthes <leon.matthes@kdab.com>
#
# SPDX-License-Identifier: MIT
#
# Contact KDAB at <info@kdab.com> for commercial licensing options.
#

project(08-managing-connections VERSION 0.1 LANGUAGES CXX)

add_executable(${PROJECT_NAME}
main.cpp
)
target_link_libraries(${PROJECT_NAME} KDAB::KDBindings)
56 changes: 56 additions & 0 deletions examples/08-managing-connections/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
This file is part of KDBindings.
SPDX-FileCopyrightText: 2021 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
Author: Leon Matthes <leon.matthes@kdab.com>
SPDX-License-Identifier: MIT
Contact KDAB at <info@kdab.com> for commercial licensing options.
*/

#include <ios>
#include <kdbindings/signal.h>

#include <iostream>
#include <string>

using namespace KDBindings;

void displayLabelled(const std::string &label, int value)
{
std::cout << label << ": " << value << std::endl;
}

int main()
{
Signal<int> signal;

{
// A ScopedConnection will disconnect the connection once it goes out of scope.
// It is especially useful if you're connecting to a member function.
// Storing a ScopedConnection in the object that contains the slot ensures the connection
// is disconnected when the object is destructed.
// This ensures that there are no dangling connections.
ScopedConnection guard = signal.connect(displayLabelled, "Guard is connected");

signal.emit(1);
} // The connection is disconnected here

signal.emit(2);

ConnectionHandle handle = signal.connect(displayLabelled, "Connection is not blocked");

signal.emit(3);
{
// A ConnectionBlocker will block a connection for the duration of its scope.
// This is a good way to avoid endless-recursion, or to suppress updates for a short time.
ConnectionBlocker blocker(handle); // The connection is blocked here

signal.emit(4);
} // The connection is un-blocked here

signal.emit(5);

return 0;
}
Loading

0 comments on commit 0c50827

Please sign in to comment.