diff --git a/backend/library.c b/backend/library.c index f2d93749..5c258fc1 100644 --- a/backend/library.c +++ b/backend/library.c @@ -1282,25 +1282,36 @@ int ZBarcode_Buffer(struct zint_symbol *symbol, int rotate_angle) { int ZBarcode_Encode_and_Print(struct zint_symbol *symbol, unsigned char *input, int length, int rotate_angle) { int error_number; + int first_err; error_number = ZBarcode_Encode(symbol, input, length); - if (error_number != 0) { + if (error_number >= 5) { return error_number; } + first_err = error_number; error_number = ZBarcode_Print(symbol, rotate_angle); + if (error_number == 0) { + error_number = first_err; + } return error_number; } int ZBarcode_Encode_and_Buffer(struct zint_symbol *symbol, unsigned char *input, int length, int rotate_angle) { int error_number; + int first_err; error_number = ZBarcode_Encode(symbol, input, length); - if (error_number != 0) { + if (error_number >= 5) { return error_number; } + first_err = error_number; error_number = ZBarcode_Buffer(symbol, rotate_angle); + if (error_number == 0) { + error_number = first_err; + } + return error_number; } @@ -1365,24 +1376,38 @@ int ZBarcode_Encode_File(struct zint_symbol *symbol, char *filename) { int ZBarcode_Encode_File_and_Print(struct zint_symbol *symbol, char *filename, int rotate_angle) { int error_number; + int first_err; error_number = ZBarcode_Encode_File(symbol, filename); - if (error_number != 0) { + if (error_number >= 5) { return error_number; } - - return ZBarcode_Print(symbol, rotate_angle); + + first_err = error_number; + error_number = ZBarcode_Print(symbol, rotate_angle); + if (error_number == 0) { + error_number = first_err; + } + + return error_number; } int ZBarcode_Encode_File_and_Buffer(struct zint_symbol *symbol, char *filename, int rotate_angle) { int error_number; + int first_err; error_number = ZBarcode_Encode_File(symbol, filename); - if (error_number != 0) { + if (error_number >= 5) { return error_number; } + + first_err = error_number; + error_number = ZBarcode_Buffer(symbol, rotate_angle); + if (error_number == 0) { + error_number = first_err; + } - return ZBarcode_Buffer(symbol, rotate_angle); + return error_number; } /* diff --git a/backend_qt/qzint.cpp b/backend_qt/qzint.cpp index d7222ed3..5a984119 100644 --- a/backend_qt/qzint.cpp +++ b/backend_qt/qzint.cpp @@ -279,7 +279,7 @@ namespace Zint { strcpy(m_zintSymbol->fgcolour, fgcol.data()); strcpy(m_zintSymbol->bgcolour, bgcol.data()); m_error = ZBarcode_Encode_and_Print(m_zintSymbol, (unsigned char*) bstr.data(), bstr.length(), 0); - if (m_error != 0) { + if (m_error >= 5) { m_lastError = m_zintSymbol->errtxt; return false; } else {