Compilation with an environment variable SLIC3R_HAS_BROKEN_CROAK set
will force the perl confess / croak called from a C++ code to print an error message and exit. There is a bug in some Strawberry Perl instalations leading to an interpreter hang up and an exit with a reasonable message is better than that.
This commit is contained in:
parent
22ca927f12
commit
eb61373b69
3 changed files with 53 additions and 0 deletions
|
@ -42,6 +42,14 @@ if ($ENV{SLIC3R_GUI})
|
|||
# push @early_includes, qw(slic3r/GUI/wxinit.h);
|
||||
}
|
||||
|
||||
if ($ENV{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.
|
||||
push @cflags, qw(-DSLIC3R_HAS_BROKEN_CROAK)
|
||||
}
|
||||
|
||||
# search for Boost in a number of places
|
||||
my @boost_include = ();
|
||||
if (defined $ENV{BOOST_INCLUDEDIR}) {
|
||||
|
|
|
@ -1,3 +1,37 @@
|
|||
#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
|
||||
|
||||
#include <xsinit.h>
|
||||
|
||||
void
|
||||
|
@ -26,3 +60,5 @@ confess_at(const char *file, int line, const char *func,
|
|||
LEAVE;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -153,4 +153,13 @@ SV* polynode2perl(const ClipperLib::PolyNode& node);
|
|||
|
||||
}
|
||||
|
||||
#ifdef SLIC3R_HAS_BROKEN_CROAK
|
||||
#undef croak
|
||||
#ifdef _MSC_VER
|
||||
#define croak(...) confess_at(__FILE__, __LINE__, __FUNCTION__, __VA_ARGS__)
|
||||
#else
|
||||
#define croak(...) confess_at(__FILE__, __LINE__, __func__, __VA_ARGS__)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue