Skip to content

Commit

Permalink
writing debug.html in temp folder
Browse files Browse the repository at this point in the history
writing debug.html in the current folder (in case of build the program data) makes it read only and no write modifications are allowed, hence crash. Now it is written in temp foilder of the computer where writing the file is also allowed.
  • Loading branch information
saumyaj3 committed Apr 26, 2024
1 parent 8b1757e commit 9f39bf0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/utils/SVG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ SVG::SVG(std::string filename, AABB aabb, double scale, Point2LL canvas_size, Co
out_ = fopen(filename.c_str(), "w");
if (! out_)
{
spdlog::error("The file %s could not be opened for writing.", filename);
spdlog::error("The file {} could not be opened for writing.", filename);
}
if (output_is_html_)
{
Expand Down
8 changes: 6 additions & 2 deletions src/utils/polygonUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,15 @@
#include "utils/linearAlg2D.h"

#ifdef DEBUG
#include <filesystem>
#include <spdlog/spdlog.h>

#include "utils/AABB.h"
#include "utils/SVG.h"
#endif

namespace fs = std::filesystem;

namespace cura
{

Expand Down Expand Up @@ -693,12 +696,13 @@ ClosestPolygonPoint PolygonUtils::ensureInsideOrOutside(
static bool has_run = false;
if (! has_run)
{
fs::path const debug_file_name = fs::temp_directory_path() / "debug.html";
try
{
int offset_performed = offset / 2;
AABB aabb(polygons);
aabb.expand(std::abs(preferred_dist_inside) * 2);
SVG svg("debug.html", aabb);
SVG svg(debug_file_name.string(), aabb);
svg.writeComment("Original polygon in black");
svg.writePolygons(polygons, SVG::Color::BLACK);
for (auto poly : polygons)
Expand Down Expand Up @@ -729,7 +733,7 @@ ClosestPolygonPoint PolygonUtils::ensureInsideOrOutside(
catch (...)
{
}
spdlog::error("Clipper::offset failed. See generated debug.html! Black is original Blue is offsetted polygon");
spdlog::error("Clipper::offset failed. See generated {}! Black is original Blue is offsetted polygon", debug_file_name.string());
has_run = true;
}
#endif
Expand Down

0 comments on commit 9f39bf0

Please sign in to comment.