diff --git a/src/importdxf.cpp b/src/importdxf.cpp index 2db8836f..f5c44086 100644 --- a/src/importdxf.cpp +++ b/src/importdxf.cpp @@ -1068,8 +1068,9 @@ public: } }; -static void ImportDwgDxf(const Platform::Path &filename, - std::function read) { +static void +ImportDwgDxf(const Platform::Path &filename, + const std::function &read) { std::string fileType = ToUpper(filename.Extension()); std::string data; diff --git a/src/lib.cpp b/src/lib.cpp index 052768d2..c16206b1 100644 --- a/src/lib.cpp +++ b/src/lib.cpp @@ -13,7 +13,7 @@ static System SYS; static int IsInit = 0; -void SolveSpace::Platform::FatalError(std::string message) { +void SolveSpace::Platform::FatalError(const std::string &message) { fprintf(stderr, "%s", message.c_str()); abort(); } diff --git a/src/platform/gui.h b/src/platform/gui.h index 50bebc3e..c5d082c1 100644 --- a/src/platform/gui.h +++ b/src/platform/gui.h @@ -102,7 +102,7 @@ std::string AcceleratorDescription(const KeyboardEvent &accel); #if defined(__GNUC__) __attribute__((noreturn)) #endif -void FatalError(std::string message); +void FatalError(const std::string &message); // A native settings store. class Settings { diff --git a/src/platform/guigtk.cpp b/src/platform/guigtk.cpp index 61181482..73fb01ec 100644 --- a/src/platform/guigtk.cpp +++ b/src/platform/guigtk.cpp @@ -50,7 +50,7 @@ static std::string PrepareMnemonics(std::string label) { return label; } -static std::string PrepareTitle(std::string title) { +static std::string PrepareTitle(const std::string &title) { return title + " — SolveSpace"; } @@ -58,7 +58,7 @@ static std::string PrepareTitle(std::string title) { // Fatal errors //----------------------------------------------------------------------------- -void FatalError(std::string message) { +void FatalError(const std::string &message) { fprintf(stderr, "%s", message.c_str()); abort(); } diff --git a/src/platform/guimac.mm b/src/platform/guimac.mm index 3d9108b4..0a1078df 100644 --- a/src/platform/guimac.mm +++ b/src/platform/guimac.mm @@ -84,7 +84,7 @@ crash_info_t crashAnnotation __attribute__((section("__DATA,__crash_info"))) = { CRASH_VERSION, NULL, NULL, NULL, NULL, NULL, NULL }; -void FatalError(std::string message) { +void FatalError(const std::string &message) { crashAnnotation.message = message.c_str(); abort(); } diff --git a/src/platform/guinone.cpp b/src/platform/guinone.cpp index 31f37dcd..85beae37 100644 --- a/src/platform/guinone.cpp +++ b/src/platform/guinone.cpp @@ -22,7 +22,7 @@ namespace Platform { // Fatal errors //----------------------------------------------------------------------------- -void FatalError(std::string message) { +void FatalError(const std::string &message) { fprintf(stderr, "%s", message.c_str()); #if !defined(LIBRARY) && defined(HAVE_BACKTRACE) diff --git a/src/platform/guiwin.cpp b/src/platform/guiwin.cpp index 40f20c51..b2ae8105 100644 --- a/src/platform/guiwin.cpp +++ b/src/platform/guiwin.cpp @@ -152,13 +152,12 @@ static int Clamp(int x, int a, int b) { bool handlingFatalError = false; -void FatalError(std::string message) { +void FatalError(const std::string &message) { // Indicate that we're handling a fatal error, to avoid re-entering application code // and potentially crashing even harder. handlingFatalError = true; - message += "\nGenerate debug report?"; - switch(MessageBoxW(NULL, Platform::Widen(message).c_str(), + switch(MessageBoxW(NULL, Platform::Widen(message + "\nGenerate debug report?").c_str(), L"Fatal error — SolveSpace", MB_ICONERROR|MB_TASKMODAL|MB_SETFOREGROUND|MB_TOPMOST| MB_OKCANCEL|MB_DEFBUTTON2)) { diff --git a/src/polygon.h b/src/polygon.h index b7c5a71e..a9a754c4 100644 --- a/src/polygon.h +++ b/src/polygon.h @@ -403,11 +403,10 @@ public: Vertex *AddVertex(const Vector &pos); Edge *AddEdge(const Vector &p0, const Vector &p1, uint32_t kind, uintptr_t data = 0); - void Generate( - std::function startFunc, - std::function nextFunc, - std::function aloneFunc, - std::function endFunc = [](){}); + void Generate(std::function const &startFunc, + std::function const &nextFunc, + std::function const &aloneFunc, + std::function const &endFunc = []() {}); void MakeFromEdges(const SEdgeList &sel); void MakeFromOutlines(const SOutlineList &sol); diff --git a/src/polyline.cpp b/src/polyline.cpp index bddf1ab7..64aef4e9 100644 --- a/src/polyline.cpp +++ b/src/polyline.cpp @@ -141,10 +141,9 @@ PolylineBuilder::Edge *PolylineBuilder::AddEdge(const Vector &p0, const Vector & } void PolylineBuilder::Generate( - std::function startFunc, - std::function nextFunc, - std::function aloneFunc, - std::function endFunc) { + std::function const &startFunc, + std::function const &nextFunc, + std::function const &aloneFunc, std::function const &endFunc) { bool found; bool loop = false; do { diff --git a/src/render/gl3shader.cpp b/src/render/gl3shader.cpp index 542eb97f..888779d3 100644 --- a/src/render/gl3shader.cpp +++ b/src/render/gl3shader.cpp @@ -162,7 +162,7 @@ void Shader::Clear() { glDeleteProgram(program); } -void Shader::SetUniformMatrix(const char *name, double *md) { +void Shader::SetUniformMatrix(const char *name, const double *md) { Enable(); float mf[16]; for(int i = 0; i < 16; i++) mf[i] = (float)md[i]; @@ -621,11 +621,11 @@ void EdgeRenderer::Draw(const SEdgeList &edges) { Remove(handle); } -void EdgeRenderer::SetModelview(double *matrix) { +void EdgeRenderer::SetModelview(const double *matrix) { shader.SetUniformMatrix("modelview", matrix); } -void EdgeRenderer::SetProjection(double *matrix) { +void EdgeRenderer::SetProjection(const double *matrix) { shader.SetUniformMatrix("projection", matrix); } @@ -833,11 +833,11 @@ void OutlineRenderer::Draw(const SOutlineList &outlines, Canvas::DrawOutlinesAs Remove(handle); } -void OutlineRenderer::SetModelview(double *matrix) { +void OutlineRenderer::SetModelview(const double *matrix) { shader.SetUniformMatrix("modelview", matrix); } -void OutlineRenderer::SetProjection(double *matrix) { +void OutlineRenderer::SetProjection(const double *matrix) { shader.SetUniformMatrix("projection", matrix); } @@ -1037,14 +1037,14 @@ bool IndexedMeshRenderer::NeedsTexture() const { selectedShader == &pointShader; } -void IndexedMeshRenderer::SetModelview(double *matrix) { +void IndexedMeshRenderer::SetModelview(const double *matrix) { colShader.SetUniformMatrix("modelview", matrix); texShader.SetUniformMatrix("modelview", matrix); texaShader.SetUniformMatrix("modelview", matrix); pointShader.SetUniformMatrix("modelview", matrix); } -void IndexedMeshRenderer::SetProjection(double *matrix) { +void IndexedMeshRenderer::SetProjection(const double *matrix) { colShader.SetUniformMatrix("projection", matrix); texShader.SetUniformMatrix("projection", matrix); texaShader.SetUniformMatrix("projection", matrix); diff --git a/src/render/gl3shader.h b/src/render/gl3shader.h index ae5ed33d..1831e792 100644 --- a/src/render/gl3shader.h +++ b/src/render/gl3shader.h @@ -74,7 +74,7 @@ public: const std::vector> &locations = {}); void Clear(); - void SetUniformMatrix(const char *name, double *md); + void SetUniformMatrix(const char *name, const double *md); void SetUniformVector(const char *name, const Vector &v); void SetUniformVector(const char *name, const Vector4f &v); void SetUniformColor(const char *name, RgbaColor c); @@ -163,8 +163,8 @@ public: void Draw(const Handle &handle); void Draw(const SEdgeList &edges); - void SetModelview(double *matrix); - void SetProjection(double *matrix); + void SetModelview(const double *matrix); + void SetProjection(const double *matrix); void SetStroke(const Canvas::Stroke &stroke, double pixel); }; @@ -203,8 +203,8 @@ public: void Draw(const Handle &handle, Canvas::DrawOutlinesAs mode); void Draw(const SOutlineList &outlines, Canvas::DrawOutlinesAs mode); - void SetModelview(double *matrix); - void SetProjection(double *matrix); + void SetModelview(const double *matrix); + void SetProjection(const double *matrix); void SetStroke(const Canvas::Stroke &stroke, double pixel); }; @@ -252,8 +252,8 @@ public: void Draw(const Handle &handle); void Draw(const SIndexedMesh &mesh); - void SetModelview(double *matrix); - void SetProjection(double *matrix); + void SetModelview(const double *matrix); + void SetProjection(const double *matrix); bool NeedsTexture() const; diff --git a/src/render/render.cpp b/src/render/render.cpp index 3ef7171b..ca2a26eb 100644 --- a/src/render/render.cpp +++ b/src/render/render.cpp @@ -444,12 +444,11 @@ void ObjectPicker::DrawPixmap(std::shared_ptr pm, DrawQuad(o, o.Plus(u), o.Plus(u).Plus(v), o.Plus(v), hcf); } -bool ObjectPicker::Pick(std::function drawFn) { +bool ObjectPicker::Pick(const std::function &drawFn) { minDistance = VERY_POSITIVE; maxZIndex = INT_MIN; drawFn(); return minDistance < selRadius; } - } diff --git a/src/render/render.h b/src/render/render.h index 825ca8d1..649256e7 100644 --- a/src/render/render.h +++ b/src/render/render.h @@ -261,7 +261,7 @@ public: void DoQuad(const Vector &a, const Vector &b, const Vector &c, const Vector &d, int zIndex, int comparePosition = 0); - bool Pick(std::function drawFn); + bool Pick(const std::function &drawFn); }; // A canvas that renders onto a 2d surface, performing z-index sorting, occlusion testing, etc, diff --git a/src/resource.cpp b/src/resource.cpp index 6e9ce727..7b19081e 100644 --- a/src/resource.cpp +++ b/src/resource.cpp @@ -918,7 +918,7 @@ Vector VectorFont::GetExtents(double forCapHeight, const std::string &str) { } void VectorFont::Trace(double forCapHeight, Vector o, Vector u, Vector v, const std::string &str, - std::function traceEdge) { + const std::function &traceEdge) { ssassert(!IsEmpty(), "Expected a loaded font"); double scale = (forCapHeight / capHeight); @@ -945,7 +945,7 @@ void VectorFont::Trace(double forCapHeight, Vector o, Vector u, Vector v, const } void VectorFont::Trace(double forCapHeight, Vector o, Vector u, Vector v, const std::string &str, - std::function traceEdge, const Camera &camera) { + const std::function &traceEdge, const Camera &camera) { ssassert(!IsEmpty(), "Expected a loaded font"); // Perform grid-fitting only when the text is parallel to the view plane. diff --git a/src/resource.h b/src/resource.h index 6c14dad8..bb0e1c7a 100644 --- a/src/resource.h +++ b/src/resource.h @@ -103,9 +103,9 @@ public: Vector GetExtents(double forCapHeight, const std::string &str); void Trace(double forCapHeight, Vector o, Vector u, Vector v, const std::string &str, - std::function traceEdge); + const std::function &traceEdge); void Trace(double forCapHeight, Vector o, Vector u, Vector v, const std::string &str, - std::function traceEdge, const Camera &camera); + const std::function &traceEdge, const Camera &camera); }; #endif