From 0251f35c93e3f0e0a6853a50fb5bd82c1b9e4187 Mon Sep 17 00:00:00 2001 From: saturneric Date: Mon, 6 Nov 2023 17:17:47 +0800 Subject: refactor: clean up core's codes --- src/core/function/basic/ChannelObject.cpp | 45 +++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 src/core/function/basic/ChannelObject.cpp (limited to 'src/core/function/basic/ChannelObject.cpp') diff --git a/src/core/function/basic/ChannelObject.cpp b/src/core/function/basic/ChannelObject.cpp new file mode 100644 index 00000000..9485a278 --- /dev/null +++ b/src/core/function/basic/ChannelObject.cpp @@ -0,0 +1,45 @@ +/** + * Copyright (C) 2021 Saturneric + * + * This file is part of GpgFrontend. + * + * GpgFrontend is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GpgFrontend is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GpgFrontend. If not, see . + * + * The initial version of the source code is inherited from + * the gpg4usb project, which is under GPL-3.0-or-later. + * + * All the source code of GpgFrontend was modified and released by + * Saturneric starting on May 12, 2021. + * + * SPDX-License-Identifier: GPL-3.0-or-later + * + */ + +#include "ChannelObject.h" + +namespace GpgFrontend { + +ChannelObject::ChannelObject() noexcept = default; + +ChannelObject::ChannelObject(int channel) : channel_(channel) {} + +void ChannelObject::SetChannel(int channel) { this->channel_ = channel; } + +auto ChannelObject::GetChannel() const -> int { return channel_; } + +auto ChannelObject::GetDefaultChannel() -> int { + return kGpgFrontendDefaultChannel; +} + +} // namespace GpgFrontend \ No newline at end of file -- cgit v1.2.3 From ae2717c3787a34a2c60d6aeef2d0b8bb8e551a1e Mon Sep 17 00:00:00 2001 From: saturneric Date: Sun, 3 Dec 2023 04:27:47 -0800 Subject: feat: improve memory security of function framework --- src/core/function/basic/ChannelObject.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/core/function/basic/ChannelObject.cpp') diff --git a/src/core/function/basic/ChannelObject.cpp b/src/core/function/basic/ChannelObject.cpp index 9485a278..7a41d4d1 100644 --- a/src/core/function/basic/ChannelObject.cpp +++ b/src/core/function/basic/ChannelObject.cpp @@ -34,6 +34,8 @@ ChannelObject::ChannelObject() noexcept = default; ChannelObject::ChannelObject(int channel) : channel_(channel) {} +ChannelObject::~ChannelObject() noexcept = default; + void ChannelObject::SetChannel(int channel) { this->channel_ = channel; } auto ChannelObject::GetChannel() const -> int { return channel_; } -- cgit v1.2.3 From f5cf83e4b3fdf1e9ae82b00f39e45e189809c419 Mon Sep 17 00:00:00 2001 From: saturneric Date: Fri, 15 Dec 2023 17:04:59 +0800 Subject: fix: slove some issues on memory and intilizations --- src/core/function/basic/ChannelObject.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/core/function/basic/ChannelObject.cpp') diff --git a/src/core/function/basic/ChannelObject.cpp b/src/core/function/basic/ChannelObject.cpp index 7a41d4d1..3f040ca6 100644 --- a/src/core/function/basic/ChannelObject.cpp +++ b/src/core/function/basic/ChannelObject.cpp @@ -28,13 +28,20 @@ #include "ChannelObject.h" +#include +#include +#include + namespace GpgFrontend { ChannelObject::ChannelObject() noexcept = default; -ChannelObject::ChannelObject(int channel) : channel_(channel) {} +ChannelObject::ChannelObject(int channel, std::string type) + : channel_(channel), type_(std::move(type)) {} -ChannelObject::~ChannelObject() noexcept = default; +ChannelObject::~ChannelObject() noexcept { + std::cout << "deleting channel object: " << type_ << std::endl; +} void ChannelObject::SetChannel(int channel) { this->channel_ = channel; } -- cgit v1.2.3 From 37215a895a649345165027971690dfdcd9106a32 Mon Sep 17 00:00:00 2001 From: saturneric Date: Fri, 15 Dec 2023 21:53:03 -0800 Subject: fix: use secure memory management at impl class --- src/core/function/basic/ChannelObject.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'src/core/function/basic/ChannelObject.cpp') diff --git a/src/core/function/basic/ChannelObject.cpp b/src/core/function/basic/ChannelObject.cpp index 3f040ca6..451f9eeb 100644 --- a/src/core/function/basic/ChannelObject.cpp +++ b/src/core/function/basic/ChannelObject.cpp @@ -28,9 +28,7 @@ #include "ChannelObject.h" -#include #include -#include namespace GpgFrontend { @@ -39,9 +37,7 @@ ChannelObject::ChannelObject() noexcept = default; ChannelObject::ChannelObject(int channel, std::string type) : channel_(channel), type_(std::move(type)) {} -ChannelObject::~ChannelObject() noexcept { - std::cout << "deleting channel object: " << type_ << std::endl; -} +ChannelObject::~ChannelObject() noexcept = default; void ChannelObject::SetChannel(int channel) { this->channel_ = channel; } -- cgit v1.2.3 From 3c40fa27823e70215261d3845275360f85e59623 Mon Sep 17 00:00:00 2001 From: saturneric Date: Fri, 5 Jan 2024 16:11:24 +0800 Subject: fix: slove some known issues --- src/core/function/basic/ChannelObject.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/core/function/basic/ChannelObject.cpp') diff --git a/src/core/function/basic/ChannelObject.cpp b/src/core/function/basic/ChannelObject.cpp index 451f9eeb..ddbfa603 100644 --- a/src/core/function/basic/ChannelObject.cpp +++ b/src/core/function/basic/ChannelObject.cpp @@ -28,7 +28,7 @@ #include "ChannelObject.h" -#include +#include namespace GpgFrontend { @@ -37,7 +37,15 @@ ChannelObject::ChannelObject() noexcept = default; ChannelObject::ChannelObject(int channel, std::string type) : channel_(channel), type_(std::move(type)) {} +#ifdef DEBUG +ChannelObject::~ChannelObject() noexcept { + // using iostream instead of spdlog bacause at this time spdlog may have + // already been destroyed. + std::cout << "releasing channel object: " << this->type_ << std::endl; +} +#else ChannelObject::~ChannelObject() noexcept = default; +#endif void ChannelObject::SetChannel(int channel) { this->channel_ = channel; } -- cgit v1.2.3 From bf538056b24a68b8fd235b1c50991ee8eb46a776 Mon Sep 17 00:00:00 2001 From: saturneric Date: Fri, 12 Jan 2024 14:02:37 +0800 Subject: refactor: use QString instead of std::string and improve threading system --- src/core/function/basic/ChannelObject.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/core/function/basic/ChannelObject.cpp') diff --git a/src/core/function/basic/ChannelObject.cpp b/src/core/function/basic/ChannelObject.cpp index ddbfa603..18449ddb 100644 --- a/src/core/function/basic/ChannelObject.cpp +++ b/src/core/function/basic/ChannelObject.cpp @@ -34,14 +34,15 @@ namespace GpgFrontend { ChannelObject::ChannelObject() noexcept = default; -ChannelObject::ChannelObject(int channel, std::string type) +ChannelObject::ChannelObject(int channel, QString type) : channel_(channel), type_(std::move(type)) {} #ifdef DEBUG ChannelObject::~ChannelObject() noexcept { // using iostream instead of spdlog bacause at this time spdlog may have // already been destroyed. - std::cout << "releasing channel object: " << this->type_ << std::endl; + QTextStream(stdout) << "releasing channel object: " << this->type_ + << Qt::endl; } #else ChannelObject::~ChannelObject() noexcept = default; -- cgit v1.2.3