Files
OrcaSlicer-bambulab/xs/src/libslic3r/utils.cpp
T

65 lines
1.4 KiB
C++
Raw Normal View History

#ifdef SLIC3R_HAS_BROKEN_CROAK
// Some Strawberry Perl builds (mainly the latest 64bit builds) have a broken mechanism
// for emiting Perl exception after handling a C++ exception. Perl interpreter
// simply hangs. Better to show a message box in that case and stop the application.
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#ifdef WIN32
#include <Windows.h>
#endif
void confess_at(const char *file, int line, const char *func, const char *format, ...)
{
char dest[1024*8];
va_list argptr;
va_start(argptr, format);
vsprintf(dest, format, argptr);
va_end(argptr);
strcat(dest, "\r\n Closing the application.\r\n");
#ifdef WIN32
::MessageBoxA(NULL, dest, "Slic3r Prusa Edition", MB_OK | MB_ICONERROR);
#endif;
// Give up.
printf(dest);
exit(-1);
}
#else
2015-12-08 00:39:54 +01:00
#include <xsinit.h>
2013-09-09 21:40:57 +02:00
void
confess_at(const char *file, int line, const char *func,
const char *pat, ...)
{
#ifdef SLIC3RXS
2013-09-09 21:40:57 +02:00
va_list args;
SV *error_sv = newSVpvf("Error in function %s at %s:%d: ", func,
file, line);
va_start(args, pat);
sv_vcatpvf(error_sv, pat, &args);
va_end(args);
sv_catpvn(error_sv, "\n\t", 2);
dSP;
ENTER;
SAVETMPS;
PUSHMARK(SP);
XPUSHs( sv_2mortal(error_sv) );
PUTBACK;
call_pv("Carp::confess", G_DISCARD);
FREETMPS;
LEAVE;
#endif
2013-09-09 21:40:57 +02:00
}
#endif