Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions captbackend/Core/CaptPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ std::optional<Capt::Protocol::ExtendedStatus> CaptPrinter::WritePage(StopTokenTy
}

// Has value if error
std::optional<Capt::Protocol::ExtendedStatus> CaptPrinter::WaitLastPage(StopTokenType stopToken, Capt::Utility::BufferedPage& page) {
std::optional<Capt::Protocol::ExtendedStatus> CaptPrinter::WaitLastPage(StopTokenType stopToken, Capt::Utility::BufferedPage& page, unsigned pageNum) {
while (!stopToken.stop_requested()) {
std::this_thread::sleep_for(1s);
auto status = this->WaitPrintEnd(stopToken);
auto status = this->WaitPrintEnd(stopToken, pageNum);
if (!status) {
return std::nullopt;
}
Expand All @@ -118,6 +118,10 @@ std::optional<Capt::Protocol::ExtendedStatus> CaptPrinter::WaitLastPage(StopToke
return std::nullopt;
}

std::optional<Capt::Protocol::ExtendedStatus> CaptPrinter::WaitLastPage(StopTokenType stopToken, Capt::Utility::BufferedPage& page) {
return CaptPrinter::WaitLastPage(stopToken, page, 0);
}

bool CaptPrinter::Print(StopTokenType stopToken, RasterStreambuf& rasterStr) {
unsigned page = 0;
Capt::Utility::BufferedPage prevPage;
Expand Down Expand Up @@ -150,7 +154,7 @@ bool CaptPrinter::Print(StopTokenType stopToken, RasterStreambuf& rasterStr) {

Log::Info() << "Waiting for last page...";
if (page != 0) {
auto res = this->WaitLastPage(stopToken, prevPage);
auto res = this->WaitLastPage(stopToken, prevPage, page);
if (res.has_value()) {
Log::Debug() << "WaitLastPage failed: " << *res;
Log::Critical() << "Failed to write page (" << StatusMessage(*res) << ')';
Expand Down
1 change: 1 addition & 0 deletions captbackend/Core/CaptPrinter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class CaptPrinter : public Capt::BasicCaptPrinter<StopToken> {
std::optional<Capt::Protocol::ExtendedStatus> WritePage(StopTokenType stopToken, Capt::Utility::BufferedPage& page, Capt::Utility::BufferedPage* prev);

// Has value if error
std::optional<Capt::Protocol::ExtendedStatus> WaitLastPage(StopTokenType stopToken, Capt::Utility::BufferedPage& page, unsigned pageNum);
std::optional<Capt::Protocol::ExtendedStatus> WaitLastPage(StopTokenType stopToken, Capt::Utility::BufferedPage& page);

bool Print(StopTokenType stopToken, RasterStreambuf& rasterStr);
Expand Down
Loading