fixed pvs-studio warnings
This commit is contained in:
parent
f9bd8c1184
commit
d4d380cc9f
@ -26,9 +26,7 @@ class RBTree {
|
|||||||
}
|
}
|
||||||
|
|
||||||
~Node(){
|
~Node(){
|
||||||
if(left != nullptr)
|
|
||||||
delete left;
|
delete left;
|
||||||
if(right != nullptr)
|
|
||||||
delete right;
|
delete right;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
#include "UsefulException.hpp"
|
#include "UsefulException.hpp"
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
UsefulException_::UsefulException_(std::string _message, std::string _file, std::string _func, int _line_n)
|
UsefulException_::UsefulException_(const std::string& _message, const std::string& _file, const std::string& _func, int _line_n)
|
||||||
: message(_message), file(_file), function(_func), line_n(_line_n)
|
: message(_message), file(_file), function(_func), line_n(_line_n)
|
||||||
{
|
{
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
|
|||||||
@ -13,7 +13,7 @@ class UsefulException_ : public std::exception {
|
|||||||
std::string complete_text;
|
std::string complete_text;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
UsefulException_(std::string msg, std::string _file, std::string _func, int line_n);
|
UsefulException_(const std::string& msg, const std::string& _file, const std::string& _func, int line_n);
|
||||||
|
|
||||||
virtual char const* what() const noexcept;
|
virtual char const* what() const noexcept;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
#include "UsefulException.hpp"
|
#include "UsefulException.hpp"
|
||||||
#include "../dependencies/kerep/src/base/base.h"
|
#include "../dependencies/kerep/src/base/base.h"
|
||||||
|
|
||||||
std::string _format(const std::string format_str, size_t args_count, ...){
|
std::string _format(const std::string& format_str, const size_t args_count, ...){
|
||||||
va_list vl;
|
va_list vl;
|
||||||
va_start(vl, args_count);
|
va_start(vl, args_count);
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
|
|||||||
@ -3,5 +3,5 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include "../dependencies/kerep/src/base/std.h"
|
#include "../dependencies/kerep/src/base/std.h"
|
||||||
|
|
||||||
std::string _format(const std::string format_str, size_t args_count, ...);
|
std::string _format(const std::string& format_str, const size_t args_count, ...);
|
||||||
#define format(FORMAT_STR, ARGS...) _format(FORMAT_STR, count_args(ARGS) ,##ARGS)
|
#define format(FORMAT_STR, ARGS...) _format(FORMAT_STR, count_args(ARGS) ,##ARGS)
|
||||||
|
|||||||
@ -35,7 +35,7 @@ void GraphEditor::drawNode(const GraphModel::Node& node){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* items[]={
|
static const char* items[]={
|
||||||
"static","input", "output"
|
"static","input", "output"
|
||||||
};
|
};
|
||||||
static int selected_item_i = 0;
|
static int selected_item_i = 0;
|
||||||
@ -81,15 +81,15 @@ void GraphEditor::drawNode(const GraphModel::Node& node){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
GraphModel::Node* GraphEditor::CreateExampleNode(std::string title){
|
GraphModel::Node* GraphEditor::CreateExampleNode(const std::string& node_title){
|
||||||
GraphModel::Node* n = graph.createNode(GraphModel::Node(graph.id_gen.getNext(), title));
|
GraphModel::Node* n = graph.createNode(GraphModel::Node(graph.id_gen.getNext(), node_title));
|
||||||
graph.createAttribute(GraphModel::Attribute(graph.id_gen.getNext(), n, GraphModel::Attribute::Type::Input, "In"));
|
graph.createAttribute(GraphModel::Attribute(graph.id_gen.getNext(), n, GraphModel::Attribute::Type::Input, "In"));
|
||||||
graph.createAttribute(GraphModel::Attribute(graph.id_gen.getNext(), n, GraphModel::Attribute::Type::Output, "Out"));
|
graph.createAttribute(GraphModel::Attribute(graph.id_gen.getNext(), n, GraphModel::Attribute::Type::Output, "Out"));
|
||||||
graph.createAttribute(GraphModel::Attribute(graph.id_gen.getNext(), n, GraphModel::Attribute::Type::Static, "Static"));
|
graph.createAttribute(GraphModel::Attribute(graph.id_gen.getNext(), n, GraphModel::Attribute::Type::Static, "Static"));
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
GraphEditor::GraphEditor(std::string _title)
|
GraphEditor::GraphEditor(const std::string& _title)
|
||||||
: title(_title)
|
: title(_title)
|
||||||
{
|
{
|
||||||
// CreateExampleNode("Node A");
|
// CreateExampleNode("Node A");
|
||||||
@ -153,8 +153,10 @@ void GraphEditor::draw(){
|
|||||||
GraphModel::id_t from_attr_id, to_attr_id;
|
GraphModel::id_t from_attr_id, to_attr_id;
|
||||||
if (ImNodes::IsLinkCreated(&from_attr_id, &to_attr_id))
|
if (ImNodes::IsLinkCreated(&from_attr_id, &to_attr_id))
|
||||||
{
|
{
|
||||||
if(!graph.tryCreateEdge(from_attr_id, to_attr_id, nullptr))
|
if(!graph.tryCreateEdge(from_attr_id, to_attr_id, nullptr)){
|
||||||
|
ImGui::End();
|
||||||
throw UsefulException(format("can't create edge from attribute %i to attribute %i", from_attr_id, to_attr_id));
|
throw UsefulException(format("can't create edge from attribute %i to attribute %i", from_attr_id, to_attr_id));
|
||||||
|
}
|
||||||
std::cout<<"EDGES:\n";
|
std::cout<<"EDGES:\n";
|
||||||
std::cout<<graph.getEdges().generateGraphVizCode()<<std::endl;
|
std::cout<<graph.getEdges().generateGraphVizCode()<<std::endl;
|
||||||
}
|
}
|
||||||
@ -163,8 +165,10 @@ void GraphEditor::draw(){
|
|||||||
GraphModel::id_t edge_id;
|
GraphModel::id_t edge_id;
|
||||||
if (ImNodes::IsLinkDestroyed(&edge_id))
|
if (ImNodes::IsLinkDestroyed(&edge_id))
|
||||||
{
|
{
|
||||||
if(!graph.tryDeleteEdge(edge_id))
|
if(!graph.tryDeleteEdge(edge_id)){
|
||||||
|
ImGui::End();
|
||||||
throw UsefulException(format("can't delete edge with id %i", edge_id));
|
throw UsefulException(format("can't delete edge with id %i", edge_id));
|
||||||
|
}
|
||||||
std::cout<<"EDGES:\n";
|
std::cout<<"EDGES:\n";
|
||||||
std::cout<<graph.getEdges().generateGraphVizCode()<<std::endl;
|
std::cout<<graph.getEdges().generateGraphVizCode()<<std::endl;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,10 +13,10 @@ class GraphEditor {
|
|||||||
GraphModel::Graph graph;
|
GraphModel::Graph graph;
|
||||||
|
|
||||||
void drawNode(const GraphModel::Node& node);
|
void drawNode(const GraphModel::Node& node);
|
||||||
GraphModel::Node* CreateExampleNode(std::string title);
|
GraphModel::Node* CreateExampleNode(const std::string& title);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GraphEditor(std::string _title);
|
GraphEditor(const std::string& _title);
|
||||||
|
|
||||||
void draw();
|
void draw();
|
||||||
void show();
|
void show();
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
namespace GraphC::gui {
|
namespace GraphC::gui {
|
||||||
|
|
||||||
SDLException_::SDLException_(std::string _file, std::string _func, int _line_n)
|
SDLException_::SDLException_(const std::string& _file,const std::string& _func, int _line_n)
|
||||||
: UsefulException_(SDL_GetError(), _file, _func, _line_n)
|
: UsefulException_(SDL_GetError(), _file, _func, _line_n)
|
||||||
{
|
{
|
||||||
SDL_ClearError();
|
SDL_ClearError();
|
||||||
|
|||||||
@ -6,9 +6,9 @@ namespace GraphC::gui {
|
|||||||
|
|
||||||
#define SDLException() SDLException_(__FILE__, __func__, __LINE__)
|
#define SDLException() SDLException_(__FILE__, __func__, __LINE__)
|
||||||
|
|
||||||
class SDLException_ : UsefulException_ {
|
class SDLException_ : public UsefulException_ {
|
||||||
public:
|
public:
|
||||||
SDLException_(std::string _file, std::string _func, int line_n);
|
SDLException_(const std::string& _file, const std::string& _func, int line_n);
|
||||||
};
|
};
|
||||||
|
|
||||||
#define SDL_TRY_ZERO(FUNC_CALL) if(FUNC_CALL != 0) throw SDLException();
|
#define SDL_TRY_ZERO(FUNC_CALL) if(FUNC_CALL != 0) throw SDLException();
|
||||||
|
|||||||
@ -9,8 +9,8 @@ f32 GUI::getDPI(){
|
|||||||
SDL_GL_GetDrawableSize(sdl_window, &w, &h);
|
SDL_GL_GetDrawableSize(sdl_window, &w, &h);
|
||||||
int sim_w=0, sim_h=0;
|
int sim_w=0, sim_h=0;
|
||||||
SDL_GetWindowSize(sdl_window, &sim_w, &sim_h);
|
SDL_GetWindowSize(sdl_window, &sim_w, &sim_h);
|
||||||
f32 wdpi=w/sim_w;
|
f32 wdpi=(f32)w / sim_w;
|
||||||
f32 hdpi=h/sim_h;
|
f32 hdpi=(f32)h / sim_h;
|
||||||
f32 dpi=SDL_sqrtf(wdpi*wdpi + hdpi*hdpi);
|
f32 dpi=SDL_sqrtf(wdpi*wdpi + hdpi*hdpi);
|
||||||
return dpi;
|
return dpi;
|
||||||
}
|
}
|
||||||
@ -117,7 +117,7 @@ void GUI::draw_frame(){
|
|||||||
|
|
||||||
// Draw UI
|
// Draw UI
|
||||||
draw_bg_window();
|
draw_bg_window();
|
||||||
draw_debug_window(io, &main_loop_wait_for_input);
|
draw_debug_window(io);
|
||||||
node_editor->draw();
|
node_editor->draw();
|
||||||
|
|
||||||
// Rendering
|
// Rendering
|
||||||
@ -235,10 +235,10 @@ void GUI::draw_bg_window(){
|
|||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GUI::draw_debug_window(ImGuiIO& io, bool* main_loop_wait_for_input){
|
void GUI::draw_debug_window(ImGuiIO& io){
|
||||||
ImGui::Begin("Debug Options");
|
ImGui::Begin("Debug Options");
|
||||||
ImGui::ColorEdit3("clear_color", (float*)&clear_color);
|
ImGui::ColorEdit3("clear_color", (float*)&clear_color);
|
||||||
ImGui::Checkbox("main_loop_wait_for_input", main_loop_wait_for_input);
|
ImGui::Checkbox("main_loop_wait_for_input", &main_loop_wait_for_input);
|
||||||
ImGui::Text("Application average %.3f ms/frame (%.2f FPS)", 1000.0f / io.Framerate, io.Framerate);
|
ImGui::Text("Application average %.3f ms/frame (%.2f FPS)", 1000.0f / io.Framerate, io.Framerate);
|
||||||
ImGui::Checkbox("Demo Window", &show_demo_window);
|
ImGui::Checkbox("Demo Window", &show_demo_window);
|
||||||
ImGui::Checkbox("Metrics/Debug Window", &show_metrics_window);
|
ImGui::Checkbox("Metrics/Debug Window", &show_metrics_window);
|
||||||
|
|||||||
@ -34,8 +34,8 @@ private:
|
|||||||
bool main_loop_wait_for_input=true;
|
bool main_loop_wait_for_input=true;
|
||||||
bool show_demo_window = false;
|
bool show_demo_window = false;
|
||||||
bool show_metrics_window = false;
|
bool show_metrics_window = false;
|
||||||
SDL_Window* sdl_window;
|
SDL_Window* sdl_window = nullptr;
|
||||||
SDL_GLContext gl_context;
|
SDL_GLContext gl_context = nullptr;
|
||||||
GraphEditor* node_editor = nullptr;
|
GraphEditor* node_editor = nullptr;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -48,7 +48,7 @@ private:
|
|||||||
void destroy();
|
void destroy();
|
||||||
void poll_events(u16& frame_updates_requested, bool wait);
|
void poll_events(u16& frame_updates_requested, bool wait);
|
||||||
void draw_frame();
|
void draw_frame();
|
||||||
void draw_debug_window(ImGuiIO &io, bool *main_loop_wait_for_input);
|
void draw_debug_window(ImGuiIO &io);
|
||||||
void draw_bg_window();
|
void draw_bg_window();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -27,7 +27,7 @@ int main(const int argc, const char* const* argv){
|
|||||||
std::cerr<<"Catched exception message: "<<msg<<std::endl;
|
std::cerr<<"Catched exception message: "<<msg<<std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
catch(std::string& msg){
|
catch(const std::string& msg){
|
||||||
std::cerr<<"Catched exception message: "<<msg<<std::endl;
|
std::cerr<<"Catched exception message: "<<msg<<std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user