Skip to content

Commit d457308

Browse files
committed
headless messaging fixes
1 parent 228ebcc commit d457308

File tree

2 files changed

+20
-10
lines changed

2 files changed

+20
-10
lines changed

include/polyscope/render/mock_opengl/mock_gl_engine.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,9 @@ class MockGLEngine : public Engine {
328328
virtual void shutdown() override;
329329
void checkError(bool fatal = false) override;
330330

331+
// mock backend is always headless
332+
virtual bool isHeadless() override { return true; }
333+
331334
void swapDisplayBuffers() override;
332335
std::vector<unsigned char> readDisplayBuffer() override;
333336

src/messages.cpp

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,11 @@ void terminatingError(std::string message) {
233233
std::cout << options::printPrefix << "[ERROR] " << message << std::endl;
234234
}
235235

236-
auto func = std::bind(buildErrorUI, message, true);
237-
pushContext(func, false);
236+
// Enter a modal UI loop showing the warning
237+
if (!isHeadless()) { // don't do it if running headless
238+
auto func = std::bind(buildErrorUI, message, true);
239+
pushContext(func, false);
240+
}
238241

239242
// Quit the program
240243
shutdown(true);
@@ -243,6 +246,13 @@ void terminatingError(std::string message) {
243246

244247
void warning(std::string baseMessage, std::string detailMessage) {
245248

249+
// print to stdout
250+
if (options::verbosity > 0) {
251+
std::cout << options::printPrefix << "[WARNING] " << baseMessage;
252+
if (detailMessage != "") std::cout << " --- " << detailMessage;
253+
std::cout << std ::endl;
254+
}
255+
246256
// Look for a message with the same name
247257
bool found = false;
248258
for (WarningMessage& w : warningMessages) {
@@ -268,16 +278,13 @@ void showDelayedWarnings() {
268278
showingWarning = true;
269279
WarningMessage& currMessage = warningMessages.front();
270280

271-
if (options::verbosity > 0) {
272-
std::cout << options::printPrefix << "[WARNING] " << currMessage.baseMessage;
273-
if (currMessage.detailMessage != "") std::cout << " --- " << currMessage.detailMessage;
274-
if (currMessage.repeatCount > 0) std::cout << " (and " << currMessage.repeatCount << " similar messages).";
275-
std::cout << std ::endl;
281+
// Enter a modal UI loop showing the warning
282+
if (!isHeadless()) { // don't do it if running headless
283+
auto func =
284+
std::bind(buildWarningUI, currMessage.baseMessage, currMessage.detailMessage, currMessage.repeatCount);
285+
pushContext(func, false);
276286
}
277287

278-
auto func = std::bind(buildWarningUI, currMessage.baseMessage, currMessage.detailMessage, currMessage.repeatCount);
279-
pushContext(func, false);
280-
281288
warningMessages.pop_front();
282289
showingWarning = false;
283290
}

0 commit comments

Comments
 (0)