mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-10-04 06:11:02 +00:00
* Stop Malformed Network Responses from Crashing the App Duet, MKS and UltiMaker parsed print host replies with boost read_json inside the HTTP completion callback with no try, so an HTML or truncated reply threw out of the Physical Printer Test button and terminated the app, or killed the upload queue thread. The five identical copies of the parser (ESP3D's and Flashforge's were unused) are replaced by one shared PrintHost::get_err_code_from_body that reports a non-JSON reply as an error. The upload queue now catches a failing job per job, so one bad upload no longer leaves later jobs queued forever. Flashforge read material station slots with nlohmann value(), which throws on off-type fields or non-object entries. The parsing moves into Flashforge::parse_material_slots, which reads fields leniently with the existing try_parse_json_int and skips bad entries. UserManager::parse_json parsed the payload before its try block; the parse now happens inside it. * Keep UploadFinished Paired with UploadStarted When an Upload Throws The exception from a throwing upload was caught around perform_job, so the UploadFinished lifecycle event was skipped and plugins saw an upload start that never finished. The catch now sits around the upload call. The error is reported through the job's error callback and UploadFinished is fired with an error code, as for any other failed upload. The worker keeps running for the next job. The started, upload and finished sequence moved to PrintHostJobQueue::upload_job so it can be tested without the dialog.
24 lines
734 B
C++
24 lines
734 B
C++
#include <catch2/catch_all.hpp>
|
|
|
|
#include <string>
|
|
|
|
#include "slic3r/GUI/UserManager.hpp"
|
|
|
|
using namespace Slic3r;
|
|
|
|
TEST_CASE("User message that is not JSON is rejected without throwing", "[UserManager]")
|
|
{
|
|
const std::string payload = GENERATE(as<std::string>{}, "not json", "", "<html></html>", "{\"bind\":");
|
|
UserManager manager;
|
|
int result = 0;
|
|
REQUIRE_NOTHROW(result = manager.parse_json(payload));
|
|
CHECK(result == -1);
|
|
}
|
|
|
|
TEST_CASE("User message without a successful bind is ignored", "[UserManager]")
|
|
{
|
|
const std::string payload = GENERATE(as<std::string>{}, "{}", R"({"bind":{"command":"unbind"}})", R"({"bind":"bind"})", "[1]");
|
|
UserManager manager;
|
|
CHECK(manager.parse_json(payload) == -1);
|
|
}
|