Compare commits

...

4 Commits

Author SHA1 Message Date
Fish
b7cb05a3f7
Merge 9bb107d7f4 into 1a905cbd4f 2024-11-26 13:00:35 +00:00
Egor Krugletsov
1a905cbd4f
Use std::shared_ptr for PromiseValue<T>::m_data instead of QSharedPoitner<T> (#60)
In optimized builds (such as -O2) GCC emits "maybe-uninitialized" warning for QSharedPointer<T>::d. This happens only for optimized builds because that is when GCC tracks lifetimes[1]. In a project with lots of QtPromise uses this produces a heap of bogus warnings. This warning has been previously reported to a Qt team, but they're confident it is a compiler bug[2][3]. However, this is a second time and issue raised with QSharedPointer and warnings to it. The first time it was addressed here: https://github.com/simonbrunel/qtpromise/pull/34.

[1] https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wmaybe-uninitialized
[2] https://bugreports.qt.io/browse/QTBUG-14637
[3] https://bugreports.qt.io/browse/QTBUG-77641
2024-08-24 09:01:08 +02:00
Simon Brunel
14031392ac Use GitHub actions instead of Travis 2024-08-20 20:59:47 +02:00
yuailong
9bb107d7f4 Brings conan package management to qtpromise.
I have uploaded it to personal conan-repository(https://fish.jfrog.io/artifactory/api/conan/fish-conan), dependence: QtPromise/master
TODO:
1, Need to add test_package for testing
2, Need to upload to conan-center, better with ci/cd
2021-07-07 16:38:37 +08:00
4 changed files with 79 additions and 42 deletions

43
.github/workflows/ci.yaml vendored Normal file
View File

@ -0,0 +1,43 @@
# https://docs.github.com/actions/reference/workflow-syntax-for-github-actions
# https://doc.qt.io/qt-6/supported-platforms.html
# https://ddalcino.github.io/aqt-list-server/
name: CI
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
qt:
- 5.9.9
steps:
- uses: actions/checkout@v4
- uses: jurplel/install-qt-action@v4
with:
version: ${{ matrix.qt }}
archives: qtbase icu
tools: tools_cmake
arch: gcc_64
host: linux
- run: |
qmake --version
cmake --version
gcc --version
g++ --version
- run: |
cmake -G "Unix Makefiles"
cmake --build . -- -j12
cmake --build . --target test
- run: |
sudo apt-get install lcov > /dev/null
lcov --version
lcov --capture --directory . -o coverage.info
lcov -e coverage.info '**/src/**/*' -o coverage.info
- uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
files: coverage.info

View File

@ -1,38 +0,0 @@
sudo: required
dist: xenial
language: cpp
compiler: gcc
before_install:
- sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
- sudo add-apt-repository -y ppa:beineri/opt-qt563-xenial
- sudo apt-get update -qq
install:
- sudo apt-get install -qq gcc-4.9 g++-4.9
- sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 90
- sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.9 90
- sudo update-alternatives --install /usr/bin/gcov gcov /usr/bin/gcov-4.9 90
- sudo apt-get install -qq qt56base
- source /opt/qt56/bin/qt56-env.sh
- wget http://archive.ubuntu.com/ubuntu/pool/universe/l/lcov/lcov_1.13.orig.tar.gz
- tar xf lcov_1.13.orig.tar.gz
- cd lcov-1.13/
- sudo make install
- cd ..
before_script:
- cmake --version
- qmake --version
- gcc --version && g++ --version
- lcov --version && gcov --version
script:
- cmake -G "Unix Makefiles"
- cmake --build . -- -j12
- cmake --build . --target test
- lcov -capture --directory . --o coverage.info
- lcov -e coverage.info '**/src/**/*' -o coverage.info
after_success:
- bash <(curl -s https://codecov.io/bash) -f coverage.info

30
conanfile.py Normal file
View File

@ -0,0 +1,30 @@
import os
from conans import ConanFile
class QtPromiseConfig(ConanFile):
name = "QtPromise"
version = "master"
license = "QtPromise is available under the MIT license."
author = "simonbrunel"
url = "https://github.com/simonbrunel/qtpromise"
description = "Promises/A+ implementation for Qt/C++"
settings = "os", "compiler", "build_type", "arch"
def package_id(self):
self.info.header_only()
def source(self):
self.run("git clone git@github.com:simonbrunel/qtpromise.git")
def package(self):
self.copy("*", dst="include", src="./qtpromise/include")
self.copy("*", dst="src", src="./qtpromise/src")
def package_info(self):
self.cpp_info.libs = self.collect_libs()
if __name__ == '__main__':
os.system("conan create .")

View File

@ -20,6 +20,8 @@
#include <QtCore/QVariant>
#include <QtCore/QVector>
#include <memory>
namespace QtPromise {
template<typename T>
@ -92,13 +94,13 @@ class PromiseValue
{
public:
PromiseValue() { }
PromiseValue(const T& data) : m_data(QSharedPointer<T>::create(data)) { }
PromiseValue(T&& data) : m_data(QSharedPointer<T>::create(std::forward<T>(data))) { }
bool isNull() const { return m_data.isNull(); }
PromiseValue(const T& data) : m_data(std::make_shared<T>(data)) { }
PromiseValue(T&& data) : m_data(std::make_shared<T>(std::forward<T>(data))) { }
bool isNull() const { return m_data == nullptr; }
const T& data() const { return *m_data; }
private:
QSharedPointer<T> m_data;
std::shared_ptr<T> m_data;
};
class PromiseError