Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start SmartPointers #1679

Merged
merged 38 commits into from
Feb 25, 2024
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
1b4df36
Refactor to fix #1671
Lord-Grey Dec 23, 2023
49cfca7
Add GUI/NonGUI mode to info page
Lord-Grey Dec 23, 2023
a833308
Do not show lock config, if in non-UI mode
Lord-Grey Dec 23, 2023
2d5df04
Updae Changelog
Lord-Grey Dec 23, 2023
870062a
Correct includes
Lord-Grey Dec 23, 2023
757d84c
Ensure key member initialization - RGB Channels
Lord-Grey Dec 27, 2023
ca88678
Ensure key member initialization - WebServer
Lord-Grey Dec 27, 2023
75c5eea
Update RGBChannels
Lord-Grey Dec 27, 2023
1166c76
Fix initialization order
Lord-Grey Dec 28, 2023
1cc8783
Fix key when inserting new logger in LoggerMap,
Lord-Grey Dec 28, 2023
592e61d
Fix Memory leak in GrabberWrapper
Lord-Grey Dec 28, 2023
0c87869
Fix Memory leak in BlackBorderProcessor
Lord-Grey Dec 28, 2023
dc564e9
Fix Memory leak in BlackBorderProcessor
Lord-Grey Dec 28, 2023
dad1d8b
use ninja generator under macos
Paulchen-Panther Dec 28, 2023
6aacac7
Fix BGEffectHandler destruction
Lord-Grey Dec 28, 2023
e71185a
Fix Mdns code
Lord-Grey Dec 29, 2023
40d74fa
Clear list after applying qDeleteAll
Lord-Grey Dec 29, 2023
fcee3d0
Fix deletion of CecHandler
Lord-Grey Dec 29, 2023
89ec43b
Fix memory leak caused by wrong buffer allocation
Lord-Grey Dec 29, 2023
ccacad9
Remove extra pixel consistently
Lord-Grey Dec 30, 2023
e8f19e2
Change mDNS to Qt SmartPointers
Lord-Grey Dec 30, 2023
77f7a6b
Correct removal
Lord-Grey Dec 31, 2023
6df4550
Fix usage of _width/_height (they are the output resolution, not the …
Lord-Grey Jan 1, 2024
26102ca
Move main non Thread Objects to Smart Pointers
Lord-Grey Jan 1, 2024
4630d9b
Refactor Hyperion Daemon unsing smartpointers
Lord-Grey Jan 3, 2024
76c54bf
Merge remote-tracking branch 'origin/master' into smartp
Lord-Grey Jan 3, 2024
8007b3c
Correction
Lord-Grey Jan 3, 2024
f6955ea
Correct typos/ align text
Lord-Grey Jan 3, 2024
1bb77e7
Fix startGrabberDispmanx
Lord-Grey Jan 4, 2024
8b04621
Fix startGrabberDispmanx
Lord-Grey Jan 4, 2024
524ff6a
Address CodeQL finding
Lord-Grey Jan 6, 2024
3cf1d4c
Create Screen grabbers via Template
Lord-Grey Jan 7, 2024
f6a6519
Fix typo
Lord-Grey Jan 7, 2024
be34366
Change way of logging
Lord-Grey Jan 7, 2024
fae8fe1
Revert change
Lord-Grey Jan 7, 2024
09637f6
Address deprecation warning
Lord-Grey Jan 7, 2024
6ecc2b0
Merge remote-tracking branch 'origin/master' into smartp
Lord-Grey Jan 14, 2024
2ae1e8a
Correct auto screen grabber evaluation
Lord-Grey Jan 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ Note: The wizard will configure an APIv2 capable bridge always with Entertainmen
- MDNSBrower - Fixed, if timeout while resolving host occurs
- Non image updates ignored blacklisted LEDs (#1634)
- Fixed that Windows OsEvents failed in non-GUI mode (#1671)
- Addressed serious (#1425) and some smaller memory leaks

##### LED-Devices

Expand All @@ -79,6 +80,7 @@ Note: The wizard will configure an APIv2 capable bridge always with Entertainmen
- Changed default build from Stretch to Buster
- Support Qt 6.7, Update to Protobuf 25.1, Update mbedTLS to v3.4.0, Update flatbuffers to v23.5.26
- Use C++17 standard as default
- Started using SmartPointers (#981)
- Added Pull Request (PR) installation script, allowing users to test development builds savely on Linux
- Fixed missing include limits in QJsonSchemaChecker - Thanks @Portisch
- Fixed dependencies for deb packages in Debian Bookworm (#1579) - Thanks @hg42, @Psirus
Expand Down
11 changes: 8 additions & 3 deletions include/blackborder/BlackBorderProcessor.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#pragma once
#ifndef BLACK_BORDER_PROCESSOR_H
#define BLACK_BORDER_PROCESSOR_H

#include <memory>

// QT includes
#include <QJsonObject>
Expand All @@ -24,7 +27,7 @@ namespace hyperion
Q_OBJECT
public:
BlackBorderProcessor(Hyperion* hyperion, QObject* parent);
~BlackBorderProcessor() override;

///
/// Return the current (detected) border
/// @return The current border
Expand Down Expand Up @@ -141,7 +144,7 @@ namespace hyperion
QString _detectionMode;

/// The black-border detector
BlackBorderDetector* _detector;
std::unique_ptr<BlackBorderDetector> _detector;

/// The current detected border
BlackBorder _currentBorder;
Expand All @@ -162,3 +165,5 @@ namespace hyperion

};
} // end namespace hyperion

#endif // BLACK_BORDER_PROCESSOR_H
9 changes: 7 additions & 2 deletions include/events/EventHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ class EventHandler : public QObject
Q_OBJECT

public:
EventHandler();
~EventHandler() override;

static EventHandler* getInstance();
static QScopedPointer<EventHandler>& getInstance();

public slots:

Expand All @@ -40,6 +39,12 @@ public slots:
Logger * _log {};

private:
EventHandler();
EventHandler(const EventHandler&) = delete;
EventHandler& operator=(const EventHandler&) = delete;

static QScopedPointer<EventHandler> instance;

bool _isSuspended;
bool _isIdle;
};
Expand Down
4 changes: 2 additions & 2 deletions include/grabber/qt/QtGrabber.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ private slots:
int _display;
int _numberOfSDisplays;

int _calculatedWidth;
int _calculatedHeight;
int _screenWidth;
int _screenHeight;
int _src_x;
int _src_y;
int _src_x_max;
Expand Down
20 changes: 10 additions & 10 deletions include/grabber/x11/X11Grabber.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class X11Grabber : public Grabber , public QAbstractNativeEventFilter
///
/// @brief Apply new width/height values, overwrite Grabber.h implementation as X11 doesn't use width/height, just pixelDecimation to calc dimensions
///
bool setWidthHeight(int width, int height) override { return true; }
bool setWidthHeight(int /*width*/, int /*height*/) override { return true; }

///
/// @brief Apply new pixelDecimation
Expand Down Expand Up @@ -109,19 +109,19 @@ class X11Grabber : public Grabber , public QAbstractNativeEventFilter
Picture _srcPicture;
Picture _dstPicture;

int _XRandREventBase;
int _xRandREventBase;

XTransform _transform;

unsigned _calculatedWidth;
unsigned _calculatedHeight;
unsigned _src_x;
unsigned _src_y;
int _screenWidth;
int _screenHeight;
int _src_x;
int _src_y;

bool _XShmAvailable;
bool _XShmPixmapAvailable;
bool _XRenderAvailable;
bool _XRandRAvailable;
bool _xShmAvailable;
bool _xShmPixmapAvailable;
bool _xRenderAvailable;
bool _xRandRAvailable;
bool _isWayland;

Logger * _logger;
Expand Down
10 changes: 10 additions & 0 deletions include/hyperion/BGEffectHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,16 @@ class BGEffectHandler : public QObject
handleSettingsUpdate(settings::BGEFFECT, _hyperion->getSetting(settings::BGEFFECT));
}

///
/// @brief Disconnect from connected signals
/// Disconnect should be done before other priorities invoke methods during shutdown
///
void disconnect()
{
QObject::disconnect(_prioMuxer, &PriorityMuxer::prioritiesChanged, nullptr, nullptr);
QObject::disconnect(_hyperion, nullptr, nullptr, nullptr);
}

///
/// @brief Check, if background effect processing is enabled.
/// @return True, background effect processing is enabled.
Expand Down
16 changes: 8 additions & 8 deletions include/hyperion/ColorAdjustment.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@ class ColorAdjustment
QString _id;

/// The BLACK (RGB-Channel) adjustment
RgbChannelAdjustment _rgbBlackAdjustment;
RgbChannelAdjustment _rgbBlackAdjustment {0, 0, 0, "black"};
/// The WHITE (RGB-Channel) adjustment
RgbChannelAdjustment _rgbWhiteAdjustment;
RgbChannelAdjustment _rgbWhiteAdjustment{255, 255, 255, "white"};
/// The RED (RGB-Channel) adjustment
RgbChannelAdjustment _rgbRedAdjustment;
RgbChannelAdjustment _rgbRedAdjustment {255, 0, 0 , "red"};
/// The GREEN (RGB-Channel) adjustment
RgbChannelAdjustment _rgbGreenAdjustment;
RgbChannelAdjustment _rgbGreenAdjustment {0, 255, 0, "green"};
/// The BLUE (RGB-Channel) adjustment
RgbChannelAdjustment _rgbBlueAdjustment;
RgbChannelAdjustment _rgbBlueAdjustment {0, 0, 255, "blue"};
/// The CYAN (RGB-Channel) adjustment
RgbChannelAdjustment _rgbCyanAdjustment;
RgbChannelAdjustment _rgbCyanAdjustment {0, 255, 255, "cyan"};
/// The MAGENTA (RGB-Channel) adjustment
RgbChannelAdjustment _rgbMagentaAdjustment;
RgbChannelAdjustment _rgbMagentaAdjustment {255, 0, 255, "magenta"};
/// The YELLOW (RGB-Channel) adjustment
RgbChannelAdjustment _rgbYellowAdjustment;
RgbChannelAdjustment _rgbYellowAdjustment {255, 255, 0, "yellow"};

RgbTransform _rgbTransform;
OkhsvTransform _okhsvTransform;
Expand Down
7 changes: 4 additions & 3 deletions include/hyperion/GrabberWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <QString>
#include <QStringList>
#include <QMultiMap>
#include <QScopedPointer>

#include <utils/Logger.h>
#include <utils/Components.h>
Expand Down Expand Up @@ -91,8 +92,8 @@ class GrabberWrapper : public QObject
template <typename Grabber_T>
bool transferFrame(Grabber_T &grabber)
{
unsigned w = grabber.getImageWidth();
unsigned h = grabber.getImageHeight();
int w = grabber.getImageWidth();
int h = grabber.getImageHeight();
if ( _image.width() != w || _image.height() != h)
{
_image.resize(w, h);
Expand Down Expand Up @@ -185,7 +186,7 @@ private slots:
Logger * _log;

/// The timer for generating events with the specified update rate
QTimer* _timer;
QScopedPointer<QTimer> _timer;

/// The calculated update rate [ms]
int _updateInterval_ms;
Expand Down
30 changes: 13 additions & 17 deletions include/mdns/MdnsBrowser.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#define MDNS_BROWSER_H

#include <chrono>
#include <type_traits>

#include <qmdnsengine/server.h>
#include <qmdnsengine/service.h>
Expand All @@ -16,6 +15,10 @@
// Qt includes
#include <QObject>
#include <QByteArray>
#include <QMap>
#include <QJsonArray>
#include <QScopedPointer>
#include <QSharedPointer>

// Utility includes
#include <utils/Logger.h>
Expand All @@ -24,41 +27,33 @@
namespace {
constexpr std::chrono::milliseconds DEFAULT_DISCOVER_TIMEOUT{ 500 };
constexpr std::chrono::milliseconds DEFAULT_ADDRESS_RESOLVE_TIMEOUT{ 1000 };

} //End of constants
} // End of constants

class MdnsBrowser : public QObject
{
Q_OBJECT

// Run MdnsBrowser as singleton

private:
///
/// @brief Browse for hyperion services in bonjour, constructed from HyperionDaemon
/// Searching for hyperion http service by default
///
// Run MdnsBrowser as singleton
MdnsBrowser(QObject* parent = nullptr);
~MdnsBrowser() override;

public:

static MdnsBrowser& getInstance()
{
static MdnsBrowser* instance = new MdnsBrowser();
return *instance;
}

MdnsBrowser(const MdnsBrowser&) = delete;
MdnsBrowser(MdnsBrowser&&) = delete;
MdnsBrowser& operator=(const MdnsBrowser&) = delete;
MdnsBrowser& operator=(MdnsBrowser&&) = delete;

static QScopedPointer<MdnsBrowser> instance;

public:
~MdnsBrowser() override;
static QScopedPointer<MdnsBrowser>& getInstance();

QMdnsEngine::Service getFirstService(const QByteArray& serviceType, const QString& filter = ".*", const std::chrono::milliseconds waitTime = DEFAULT_DISCOVER_TIMEOUT) const;
QJsonArray getServicesDiscoveredJson(const QByteArray& serviceType, const QString& filter = ".*", const std::chrono::milliseconds waitTime = std::chrono::milliseconds{ 0 }) const;


void printCache(const QByteArray& name = QByteArray(), quint16 type = QMdnsEngine::ANY) const;

public slots:
Expand Down Expand Up @@ -109,8 +104,9 @@ private slots:

QMdnsEngine::Server _server;
QMdnsEngine::Cache _cache;
QSharedPointer<QMdnsEngine::Resolver> _resolver;

QMap<QByteArray, QMdnsEngine::Browser*> _browsedServiceTypes;
QMap<QByteArray, QSharedPointer<QMdnsEngine::Browser>> _browsedServiceTypes;
};

#endif // MDNSBROWSER_H
7 changes: 4 additions & 3 deletions include/mdns/MdnsProvider.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
// Qt includes
#include <QObject>
#include <QByteArray>
#include <QScopedPointer>

// Utility includes
#include <utils/Logger.h>
Expand Down Expand Up @@ -41,11 +42,11 @@ private slots:
/// The logger instance for mDNS-Service
Logger* _log;

QMdnsEngine::Server* _server;
QMdnsEngine::Hostname* _hostname;
QScopedPointer<QMdnsEngine::Server> _server;
QScopedPointer<QMdnsEngine::Hostname> _hostname;

/// map of services provided
QMap<QByteArray, QMdnsEngine::Provider*> _providedServiceTypes;
QMap<QByteArray, QSharedPointer<QMdnsEngine::Provider>> _providedServiceTypes;
};

#endif // MDNSPROVIDER_H
20 changes: 9 additions & 11 deletions include/utils/Image.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ class Image
{
}

Image(unsigned width, unsigned height) :
Image(int width, int height) :
Image(width, height, Pixel_T())

{
}

Expand All @@ -28,7 +27,7 @@ class Image
/// @param height The height of the image
/// @param background The color of the image
///
Image(unsigned width, unsigned height, const Pixel_T background) :
Image(int width, int height, const Pixel_T background) :
_d_ptr(new ImageData<Pixel_T>(width, height, background))
{
}
Expand Down Expand Up @@ -78,7 +77,7 @@ class Image
///
/// @return The width of the image
///
inline unsigned width() const
inline int width() const
{
return _d_ptr->width();
}
Expand All @@ -88,7 +87,7 @@ class Image
///
/// @return The height of the image
///
inline unsigned height() const
inline int height() const
{
return _d_ptr->height();
}
Expand All @@ -111,7 +110,7 @@ class Image
///
/// @return const reference to specified pixel
///
uint8_t blue(unsigned pixel) const
uint8_t blue(int pixel) const
{
return _d_ptr->blue(pixel);
}
Expand All @@ -121,23 +120,23 @@ class Image
///
/// @param x The x index
/// @param y The y index
const Pixel_T& operator()(unsigned x, unsigned y) const
const Pixel_T& operator()(int x, int y) const
{
return _d_ptr->operator()(x, y);
}

///
/// @return reference to specified pixel
///
Pixel_T& operator()(unsigned x, unsigned y)
Pixel_T& operator()(int x, int y)
{
return _d_ptr->operator()(x, y);
}

/// Resize the image
/// @param width The width of the image
/// @param height The height of the image
void resize(unsigned width, unsigned height)
void resize(int width, int height)
{
_d_ptr->resize(width, height);
}
Expand Down Expand Up @@ -198,12 +197,11 @@ class Image
///
/// @return The index into the underlying data-vector
///
inline unsigned toIndex(unsigned x, unsigned y) const
inline int toIndex(int x, int y) const
{
return _d_ptr->toIndex(x, y);
}

private:
QSharedDataPointer<ImageData<Pixel_T>> _d_ptr;
};

Loading
Loading