Follow clang-tidy and clazy suggestions

variables non-POD should not be 'static' outside a class. Always use and init variables. Delete useless classes.
This commit is contained in:
Bruno
2021-07-17 16:45:01 +02:00
parent 5930b0f8fe
commit a18fd3177c
27 changed files with 112 additions and 174 deletions

View File

@@ -85,7 +85,8 @@ std::string BaseToolkit::byte_to_string(long b)
++i;
numbytes /= 1024.0;
}
oss << std::fixed << std::setprecision(2) << numbytes << *i;
oss << std::fixed << std::setprecision(2) << numbytes;
if (i != list.end()) oss << *i;
return oss.str();
}
@@ -102,7 +103,8 @@ std::string BaseToolkit::bits_to_string(long b)
++i;
numbytes /= 1000.0;
}
oss << std::fixed << std::setprecision(2) << numbytes << *i;
oss << std::fixed << std::setprecision(2) << numbytes;
if (i != list.end()) oss << *i;
return oss.str();
}

View File

@@ -157,6 +157,7 @@ void Connection::listen()
#ifdef CONNECTION_DEBUG
Log::Info("Accepting handshake on port %d", Connection::manager().connections_[0].port_handshake);
#endif
if (Connection::manager().receiver_)
Connection::manager().receiver_->Run();
}

View File

@@ -249,7 +249,7 @@ void Handles::draw(glm::mat4 modelview, glm::mat4 projection)
init();
}
if ( visible_ ) {
if ( visible_ && handle_) {
static Mesh *handle_active = new Mesh("mesh/border_handles_overlay_filled.ply");
// set color

View File

@@ -224,7 +224,7 @@ void GeometryView::draw()
scene.accept(draw_overlays);
// 4. Draw control overlays of current source on top (if selectable)
if (canSelect(s)) {
if (s!=nullptr && canSelect(s)) {
s->setMode(Source::CURRENT);
DrawVisitor dv(s->overlays_[mode_], projection);
scene.accept(dv);
@@ -411,7 +411,7 @@ std::pair<Node *, glm::vec2> GeometryView::pick(glm::vec2 P)
if (current->workspace() != Settings::application.current_workspace){
current = nullptr;
}
else {
// find if the current source was picked
auto itp = pv.rbegin();
for (; itp != pv.rend(); ++itp){
@@ -446,6 +446,7 @@ std::pair<Node *, glm::vec2> GeometryView::pick(glm::vec2 P)
pick = { nullptr, glm::vec2(0.f) };
}
}
}
// the clicked source changed (not the current source)
if (current == nullptr) {
@@ -516,7 +517,7 @@ std::pair<Node *, glm::vec2> GeometryView::pick(glm::vec2 P)
bool GeometryView::canSelect(Source *s) {
return ( View::canSelect(s) && s->ready() && s->active() && s->workspace() == Settings::application.current_workspace);
return ( s!=nullptr && View::canSelect(s) && s->ready() && s->active() && s->workspace() == Settings::application.current_workspace);
}

View File

@@ -57,6 +57,16 @@ GlmToolkit::AxisAlignedBoundingBox::AxisAlignedBoundingBox() :
{
}
GlmToolkit::AxisAlignedBoundingBox::AxisAlignedBoundingBox(const GlmToolkit::AxisAlignedBoundingBox &D) :
mMin(D.mMin), mMax(D.mMax)
{
}
void GlmToolkit::AxisAlignedBoundingBox::operator = (const GlmToolkit::AxisAlignedBoundingBox &D ) {
mMin = D.mMin;
mMax = D.mMax;
}
void GlmToolkit::AxisAlignedBoundingBox::extend(const glm::vec3& point)
{
if (isNull()) {

View File

@@ -15,11 +15,8 @@ class AxisAlignedBoundingBox
{
public:
AxisAlignedBoundingBox();
inline void operator = (const AxisAlignedBoundingBox &D ) {
mMin = D.mMin;
mMax = D.mMax;
}
AxisAlignedBoundingBox(const AxisAlignedBoundingBox &D);
void operator = (const AxisAlignedBoundingBox &D );
// test
inline bool isNull() const { return mMin.x > mMax.x || mMin.y > mMax.y || mMin.z > mMax.z;}

View File

@@ -152,14 +152,6 @@ void ImGuiVisitor::visit(FrameBufferSurface &n)
ImGui::Text("Framebuffer");
}
void ImGuiVisitor::visit(MediaSurface &n)
{
ImGui::Text("%s", n.path().c_str());
if (n.mediaPlayer())
n.mediaPlayer()->accept(*this);
}
void ImGuiVisitor::visit(MediaPlayer &n)
{
ImGui::Text("Media Player");

View File

@@ -17,7 +17,6 @@ public:
void visit (Group& n) override;
void visit (Switch& n) override;
void visit (Primitive& n) override;
void visit (MediaSurface& n) override;
void visit (FrameBufferSurface& n) override;
// Elements with attributes

View File

@@ -12,7 +12,7 @@ const char* ImageProcessingShader::filter_names[12] = { "None", "Blur", "Sharpen
ImageProcessingShader::ImageProcessingShader(): Shader()
{
program_ = &imageProcessingShadingProgram;
reset();
ImageProcessingShader::reset();
}
void ImageProcessingShader::use()

View File

@@ -27,7 +27,7 @@ ImageShader::ImageShader(): Shader(), stipple(0.f), mask_texture(0)
// static program shader
program_ = &imageShadingProgram;
// reset instance
reset();
ImageShader::reset();
}
void ImageShader::use()
@@ -85,7 +85,7 @@ AlphaShader::AlphaShader(): ImageShader()
MaskShader::MaskShader(): Shader(), mode(0)
{
// reset instance
reset();
MaskShader::reset();
// static program shader
program_ = &maskPrograms[0];
}

11
Log.cpp
View File

@@ -144,7 +144,10 @@ struct AppLog
}
};
static AppLog logs;
AppLog logs;
list<string> notifications;
list<string> warnings;
float notifications_timeout = 0.f;
void Log::Info(const char* fmt, ...)
{
@@ -160,9 +163,6 @@ void Log::ShowLogWindow(bool* p_open)
logs.Draw( ICON_FA_LIST_UL " Logs", p_open);
}
static list<string> notifications;
static float notifications_timeout = 0.f;
void Log::Notify(const char* fmt, ...)
{
ImGuiTextBuffer buf;
@@ -180,9 +180,6 @@ void Log::Notify(const char* fmt, ...)
Log::Info("%s", buf.c_str());
}
static list<string> warnings;
void Log::Warning(const char* fmt, ...)
{
ImGuiTextBuffer buf;

View File

@@ -263,7 +263,6 @@ bool parsePLY(string ascii,
break;
default:
// ignore normals or other types
value = parseValue<float>(stringstream);
break;
}
}

View File

@@ -36,9 +36,9 @@
#include "Mixer.h"
#define THREADED_LOADING
static std::vector< std::future<Session *> > sessionLoaders_;
static std::vector< std::future<Session *> > sessionImporters_;
static std::vector< SessionSource * > sessionSourceToImport_;
std::vector< std::future<Session *> > sessionLoaders_;
std::vector< std::future<Session *> > sessionImporters_;
std::vector< SessionSource * > sessionSourceToImport_;
const std::chrono::milliseconds timeout_ = std::chrono::milliseconds(4);
@@ -1165,7 +1165,7 @@ void Mixer::merge(SessionSource *source)
void Mixer::swap()
{
if (!back_session_)
if (!back_session_ || !session_)
return;
if (session_) {

View File

@@ -99,8 +99,7 @@ void add_interface(int fd, const char *name) {
strncpy(ifreq.ifr_name, name, IFNAMSIZ);
if(ioctl(fd, SIOCGIFADDR, &ifreq)==0) {
char host[128];
int family;
switch(family=ifreq.ifr_addr.sa_family) {
switch(ifreq.ifr_addr.sa_family) {
case AF_INET:
case AF_INET6:
getnameinfo(&ifreq.ifr_addr, sizeof ifreq.ifr_addr, host, sizeof host, 0, 0, NI_NUMERICHOST);

View File

@@ -121,52 +121,6 @@ void ImageSurface::accept(Visitor& v)
v.visit(*this);
}
MediaSurface::MediaSurface(const std::string& p, Shader *s) : Surface(s), path_(p)
{
mediaplayer_ = new MediaPlayer;
}
MediaSurface::~MediaSurface()
{
delete mediaplayer_;
}
void MediaSurface::init()
{
Surface::init();
mediaplayer_->open(path_);
mediaplayer_->play(true);
}
void MediaSurface::draw(glm::mat4 modelview, glm::mat4 projection)
{
if ( !initialized() ) {
init();
// set the texture to the media player once openned
if ( mediaplayer_->isOpen() )
textureindex_ = mediaplayer_->texture();
}
Surface::draw(modelview, projection);
}
void MediaSurface::update( float dt )
{
if ( mediaplayer_->isOpen() ) {
mediaplayer_->update();
scale_.x = mediaplayer_->aspectRatio();
}
Primitive::update( dt );
}
void MediaSurface::accept(Visitor& v)
{
Surface::accept(v);
v.visit(*this);
}
FrameBufferSurface::FrameBufferSurface(FrameBuffer *fb, Shader *s) : Surface(s), frame_buffer_(fb)
{
}
@@ -401,6 +355,24 @@ LineSquare::LineSquare(float linewidth) : Group()
}
LineSquare::LineSquare(const LineSquare &square)
{
top_ = new HLine(square.top_->width);
top_->translation_ = glm::vec3(0.f, 1.f, 0.f);
attach(top_);
bottom_ = new HLine(square.bottom_->width);
bottom_->translation_ = glm::vec3(0.f, -1.f, 0.f);
attach(bottom_);
left_ = new VLine(square.left_->width);
left_->translation_ = glm::vec3(-1.f, 0.f, 0.f);
attach(left_);
right_ = new VLine(square.right_->width);
right_->translation_ = glm::vec3(1.f, 0.f, 0.f);
attach(right_);
setColor(square.color());
}
void LineSquare::setLineWidth(float v)
{
top_->width = v;
@@ -417,7 +389,6 @@ void LineSquare::setColor(glm::vec4 c)
right_->color = c;
}
LineStrip::LineStrip(const std::vector<glm::vec2> &path, float linewidth) : Primitive(new Shader),
arrayBuffer_(0), path_(path)
{

View File

@@ -62,31 +62,6 @@ protected:
};
/**
* @brief The MediaSurface class is a Surface to draw a video
*
* URI is passed to a Media Player to handle the video playback
* Height = 1.0, Width is set by the aspect ratio of the image
*/
class MediaSurface : public Surface {
public:
MediaSurface(const std::string& p, Shader *s = new ImageShader);
~MediaSurface();
void init () override;
void draw (glm::mat4 modelview, glm::mat4 projection) override;
void accept (Visitor& v) override;
void update (float dt) override;
inline std::string path() const { return path_; }
inline MediaPlayer *mediaPlayer() const { return mediaplayer_; }
protected:
std::string path_;
MediaPlayer *mediaplayer_;
};
/**
* @brief The FrameBufferSurface class is a Surface to draw a framebuffer
*
@@ -166,6 +141,7 @@ class LineSquare : public Group {
public:
LineSquare(float linewidth = 1.f);
LineSquare(const LineSquare &square);
void setLineWidth(float v);
inline float lineWidth() const { return top_->width; }

View File

@@ -100,7 +100,7 @@ void Rendering::LinkPipeline( GstPipeline *pipeline )
#endif
static std::map<GLFWwindow *, RenderingWindow*> GLFW_window_;
std::map<GLFWwindow *, RenderingWindow*> GLFW_window_;
static void glfw_error_callback(int error, const char* description)
{

View File

@@ -163,8 +163,7 @@ uint Resource::getTextureDDS(const std::string& path, float *aspect_ratio)
uint fourCC = *(uint*)&(header[80]);
// how big is it going to be including all mipmaps?
uint bufsize;
bufsize = mipMapCount > 1 ? linearSize * 2 : linearSize;
uint bufsize = mipMapCount > 1 ? linearSize * 2 : linearSize;
// get the buffer = bytes [128 - ]
const char *buffer = fp + 128;
@@ -188,7 +187,7 @@ uint Resource::getTextureDDS(const std::string& path, float *aspect_ratio)
}
}
if (height == 0){
if (height == 0 || bufsize == 0){
Log::Error("Invalid image in ressource %s", std::string(path).c_str());
return 0;
}

View File

@@ -309,14 +309,6 @@ void SessionVisitor::visit(FrameBufferSurface &)
xmlCurrent_->SetAttribute("type", "FrameBufferSurface");
}
void SessionVisitor::visit(MediaSurface &n)
{
// Node of a different type
xmlCurrent_->SetAttribute("type", "MediaSurface");
n.mediaPlayer()->accept(*this);
}
void SessionVisitor::visit(MediaPlayer &n)
{
XMLElement *newelement = xmlDoc_->NewElement("MediaPlayer");

View File

@@ -40,7 +40,6 @@ public:
void visit (Primitive& n) override;
void visit (Surface&) override;
void visit (ImageSurface& n) override;
void visit (MediaSurface& n) override;
void visit (FrameBufferSurface&) override;
void visit (LineStrip& n) override;
void visit (LineSquare&) override;

View File

@@ -13,8 +13,7 @@ using namespace tinyxml2;
Settings::Application Settings::application;
static string settingsFilename = "";
string settingsFilename = "";
void Settings::Save()
{

View File

@@ -206,7 +206,7 @@ Shader::Shader() : blending(BLEND_OPACITY)
id_ = BaseToolkit::uniqueId();
program_ = &simpleShadingProgram;
reset();
Shader::reset();
}

View File

@@ -56,7 +56,7 @@ Stream::Stream()
Stream::~Stream()
{
close();
Stream::close();
// cleanup opengl texture
if (textureindex_)

View File

@@ -302,8 +302,7 @@ size_t Timeline::fillSectionsArrays( float* const gaps, float* const fading)
if (gaps_.size() > 0) {
// indices to define [s e[] sections
size_t s = 0;
size_t e = MAX_TIMELINE_ARRAY;
size_t s = 0, e;
arraysize = 0;
auto it = gaps_.begin();

View File

@@ -18,6 +18,11 @@ struct TimeInterval
{
reset();
}
TimeInterval(const TimeInterval& b)
{
begin = b.begin;
end = b.end;
}
TimeInterval(GstClockTime a, GstClockTime b) : TimeInterval()
{
if ( a != GST_CLOCK_TIME_NONE && b != GST_CLOCK_TIME_NONE) {

View File

@@ -66,7 +66,7 @@ using namespace std;
#include "ImageProcessingShader.h"
#include "TextEditor.h"
static TextEditor editor;
TextEditor editor;
#include "UserInterfaceManager.h"
#define PLOT_ARRAY_SIZE 180
@@ -85,14 +85,14 @@ void SetNextWindowVisible(ImVec2 pos, ImVec2 size, float margin = 180.f);
const std::chrono::milliseconds timeout = std::chrono::milliseconds(4);
static std::atomic<bool> fileDialogPending_ = false;
static std::vector< std::future<std::string> > saveSessionFileDialogs;
static std::vector< std::future<std::string> > openSessionFileDialogs;
static std::vector< std::future<std::string> > importSessionFileDialogs;
static std::vector< std::future<std::string> > fileImportFileDialogs;
static std::vector< std::future<std::string> > recentFolderFileDialogs;
static std::vector< std::future<std::string> > recordFolderFileDialogs;
std::vector< std::future<std::string> > saveSessionFileDialogs;
std::vector< std::future<std::string> > openSessionFileDialogs;
std::vector< std::future<std::string> > importSessionFileDialogs;
std::vector< std::future<std::string> > fileImportFileDialogs;
std::vector< std::future<std::string> > recentFolderFileDialogs;
std::vector< std::future<std::string> > recordFolderFileDialogs;
static std::vector< std::future<FrameGrabber *> > _video_recorders;
std::vector< std::future<FrameGrabber *> > _video_recorders;
FrameGrabber *delayTrigger(FrameGrabber *g, std::chrono::milliseconds delay) {
std::this_thread::sleep_for (delay);
return g;
@@ -1181,7 +1181,7 @@ void UserInterface::RenderPreview()
else
openInitializeSystemLoopback = true;
}
else {
else if (webcam_emulator_ != nullptr) {
webcam_emulator_->stop();
webcam_emulator_ = nullptr;
}
@@ -1651,15 +1651,18 @@ void UserInterface::RenderMetrics(bool *p_open, int* p_corner, int *p_mode)
ImGui::Text("%s", GstToolkit::time_to_string(time_-start_time_1_, GstToolkit::TIME_STRING_FIXED).c_str());
ImGui::PopFont();
ImGui::SameLine(0, 10);
ImGui::PushID( "timermetric1" );
if (ImGuiToolkit::IconButton(12, 14))
start_time_1_ = time_; // reset timer 1
ImGui::PopID();
ImGuiToolkit::PushFont(ImGuiToolkit::FONT_LARGE);
ImGui::Text("%s", GstToolkit::time_to_string(time_-start_time_2_, GstToolkit::TIME_STRING_FIXED).c_str());
ImGui::PopFont();
ImGui::SameLine(0, 10);
ImGui::PushID( "timermetric2" );
if (ImGuiToolkit::IconButton(12, 14))
start_time_2_ = time_; // reset timer 2
ImGui::PopID();
}
else {
ImGuiToolkit::PushFont(ImGuiToolkit::FONT_MONO);
@@ -1987,7 +1990,7 @@ SourceController::SourceController() : min_width_(0.f), h_space_(0.f), v_space_(
timeline_height_(0.f), scrollbar_(0.f), mediaplayer_height_(0.f), buttons_width_(0.f),
active_label_(LABEL_AUTO_MEDIA_PLAYER), active_selection_(-1),
selection_context_menu_(false), selection_mediaplayer_(nullptr), selection_target_slower_(0), selection_target_faster_(0),
mediaplayer_active_(nullptr), mediaplayer_mode_(false), mediaplayer_slider_pressed_(false), mediaplayer_timeline_zoom_(1.f)
mediaplayer_active_(nullptr), mediaplayer_edit_fading_(false), mediaplayer_mode_(false), mediaplayer_slider_pressed_(false), mediaplayer_timeline_zoom_(1.f)
{
info_.setExtendedStringMode();
}

View File

@@ -11,7 +11,6 @@ class Primitive;
class Scene;
class Surface;
class ImageSurface;
class MediaSurface;
class FrameBufferSurface;
class LineStrip;
class LineSquare;
@@ -54,7 +53,6 @@ public:
// not mandatory for all others
virtual void visit (Surface&) {}
virtual void visit (ImageSurface&) {}
virtual void visit (MediaSurface&) {}
virtual void visit (FrameBufferSurface&) {}
virtual void visit (LineStrip&) {}
virtual void visit (LineSquare&) {}