Removes some CryAssert methods that are not being used because we redirected it all to AZ_Assert
Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>
This commit is contained in:
@@ -166,18 +166,3 @@
|
||||
#ifdef LoadCursor
|
||||
#undef LoadCursor
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef _DEBUG
|
||||
#if !defined(AZ_PLATFORM_LINUX)
|
||||
#ifdef assert
|
||||
#undef assert
|
||||
#if defined(USE_AZ_ASSERT)
|
||||
#define assert(condition) AZ_Assert(condition, "")
|
||||
#else
|
||||
#define assert CRY_ASSERT
|
||||
#endif
|
||||
#endif // !defined(AZ_PLATFORM_LINUX)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
@@ -37,26 +37,10 @@ namespace SandboxEditor
|
||||
|
||||
bool StartupTraceHandler::OnPreAssert(const char* fileName, int line, const char* func, const char* message)
|
||||
{
|
||||
// Asserts are more fatal than errors, and need to be displayed right away.
|
||||
// After the assert occurs, nothing else may be functional enough to collect and display messages.
|
||||
|
||||
// Only use Cry message boxes if we aren't using native dialog boxes
|
||||
#ifndef USE_AZ_ASSERT
|
||||
if (message == nullptr || message[0] == 0)
|
||||
{
|
||||
AZStd::string emptyText = AZStd::string::format("Assertion failed in %s %s:%i", func, fileName, line);
|
||||
OnMessage(emptyText.c_str(), nullptr, MessageDisplayBehavior::AlwaysShow);
|
||||
}
|
||||
else
|
||||
{
|
||||
OnMessage(message, nullptr, MessageDisplayBehavior::AlwaysShow);
|
||||
}
|
||||
#else
|
||||
AZ_UNUSED(fileName);
|
||||
AZ_UNUSED(line);
|
||||
AZ_UNUSED(func);
|
||||
AZ_UNUSED(message);
|
||||
#endif // !USE_AZ_ASSERT
|
||||
|
||||
// Return false so other listeners can handle this. The StartupTraceHandler won't report messages
|
||||
// will probably crash before that occurs, because this is an assert.
|
||||
|
||||
@@ -6,9 +6,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "ColorUtils.h"
|
||||
|
||||
// Qt
|
||||
#include <QColor>
|
||||
|
||||
|
||||
@@ -169,13 +169,12 @@ void CMemoryBlock::Uncompress(CMemoryBlock& toBlock) const
|
||||
assert(this != &toBlock);
|
||||
toBlock.Allocate(m_uncompressedSize);
|
||||
toBlock.m_uncompressedSize = 0;
|
||||
unsigned long destSize = m_uncompressedSize;
|
||||
#if !defined(NDEBUG)
|
||||
int result =
|
||||
#endif
|
||||
uncompress((unsigned char*)toBlock.GetBuffer(), &destSize, (unsigned char*)GetBuffer(), GetSize());
|
||||
unsigned long destSize = m_uncompressedSize;
|
||||
int result = uncompress((unsigned char*)toBlock.GetBuffer(), &destSize, (unsigned char*)GetBuffer(), GetSize());
|
||||
assert(result == Z_OK);
|
||||
assert(destSize == static_cast<unsigned long>(m_uncompressedSize));
|
||||
#endif
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -13,92 +13,12 @@
|
||||
|
||||
#include <AzCore/base.h>
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------
|
||||
// Just undef this if you want to use the standard assert function
|
||||
//-----------------------------------------------------------------------------------------------------
|
||||
|
||||
// if AZ_ENABLE_TRACING is enabled, then calls to AZ_Assert(...) will flow in. This is the case
|
||||
// even in Profile mode - thus if you want to manage what happens, USE_CRY_ASSERT also needs to be enabled in those cases.
|
||||
// if USE_CRY_ASSERT is not enabled, but AZ_ENABLE_TRACING is enabled, then the default behavior for assets will occur instead
|
||||
// which is to throw the DEBUG BREAK exception / signal, which tends to end with application shutdown.
|
||||
#if defined(AZ_ENABLE_TRACE_ASSERTS)
|
||||
#define USE_AZ_ASSERT
|
||||
#endif
|
||||
|
||||
#if !defined (USE_AZ_ASSERT) && defined(AZ_ENABLE_TRACING)
|
||||
#undef USE_CRY_ASSERT
|
||||
#define USE_CRY_ASSERT
|
||||
#endif
|
||||
|
||||
// you can undefine this. It will cause the assert message box to appear anywhere that USE_CRY_ASSERT is enabled
|
||||
// instead of it only appearing in debug.
|
||||
// if this is DEFINED then only in debug builds will you see the message box. In other builds, CRY_ASSERTS become CryWarning instead of
|
||||
// instead (showing no message box, only a warning).
|
||||
#define CRY_ASSERT_DIALOG_ONLY_IN_DEBUG
|
||||
|
||||
#if defined(FORCE_STANDARD_ASSERT) || defined(USE_AZ_ASSERT)
|
||||
#undef USE_CRY_ASSERT
|
||||
#undef CRY_ASSERT_DIALOG_ONLY_IN_DEBUG
|
||||
#endif
|
||||
|
||||
// Using AZ_Assert for all assert kinds (assert =, CRY_ASSERT, AZ_Assert).
|
||||
// see Trace::Assert for implementation
|
||||
#if defined(USE_AZ_ASSERT)
|
||||
#undef assert
|
||||
#if !defined(NDEBUG)
|
||||
#define assert(condition) AZ_Assert(condition, "%s", #condition)
|
||||
#else
|
||||
#define assert(condition)
|
||||
#endif
|
||||
#endif //defined(USE_AZ_ASSERT)
|
||||
#undef assert
|
||||
#define assert(condition) AZ_Assert(condition, "%s", #condition)
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------
|
||||
// Use like this:
|
||||
// CRY_ASSERT(expression);
|
||||
// CRY_ASSERT_MESSAGE(expression,"Useful message");
|
||||
// CRY_ASSERT_TRACE(expression,("This should never happen because parameter n%d named %s is %f",iParameter,szParam,fValue));
|
||||
//-----------------------------------------------------------------------------------------------------
|
||||
#define CRY_ASSERT(condition) AZ_Assert(condition, "%s", #condition)
|
||||
#define CRY_ASSERT_MESSAGE(condition, message) AZ_Assert(condition, message)
|
||||
#define CRY_ASSERT_TRACE(condition, parenthese_message) AZ_Assert(condition, parenthese_message)
|
||||
|
||||
#if defined(AZ_RESTRICTED_PLATFORM)
|
||||
#include AZ_RESTRICTED_FILE(CryAssert_h)
|
||||
#endif
|
||||
#if defined(AZ_RESTRICTED_SECTION_IMPLEMENTED)
|
||||
#undef AZ_RESTRICTED_SECTION_IMPLEMENTED
|
||||
#elif defined(WIN32) || defined(APPLE) || defined(LINUX)
|
||||
#define CRYASSERT_H_TRAIT_USE_CRY_ASSERT_MESSAGE 1
|
||||
#endif
|
||||
|
||||
#if defined(USE_CRY_ASSERT) && CRYASSERT_H_TRAIT_USE_CRY_ASSERT_MESSAGE
|
||||
void CryAssertTrace(const char*, ...);
|
||||
bool CryAssert(const char*, const char*, unsigned int, bool*);
|
||||
|
||||
#define CRY_ASSERT(condition) CRY_ASSERT_MESSAGE(condition, NULL)
|
||||
|
||||
#define CRY_ASSERT_MESSAGE(condition, message) CRY_ASSERT_TRACE(condition, (message))
|
||||
|
||||
#define CRY_ASSERT_TRACE(condition, parenthese_message) \
|
||||
do \
|
||||
{ \
|
||||
static bool s_bIgnoreAssert = false; \
|
||||
if (!s_bIgnoreAssert && !(condition)) \
|
||||
{ \
|
||||
CryAssertTrace parenthese_message; \
|
||||
if (CryAssert(#condition, __FILE__, __LINE__, &s_bIgnoreAssert)) \
|
||||
{ \
|
||||
AZ::Debug::Trace::Break(); \
|
||||
} \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#undef assert
|
||||
#define assert CRY_ASSERT
|
||||
#elif !defined(CRY_ASSERT)
|
||||
#ifndef USE_AZ_ASSERT
|
||||
#include <assert.h>
|
||||
#endif //USE_AZ_ASSERT
|
||||
#define CRY_ASSERT(condition) assert(condition)
|
||||
#define CRY_ASSERT_MESSAGE(condition, message) assert(condition)
|
||||
#define CRY_ASSERT_TRACE(condition, parenthese_message) assert(condition)
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -1,101 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
// Description : Assert dialog box for android
|
||||
|
||||
|
||||
#ifndef CRYINCLUDE_CRYCOMMON_CRYASSERT_ANDROID_H
|
||||
#define CRYINCLUDE_CRYCOMMON_CRYASSERT_ANDROID_H
|
||||
#pragma once
|
||||
|
||||
#if defined(USE_CRY_ASSERT) && defined(ANDROID)
|
||||
|
||||
#include <AzCore/NativeUI/NativeUIRequests.h>
|
||||
|
||||
static char gs_szMessage[MAX_PATH];
|
||||
|
||||
void CryAssertTrace(const char* szFormat, ...)
|
||||
{
|
||||
if (gEnv == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!gEnv->bIgnoreAllAsserts)
|
||||
{
|
||||
if (szFormat == NULL)
|
||||
{
|
||||
gs_szMessage[0] = '\0';
|
||||
}
|
||||
else
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, szFormat);
|
||||
vsnprintf(gs_szMessage, sizeof(gs_szMessage), szFormat, args);
|
||||
va_end(args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool CryAssert(const char* szCondition, const char* szFile, unsigned int line, bool* pIgnore)
|
||||
{
|
||||
if (!gEnv)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
#if defined(CRY_ASSERT_DIALOG_ONLY_IN_DEBUG) && !defined(AZ_DEBUG_BUILD)
|
||||
// we are in a non-debug build, so we should turn this into a warning instead.
|
||||
if ((gEnv) && (gEnv->pLog))
|
||||
{
|
||||
if (!gEnv->bIgnoreAllAsserts)
|
||||
{
|
||||
gEnv->pLog->LogWarning("%s(%u): Assertion failed - \"%s\"", szFile, line, szCondition);
|
||||
}
|
||||
}
|
||||
|
||||
if (pIgnore)
|
||||
{
|
||||
// avoid showing the same one repeatedly.
|
||||
*pIgnore = true;
|
||||
}
|
||||
return false;
|
||||
#endif
|
||||
|
||||
gEnv->pSystem->OnAssert(szCondition, gs_szMessage, szFile, line);
|
||||
|
||||
if (!gEnv->bNoAssertDialog && !gEnv->bIgnoreAllAsserts)
|
||||
{
|
||||
AZ::NativeUI::AssertAction result;
|
||||
EBUS_EVENT_RESULT(result, AZ::NativeUI::NativeUIRequestBus, DisplayAssertDialog, gs_szMessage);
|
||||
|
||||
switch (result)
|
||||
{
|
||||
case AZ::NativeUI::AssertAction::IGNORE_ASSERT:
|
||||
return false;
|
||||
case AZ::NativeUI::AssertAction::IGNORE_ALL_ASSERTS:
|
||||
gEnv->bNoAssertDialog = true;
|
||||
gEnv->bIgnoreAllAsserts = true;
|
||||
return false;
|
||||
case AZ::NativeUI::AssertAction::BREAK:
|
||||
return true;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif // CRYINCLUDE_CRYCOMMON_CRYASSERT_ANDROID_H
|
||||
@@ -1,132 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
// Description :
|
||||
// Assert dialog box for LINUX. The linux assert dialog is based on a
|
||||
// small ncurses application which writes the choice to a file. This
|
||||
// was chosen since there is no default UI system on Linux. X11 wasn't
|
||||
// used due to the possibility of the system running another display
|
||||
// protocol (e.g.: WayLand, Mir)
|
||||
|
||||
#ifndef CRYINCLUDE_CRYCOMMON_CRYASSERT_LINUX_H
|
||||
#define CRYINCLUDE_CRYCOMMON_CRYASSERT_LINUX_H
|
||||
#pragma once
|
||||
|
||||
#if defined(USE_CRY_ASSERT) && defined(LINUX) && !defined(ANDROID)
|
||||
|
||||
static char gs_szMessage[MAX_PATH];
|
||||
|
||||
void CryAssertTrace(const char* szFormat, ...)
|
||||
{
|
||||
if (gEnv == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!gEnv->bIgnoreAllAsserts)
|
||||
{
|
||||
if (szFormat == NULL)
|
||||
{
|
||||
gs_szMessage[0] = '\0';
|
||||
}
|
||||
else
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, szFormat);
|
||||
vsnprintf(gs_szMessage, sizeof(gs_szMessage), szFormat, args);
|
||||
va_end(args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool CryAssert(const char* szCondition, const char* szFile, unsigned int line, bool* pIgnore)
|
||||
{
|
||||
if (!gEnv)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
#if defined(CRY_ASSERT_DIALOG_ONLY_IN_DEBUG) && !defined(AZ_DEBUG_BUILD)
|
||||
// we are in a non-debug build, so we should turn this into a warning instead.
|
||||
if (gEnv->pLog)
|
||||
{
|
||||
if (!gEnv->bIgnoreAllAsserts)
|
||||
{
|
||||
gEnv->pLog->LogWarning("%s(%u): Assertion failed - \"%s\"", szFile, line, szCondition);
|
||||
}
|
||||
}
|
||||
if (pIgnore)
|
||||
{
|
||||
// avoid showing the same one repeatedly.
|
||||
*pIgnore = true;
|
||||
}
|
||||
return false;
|
||||
#endif
|
||||
|
||||
static const int max_len = 4096;
|
||||
static char gs_command_str[4096];
|
||||
static AZStd::recursive_mutex lock;
|
||||
|
||||
gEnv->pSystem->OnAssert(szCondition, gs_szMessage, szFile, line);
|
||||
|
||||
size_t file_len = strlen(szFile);
|
||||
|
||||
if (!gEnv->bNoAssertDialog && !gEnv->bIgnoreAllAsserts)
|
||||
{
|
||||
AZStd::scoped_lock lk(lock);
|
||||
snprintf(gs_command_str, max_len, "xterm -geometry 100x20 -n 'Assert Dialog [Linux Launcher]' -T 'Assert Dialog [Linux Launcher]' -e 'BinLinux/assert_term \"%s\" \"%s\" %d \"%s\"; echo \"$?\" > .assert_return'",
|
||||
szCondition, (file_len > 60) ? szFile + (file_len - 61) : szFile, line, gs_szMessage);
|
||||
int ret = system(gs_command_str);
|
||||
if (ret != 0)
|
||||
{
|
||||
CryLogAlways("<Assert> Terminal failed to execute");
|
||||
return false;
|
||||
}
|
||||
|
||||
FILE* assert_file = fopen(".assert_return", "r");
|
||||
if (!assert_file)
|
||||
{
|
||||
CryLogAlways("<Assert> Couldn't open assert file");
|
||||
return false;
|
||||
}
|
||||
int result = -1;
|
||||
fscanf(assert_file, "%d", &result);
|
||||
fclose(assert_file);
|
||||
|
||||
switch (result)
|
||||
{
|
||||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
*pIgnore = true;
|
||||
break;
|
||||
case 2:
|
||||
gEnv->bIgnoreAllAsserts = true;
|
||||
break;
|
||||
case 3:
|
||||
return true;
|
||||
break;
|
||||
case 4:
|
||||
raise(SIGABRT);
|
||||
exit(-1);
|
||||
break;
|
||||
default:
|
||||
CryLogAlways("<Assert> Unknown result in assert file: %d", result);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif // CRYINCLUDE_CRYCOMMON_CRYASSERT_LINUX_H
|
||||
@@ -1,107 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
// Description : Assert dialog box for Mac OS X
|
||||
|
||||
|
||||
#ifndef CRYINCLUDE_CRYCOMMON_CRYASSERT_MAC_H
|
||||
#define CRYINCLUDE_CRYCOMMON_CRYASSERT_MAC_H
|
||||
#pragma once
|
||||
|
||||
#if defined(USE_CRY_ASSERT) && defined(MAC)
|
||||
#include <AzCore/NativeUI/NativeUIRequests.h>
|
||||
|
||||
static char gs_szMessage[MAX_PATH];
|
||||
|
||||
void CryAssertTrace(const char* szFormat, ...)
|
||||
{
|
||||
if (gEnv == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!gEnv->bIgnoreAllAsserts)
|
||||
{
|
||||
if (szFormat == NULL)
|
||||
{
|
||||
gs_szMessage[0] = '\0';
|
||||
}
|
||||
else
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, szFormat);
|
||||
vsnprintf(gs_szMessage, sizeof(gs_szMessage), szFormat, args);
|
||||
va_end(args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool CryAssert(const char* szCondition, const char* szFile, unsigned int line, bool* pIgnore)
|
||||
{
|
||||
if (!gEnv)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
#if defined(CRY_ASSERT_DIALOG_ONLY_IN_DEBUG) && !defined(AZ_DEBUG_BUILD)
|
||||
// we are in a non-debug build, so we should turn this into a warning instead.
|
||||
if ((gEnv) && (gEnv->pLog))
|
||||
{
|
||||
if (!gEnv->bIgnoreAllAsserts)
|
||||
{
|
||||
gEnv->pLog->LogWarning("%s(%u): Assertion failed - \"%s\"", szFile, line, szCondition);
|
||||
}
|
||||
}
|
||||
|
||||
if (pIgnore)
|
||||
{
|
||||
// avoid showing the same one repeatedly.
|
||||
*pIgnore = true;
|
||||
}
|
||||
return false;
|
||||
#endif
|
||||
|
||||
static const int max_len = 4096;
|
||||
static char gs_command_str[4096];
|
||||
|
||||
gEnv->pSystem->OnAssert(szCondition, gs_szMessage, szFile, line);
|
||||
|
||||
size_t file_len = strlen(szFile);
|
||||
|
||||
if (!gEnv->bNoAssertDialog && !gEnv->bIgnoreAllAsserts)
|
||||
{
|
||||
AZ::NativeUI::AssertAction result;
|
||||
EBUS_EVENT_RESULT(result, AZ::NativeUI::NativeUIRequestBus, DisplayAssertDialog, gs_szMessage);
|
||||
|
||||
switch(result)
|
||||
{
|
||||
case AZ::NativeUI::AssertAction::IGNORE_ASSERT:
|
||||
return false;
|
||||
case AZ::NativeUI::AssertAction::IGNORE_ALL_ASSERTS:
|
||||
gEnv->bNoAssertDialog = true;
|
||||
gEnv->bIgnoreAllAsserts = true;
|
||||
return false;
|
||||
case AZ::NativeUI::AssertAction::BREAK:
|
||||
return true;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// For asserts on the Mac always trigger a debug break. Annoying but at least it does not kill the thread like assert() does.
|
||||
__asm__("int $3");
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
#endif // CRYINCLUDE_CRYCOMMON_CRYASSERT_MAC_H
|
||||
@@ -1,99 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
// Description : Assert dialog box for Mac OS X
|
||||
|
||||
|
||||
#ifndef CRYINCLUDE_CRYCOMMON_CRYASSERT_IOS_H
|
||||
#define CRYINCLUDE_CRYCOMMON_CRYASSERT_IOS_H
|
||||
#pragma once
|
||||
|
||||
#if defined(USE_CRY_ASSERT) && (defined(IOS)
|
||||
|
||||
#include <AzCore/NativeUI/NativeUIRequests.h>
|
||||
|
||||
static char gs_szMessage[MAX_PATH];
|
||||
|
||||
void CryAssertTrace(const char* szFormat, ...)
|
||||
{
|
||||
if (gEnv == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!gEnv->bIgnoreAllAsserts)
|
||||
{
|
||||
if (szFormat == NULL)
|
||||
{
|
||||
gs_szMessage[0] = '\0';
|
||||
}
|
||||
else
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, szFormat);
|
||||
vsnprintf(gs_szMessage, sizeof(gs_szMessage), szFormat, args);
|
||||
va_end(args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool CryAssert(const char* szCondition, const char* szFile, unsigned int line, bool* pIgnore)
|
||||
{
|
||||
if (!gEnv)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
#if defined(CRY_ASSERT_DIALOG_ONLY_IN_DEBUG) && !defined(AZ_DEBUG_BUILD)
|
||||
// we are in a non-debug build, so we should turn this into a warning instead.
|
||||
if ((gEnv) && (gEnv->pLog))
|
||||
{
|
||||
if (!gEnv->bIgnoreAllAsserts)
|
||||
{
|
||||
gEnv->pLog->LogWarning("%s(%u): Assertion failed - \"%s\"", szFile, line, szCondition);
|
||||
}
|
||||
}
|
||||
|
||||
if (pIgnore)
|
||||
{
|
||||
// avoid showing the same one repeatedly.
|
||||
*pIgnore = true;
|
||||
}
|
||||
return false;
|
||||
#endif
|
||||
|
||||
gEnv->pSystem->OnAssert(szCondition, gs_szMessage, szFile, line);
|
||||
|
||||
if (!gEnv->bNoAssertDialog && !gEnv->bIgnoreAllAsserts)
|
||||
{
|
||||
printf("!!ASSERT!!\n\tCondition: %s\n\tMessage : %s\n\tFile : %s\n\tLine : %d", szCondition, gs_szMessage, szFile, line);
|
||||
|
||||
AZ::NativeUI::AssertAction result;
|
||||
EBUS_EVENT_RESULT(result, AZ::NativeUI::NativeUIRequestBus, DisplayAssertDialog, gs_szMessage);
|
||||
|
||||
switch(result)
|
||||
{
|
||||
case AZ::NativeUI::AssertAction::IGNORE_ASSERT:
|
||||
return false;
|
||||
case AZ::NativeUI::AssertAction::IGNORE_ALL_ASSERTS:
|
||||
gEnv->bNoAssertDialog = true;
|
||||
gEnv->bIgnoreAllAsserts = true;
|
||||
return false;
|
||||
case AZ::NativeUI::AssertAction::BREAK:
|
||||
return true;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif // CRYINCLUDE_CRYCOMMON_CRYASSERT_IOS_H
|
||||
@@ -1,468 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
// Description : Assert dialog box
|
||||
|
||||
#pragma once
|
||||
|
||||
#if defined(AZ_RESTRICTED_PLATFORM)
|
||||
#undef AZ_RESTRICTED_SECTION
|
||||
#define CRYASSERT_IMPL_H_SECTION_1 1
|
||||
#define CRYASSERT_IMPL_H_SECTION_2 2
|
||||
#endif
|
||||
|
||||
#if defined(USE_CRY_ASSERT)
|
||||
#if defined(AZ_RESTRICTED_PLATFORM)
|
||||
#define AZ_RESTRICTED_SECTION CRYASSERT_IMPL_H_SECTION_1
|
||||
#include AZ_RESTRICTED_FILE(CryAssert_impl_h)
|
||||
#endif
|
||||
|
||||
#if defined(APPLE)
|
||||
#if defined(MAC)
|
||||
#include "CryAssert_Mac.h"
|
||||
#else
|
||||
#include "CryAssert_iOS.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(LINUX)
|
||||
#if defined(ANDROID)
|
||||
#include "CryAssert_Android.h"
|
||||
#else
|
||||
#include "CryAssert_Linux.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(AZ_RESTRICTED_PLATFORM)
|
||||
#define AZ_RESTRICTED_SECTION CRYASSERT_IMPL_H_SECTION_2
|
||||
#include AZ_RESTRICTED_FILE(CryAssert_impl_h)
|
||||
#elif defined(WIN32)
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------
|
||||
|
||||
#include <signal.h>
|
||||
|
||||
#include <AzCore/PlatformIncl.h>
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------
|
||||
|
||||
#define IDD_DIALOG_ASSERT 101
|
||||
#define IDC_CRYASSERT_EDIT_LINE 1000
|
||||
#define IDC_CRYASSERT_EDIT_FILE 1001
|
||||
#define IDC_CRYASSERT_EDIT_CONDITION 1002
|
||||
#define IDC_CRYASSERT_BUTTON_CONTINUE 1003
|
||||
#define IDC_CRYASSERT_EDIT_REASON 1004
|
||||
#define IDC_CRYASSERT_BUTTON_IGNORE 1005
|
||||
#define IDC_CRYASSERT_BUTTON_STOP 1007
|
||||
#define IDC_CRYASSERT_BUTTON_BREAK 1008
|
||||
#define IDC_CRYASSERT_BUTTON_IGNORE_ALL 1009
|
||||
|
||||
#define IDC_CRYASSERT_STATIC_TEXT 0
|
||||
|
||||
#define DLG_TITLE L"Assertion Failed"
|
||||
#define DLG_FONT L"MS Sans Serif"
|
||||
#define DLG_ITEM_TEXT_0 L"Continue"
|
||||
#define DLG_ITEM_TEXT_1 L"Stop"
|
||||
#define DLG_ITEM_TEXT_2 L"Info"
|
||||
#define DLG_ITEM_TEXT_3 L""
|
||||
#define DLG_ITEM_TEXT_4 L"Line"
|
||||
#define DLG_ITEM_TEXT_5 L""
|
||||
#define DLG_ITEM_TEXT_6 L"File"
|
||||
#define DLG_ITEM_TEXT_7 L"Condition"
|
||||
#define DLG_ITEM_TEXT_8 L""
|
||||
#define DLG_ITEM_TEXT_9 L"failed"
|
||||
#define DLG_ITEM_TEXT_10 L""
|
||||
#define DLG_ITEM_TEXT_11 L"Reason"
|
||||
#define DLG_ITEM_TEXT_12 L"Ignore"
|
||||
|
||||
#define DLG_ITEM_TEXT_14 L"Break"
|
||||
#define DLG_ITEM_TEXT_15 L"Ignore All"
|
||||
|
||||
#define DLG_NB_ITEM 15
|
||||
|
||||
|
||||
template<int iTitleSize>
|
||||
struct SDlgItem
|
||||
{
|
||||
// If use my struct instead of DLGTEMPLATE, or else (for some strange reason) it is not DWORD aligned !!
|
||||
DWORD style;
|
||||
DWORD dwExtendedStyle;
|
||||
short x;
|
||||
short y;
|
||||
short cx;
|
||||
short cy;
|
||||
WORD id;
|
||||
WORD ch;
|
||||
WORD c;
|
||||
WCHAR t[iTitleSize];
|
||||
WORD dummy;
|
||||
};
|
||||
#define SDLGITEM(TEXT, V) SDlgItem<sizeof(TEXT) / 2> V;
|
||||
|
||||
struct SDlgData
|
||||
{
|
||||
DLGTEMPLATE dlt;
|
||||
WORD _menu;
|
||||
WORD _class;
|
||||
WCHAR _title[sizeof(DLG_TITLE) / 2];
|
||||
WORD pointSize;
|
||||
WCHAR _font[sizeof(DLG_FONT) / 2];
|
||||
|
||||
SDLGITEM(DLG_ITEM_TEXT_0, i0);
|
||||
SDLGITEM(DLG_ITEM_TEXT_12, i12);
|
||||
SDLGITEM(DLG_ITEM_TEXT_15, i15);
|
||||
SDLGITEM(DLG_ITEM_TEXT_14, i14);
|
||||
SDLGITEM(DLG_ITEM_TEXT_1, i1);
|
||||
SDLGITEM(DLG_ITEM_TEXT_2, i2);
|
||||
SDLGITEM(DLG_ITEM_TEXT_3, i3);
|
||||
SDLGITEM(DLG_ITEM_TEXT_4, i4);
|
||||
SDLGITEM(DLG_ITEM_TEXT_5, i5);
|
||||
SDLGITEM(DLG_ITEM_TEXT_6, i6);
|
||||
SDLGITEM(DLG_ITEM_TEXT_7, i7);
|
||||
SDLGITEM(DLG_ITEM_TEXT_8, i8);
|
||||
SDLGITEM(DLG_ITEM_TEXT_9, i9);
|
||||
SDLGITEM(DLG_ITEM_TEXT_10, i10);
|
||||
SDLGITEM(DLG_ITEM_TEXT_11, i11);
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------
|
||||
|
||||
static SDlgData g_dialogRC =
|
||||
{
|
||||
{DS_SETFOREGROUND | DS_MODALFRAME | DS_3DLOOK | DS_SETFONT | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_VISIBLE, 0, DLG_NB_ITEM, 0, 0, 330, 134}, 0, 0, DLG_TITLE, 8, DLG_FONT,
|
||||
{BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 0, 12, 113, 50, 14, IDC_CRYASSERT_BUTTON_CONTINUE, 0xFFFF, 0x0080, DLG_ITEM_TEXT_0, 0},
|
||||
{BS_DEFPUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 0, 66, 113, 50, 14, IDC_CRYASSERT_BUTTON_IGNORE, 0xFFFF, 0x0080, DLG_ITEM_TEXT_12, 0},
|
||||
{BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 0, 120, 113, 50, 14, IDC_CRYASSERT_BUTTON_IGNORE_ALL, 0xFFFF, 0x0080, DLG_ITEM_TEXT_15, 0},
|
||||
{BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 0, 214, 113, 50, 14, IDC_CRYASSERT_BUTTON_BREAK, 0xFFFF, 0x0080, DLG_ITEM_TEXT_14, 0},
|
||||
{BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 0, 268, 113, 50, 14, IDC_CRYASSERT_BUTTON_STOP, 0xFFFF, 0x0080, DLG_ITEM_TEXT_1, 0},
|
||||
{BS_GROUPBOX | WS_CHILD | WS_VISIBLE, 0, 7, 7, 316, 100, IDC_CRYASSERT_STATIC_TEXT, 0xFFFF, 0x0080, DLG_ITEM_TEXT_2, 0},
|
||||
{ES_LEFT | ES_AUTOHSCROLL | ES_READONLY | WS_BORDER | WS_CHILD | WS_VISIBLE, 0, 50, 48, 25, 13, IDC_CRYASSERT_EDIT_LINE, 0xFFFF, 0x0081, DLG_ITEM_TEXT_3, 0},
|
||||
{WS_CHILD | WS_VISIBLE, 0, 14, 50, 14, 8, IDC_CRYASSERT_STATIC_TEXT, 0xFFFF, 0x0082, DLG_ITEM_TEXT_4, 0},
|
||||
{ES_LEFT | ES_AUTOHSCROLL | ES_READONLY | WS_BORDER | WS_CHILD | WS_VISIBLE, 0, 50, 32, 240, 13, IDC_CRYASSERT_EDIT_FILE, 0xFFFF, 0x0081, DLG_ITEM_TEXT_5, 0},
|
||||
{WS_CHILD | WS_VISIBLE, 0, 14, 34, 12, 8, IDC_CRYASSERT_STATIC_TEXT, 0xFFFF, 0x0082, DLG_ITEM_TEXT_6, 0},
|
||||
{WS_CHILD | WS_VISIBLE, 0, 13, 18, 30, 8, IDC_CRYASSERT_STATIC_TEXT, 0xFFFF, 0x0082, DLG_ITEM_TEXT_7, 0},
|
||||
{ES_LEFT | ES_AUTOHSCROLL | ES_READONLY | WS_BORDER | WS_CHILD | WS_VISIBLE, 0, 50, 16, 240, 13, IDC_CRYASSERT_EDIT_CONDITION, 0xFFFF, 0x0081, DLG_ITEM_TEXT_8, 0},
|
||||
{WS_CHILD | WS_VISIBLE, 0, 298, 19, 18, 8, IDC_CRYASSERT_STATIC_TEXT, 0xFFFF, 0x0082, DLG_ITEM_TEXT_9, 0},
|
||||
{ES_LEFT | ES_AUTOHSCROLL | ES_READONLY | WS_BORDER | WS_CHILD | WS_VISIBLE, 0, 50, 67, 240, 13, IDC_CRYASSERT_EDIT_REASON, 0xFFFF, 0x0081, DLG_ITEM_TEXT_10, 0},
|
||||
{WS_CHILD | WS_VISIBLE, 0, 15, 69, 26, 8, IDC_CRYASSERT_STATIC_TEXT, 0xFFFF, 0x0082, DLG_ITEM_TEXT_11, 0},
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------
|
||||
|
||||
struct SCryAssertInfo
|
||||
{
|
||||
const char* pszCondition;
|
||||
const char* pszFile;
|
||||
const char* pszMessage;
|
||||
|
||||
unsigned int uiLine;
|
||||
|
||||
enum
|
||||
{
|
||||
BUTTON_CONTINUE,
|
||||
BUTTON_IGNORE,
|
||||
BUTTON_IGNORE_ALL,
|
||||
BUTTON_BREAK,
|
||||
BUTTON_STOP,
|
||||
BUTTON_REPORT_AS_BUG,
|
||||
} btnChosen;
|
||||
|
||||
unsigned int uiX;
|
||||
unsigned int uiY;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------
|
||||
|
||||
static INT_PTR CALLBACK DlgProc(HWND _hDlg, UINT _uiMsg, WPARAM _wParam, LPARAM _lParam)
|
||||
{
|
||||
static SCryAssertInfo* pAssertInfo = NULL;
|
||||
|
||||
const UINT WM_USER_SHOWFILE_MESSAGE = (WM_USER + 0x4000);
|
||||
|
||||
switch (_uiMsg)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
{
|
||||
pAssertInfo = (SCryAssertInfo*) _lParam;
|
||||
|
||||
SetWindowText(GetDlgItem(_hDlg, IDC_CRYASSERT_EDIT_CONDITION), pAssertInfo->pszCondition);
|
||||
SetWindowText(GetDlgItem(_hDlg, IDC_CRYASSERT_EDIT_FILE), pAssertInfo->pszFile);
|
||||
|
||||
// Want to move the cursor on the file text, so that the end of the file is the first thing visible,
|
||||
// instead of the beginning, which will be the user's depot, and the same for pretty much every file.
|
||||
// Have to do this delayed, because if it's done in WM_INITDIALOG, it doesn't work.
|
||||
// PostMessage will add this to the end of the message queue.
|
||||
PostMessage(_hDlg, WM_USER_SHOWFILE_MESSAGE, 0, 0);
|
||||
|
||||
char szLine[MAX_PATH];
|
||||
sprintf_s(szLine, "%d", pAssertInfo->uiLine);
|
||||
SetWindowText(GetDlgItem(_hDlg, IDC_CRYASSERT_EDIT_LINE), szLine);
|
||||
|
||||
if (pAssertInfo->pszMessage && pAssertInfo->pszMessage[0] != '\0')
|
||||
{
|
||||
SetWindowText(GetDlgItem(_hDlg, IDC_CRYASSERT_EDIT_REASON), pAssertInfo->pszMessage);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetWindowText(GetDlgItem(_hDlg, IDC_CRYASSERT_EDIT_REASON), "No Reason");
|
||||
}
|
||||
|
||||
SetWindowPos(_hDlg, HWND_TOPMOST, pAssertInfo->uiX, pAssertInfo->uiY, 0, 0, SWP_SHOWWINDOW | SWP_NOSIZE);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_USER_SHOWFILE_MESSAGE:
|
||||
{
|
||||
// Still have to delay sending this message, or it won't work for some reason.
|
||||
// Windows does a whole bunch of stuff behind the scenes. Using PostMessage here seems to work better.
|
||||
PostMessage(GetDlgItem(_hDlg, IDC_CRYASSERT_EDIT_FILE), EM_SETSEL, strlen(pAssertInfo->pszFile), -1);
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_COMMAND:
|
||||
{
|
||||
switch (LOWORD(_wParam))
|
||||
{
|
||||
case IDCANCEL:
|
||||
case IDC_CRYASSERT_BUTTON_CONTINUE:
|
||||
{
|
||||
pAssertInfo->btnChosen = SCryAssertInfo::BUTTON_CONTINUE;
|
||||
EndDialog(_hDlg, 0);
|
||||
break;
|
||||
}
|
||||
case IDC_CRYASSERT_BUTTON_IGNORE:
|
||||
{
|
||||
pAssertInfo->btnChosen = SCryAssertInfo::BUTTON_IGNORE;
|
||||
EndDialog(_hDlg, 0);
|
||||
break;
|
||||
}
|
||||
case IDC_CRYASSERT_BUTTON_IGNORE_ALL:
|
||||
{
|
||||
pAssertInfo->btnChosen = SCryAssertInfo::BUTTON_IGNORE_ALL;
|
||||
EndDialog(_hDlg, 0);
|
||||
break;
|
||||
}
|
||||
case IDC_CRYASSERT_BUTTON_BREAK:
|
||||
{
|
||||
pAssertInfo->btnChosen = SCryAssertInfo::BUTTON_BREAK;
|
||||
EndDialog(_hDlg, 0);
|
||||
break;
|
||||
}
|
||||
case IDC_CRYASSERT_BUTTON_STOP:
|
||||
{
|
||||
pAssertInfo->btnChosen = SCryAssertInfo::BUTTON_STOP;
|
||||
EndDialog(_hDlg, 1);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
;
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_DESTROY:
|
||||
{
|
||||
if (pAssertInfo)
|
||||
{
|
||||
RECT rcWindowBounds;
|
||||
GetWindowRect(_hDlg, &rcWindowBounds);
|
||||
pAssertInfo->uiX = rcWindowBounds.left;
|
||||
pAssertInfo->uiY = rcWindowBounds.top;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------
|
||||
|
||||
static char gs_szMessage[MAX_PATH];
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------
|
||||
|
||||
void CryAssertTrace(const char* _pszFormat, ...)
|
||||
{
|
||||
if (gEnv == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!gEnv->bIgnoreAllAsserts)
|
||||
{
|
||||
if (NULL == _pszFormat)
|
||||
{
|
||||
gs_szMessage[0] = '\0';
|
||||
}
|
||||
else
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, _pszFormat);
|
||||
vsnprintf_s(gs_szMessage, sizeof(gs_szMessage), _TRUNCATE, _pszFormat, args);
|
||||
va_end(args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------
|
||||
|
||||
static const char* gs_strRegSubKey = "Software\\O3DE\\AssertWindow";
|
||||
static const char* gs_strRegXValue = "AssertInfoX";
|
||||
static const char* gs_strRegYValue = "AssertInfoY";
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------
|
||||
|
||||
void RegistryReadUInt32(const char* _strSubKey, const char* _strRegName, unsigned int* _puiValue, unsigned int _uiDefault)
|
||||
{
|
||||
HKEY hKey;
|
||||
RegCreateKeyEx(HKEY_CURRENT_USER, _strSubKey, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, NULL);
|
||||
|
||||
DWORD dwType;
|
||||
DWORD dwLength = sizeof(DWORD);
|
||||
|
||||
if (ERROR_SUCCESS != RegQueryValueEx(hKey, _strRegName, 0, &dwType, (BYTE*) _puiValue, &dwLength))
|
||||
{
|
||||
*_puiValue = _uiDefault;
|
||||
}
|
||||
|
||||
RegCloseKey(hKey);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------
|
||||
|
||||
void RegistryWriteUInt32(const char* _strSubKey, const char* _strRegName, unsigned int _uiValue)
|
||||
{
|
||||
HKEY hKey;
|
||||
RegCreateKeyEx(HKEY_CURRENT_USER, _strSubKey, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, NULL);
|
||||
RegSetValueEx (hKey, _strRegName, 0, REG_DWORD, (BYTE*) &_uiValue, sizeof(DWORD));
|
||||
RegCloseKey (hKey);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------
|
||||
|
||||
class CCursorShowerWithStack
|
||||
{
|
||||
public:
|
||||
void StoreCurrentAndShow()
|
||||
{
|
||||
m_numberOfShows = 1;
|
||||
|
||||
while (ShowCursor(TRUE) < 0)
|
||||
{
|
||||
++m_numberOfShows;
|
||||
}
|
||||
}
|
||||
|
||||
void RevertToPrevious()
|
||||
{
|
||||
while (m_numberOfShows > 0)
|
||||
{
|
||||
ShowCursor(FALSE);
|
||||
--m_numberOfShows;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
int m_numberOfShows;
|
||||
};
|
||||
|
||||
bool CryAssert(const char* _pszCondition, const char* _pszFile, unsigned int _uiLine, bool* _pbIgnore)
|
||||
{
|
||||
if (!gEnv)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
#if defined(CRY_ASSERT_DIALOG_ONLY_IN_DEBUG) && !defined(AZ_DEBUG_BUILD)
|
||||
// we are in a non-debug build, so we should turn this into a warning instead.
|
||||
if ((gEnv) && (gEnv->pLog))
|
||||
{
|
||||
if (!gEnv->bIgnoreAllAsserts)
|
||||
{
|
||||
gEnv->pLog->LogWarning("%s(%u): Assertion failed - \"%s\"", _pszFile, _uiLine, _pszCondition);
|
||||
}
|
||||
}
|
||||
|
||||
if (_pbIgnore)
|
||||
{
|
||||
// avoid showing the same one repeatedly.
|
||||
*_pbIgnore = true;
|
||||
}
|
||||
return false;
|
||||
#endif
|
||||
|
||||
if (!gEnv->bNoAssertDialog && !gEnv->bIgnoreAllAsserts)
|
||||
{
|
||||
SCryAssertInfo assertInfo;
|
||||
|
||||
assertInfo.pszCondition = _pszCondition;
|
||||
assertInfo.pszFile = _pszFile;
|
||||
assertInfo.pszMessage = gs_szMessage;
|
||||
assertInfo.uiLine = _uiLine;
|
||||
assertInfo.btnChosen = SCryAssertInfo::BUTTON_CONTINUE;
|
||||
|
||||
gEnv->pSystem->SetAssertVisible(true);
|
||||
RegistryReadUInt32(gs_strRegSubKey, gs_strRegXValue, &assertInfo.uiX, 10);
|
||||
RegistryReadUInt32(gs_strRegSubKey, gs_strRegYValue, &assertInfo.uiY, 10);
|
||||
|
||||
CCursorShowerWithStack cursorShowerWithStack;
|
||||
cursorShowerWithStack.StoreCurrentAndShow();
|
||||
|
||||
DialogBoxIndirectParam(GetModuleHandle(NULL), (DLGTEMPLATE*) &g_dialogRC, GetDesktopWindow(), DlgProc, (LPARAM) &assertInfo);
|
||||
|
||||
cursorShowerWithStack.RevertToPrevious();
|
||||
|
||||
RegistryWriteUInt32(gs_strRegSubKey, gs_strRegXValue, assertInfo.uiX);
|
||||
RegistryWriteUInt32(gs_strRegSubKey, gs_strRegYValue, assertInfo.uiY);
|
||||
gEnv->pSystem->SetAssertVisible(false);
|
||||
|
||||
switch (assertInfo.btnChosen)
|
||||
{
|
||||
case SCryAssertInfo::BUTTON_IGNORE:
|
||||
*_pbIgnore = true;
|
||||
break;
|
||||
case SCryAssertInfo::BUTTON_IGNORE_ALL:
|
||||
gEnv->bIgnoreAllAsserts = true;
|
||||
break;
|
||||
case SCryAssertInfo::BUTTON_BREAK:
|
||||
return true;
|
||||
case SCryAssertInfo::BUTTON_STOP:
|
||||
raise(SIGABRT);
|
||||
exit(-1);
|
||||
case SCryAssertInfo::BUTTON_REPORT_AS_BUG:
|
||||
if (gEnv && gEnv->pSystem)
|
||||
{
|
||||
const char* pszSafeMessage = (assertInfo.pszMessage && assertInfo.pszMessage[0]) ? assertInfo.pszMessage : "<no reason>";
|
||||
gEnv->pSystem->ReportBug("Assert: %s - %s", assertInfo.pszCondition, pszSafeMessage);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (gEnv && gEnv->pSystem)
|
||||
{
|
||||
// this also can cause fatal / shutdown behavior:
|
||||
gEnv->pSystem->OnAssert(_pszCondition, gs_szMessage, _pszFile, _uiLine);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------
|
||||
@@ -1295,15 +1295,7 @@ namespace Detail
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(USE_CRY_ASSERT)
|
||||
static void AssertConsoleExists(void)
|
||||
{
|
||||
CRY_ASSERT(gEnv->pConsole != NULL);
|
||||
}
|
||||
#define ASSERT_CONSOLE_EXISTS AssertConsoleExists()
|
||||
#else
|
||||
#define ASSERT_CONSOLE_EXISTS 0
|
||||
#endif // defined(USE_CRY_ASSERT)
|
||||
|
||||
// the following macros allow the help text to be easily stripped out
|
||||
|
||||
|
||||
@@ -712,16 +712,6 @@ DWORD Sleep(DWORD dwMilliseconds)
|
||||
#endif
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
DWORD SleepEx(DWORD dwMilliseconds, BOOL /*bAlertable*/)
|
||||
{
|
||||
//TODO: implement
|
||||
// CRY_ASSERT_MESSAGE(0, "SleepEx not implemented yet");
|
||||
printf("SleepEx not properly implemented yet\n");
|
||||
Sleep(dwMilliseconds);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if defined(LINUX) || defined(APPLE)
|
||||
BOOL GetComputerName(LPSTR lpBuffer, LPDWORD lpnSize)
|
||||
{
|
||||
|
||||
@@ -85,11 +85,6 @@ set(FILES
|
||||
MathConversion.h
|
||||
AndroidSpecific.h
|
||||
AppleSpecific.h
|
||||
CryAssert_Android.h
|
||||
CryAssert_impl.h
|
||||
CryAssert_iOS.h
|
||||
CryAssert_Linux.h
|
||||
CryAssert_Mac.h
|
||||
Linux32Specific.h
|
||||
Linux64Specific.h
|
||||
Linux_Win32Wrapper.h
|
||||
|
||||
@@ -238,12 +238,6 @@ ILINE DestinationType alias_cast(SourceType pPtr)
|
||||
// Assert dialog box macros
|
||||
#include "CryAssert.h"
|
||||
|
||||
// Replace standard assert calls by our custom one
|
||||
// Works only ifdef USE_CRY_ASSERT && _DEBUG && WIN32
|
||||
#ifndef assert
|
||||
#define assert CRY_ASSERT
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Platform dependent functions that emulate Win32 API.
|
||||
// Mostly used only for debugging!
|
||||
|
||||
@@ -157,10 +157,6 @@ void __stl_debug_message(const char* format_str, ...)
|
||||
#include <intrin.h>
|
||||
#endif
|
||||
|
||||
#if defined(APPLE) || defined(LINUX)
|
||||
#include "CryAssert_impl.h"
|
||||
#endif
|
||||
|
||||
#if defined(AZ_RESTRICTED_PLATFORM)
|
||||
#define AZ_RESTRICTED_SECTION PLATFORM_IMPL_H_SECTION_CRY_SYSTEM_FUNCTIONS
|
||||
#include AZ_RESTRICTED_FILE(platform_impl_h)
|
||||
@@ -168,8 +164,6 @@ void __stl_debug_message(const char* format_str, ...)
|
||||
|
||||
#if defined (_WIN32)
|
||||
|
||||
#include "CryAssert_impl.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CrySleep(unsigned int dwMilliseconds)
|
||||
{
|
||||
|
||||
@@ -77,64 +77,11 @@ public:
|
||||
|
||||
bool OnPreAssert(const char* fileName, int line, const char* func, const char* message) override
|
||||
{
|
||||
#if defined(USE_CRY_ASSERT) && AZ_LEGACY_CRYSYSTEM_TRAIT_DO_PREASSERT
|
||||
AZ::Crc32 crc;
|
||||
crc.Add(&line, sizeof(line));
|
||||
if (fileName)
|
||||
{
|
||||
crc.Add(fileName, strlen(fileName));
|
||||
}
|
||||
|
||||
bool* ignore = nullptr;
|
||||
auto foundIter = m_ignoredAsserts->find(crc);
|
||||
if (foundIter == m_ignoredAsserts->end())
|
||||
{
|
||||
ignore = &((*m_ignoredAsserts)[crc]);
|
||||
*ignore = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
ignore = &((*m_ignoredAsserts)[crc]);
|
||||
}
|
||||
|
||||
if (!(*ignore))
|
||||
{
|
||||
using namespace AZ::Debug;
|
||||
|
||||
Trace::Output(nullptr, "\n==================================================================\n");
|
||||
AZ::OSString outputMsg = AZ::OSString::format("Trace::Assert\n %s(%d): '%s'\n%s\n", fileName, line, func, message);
|
||||
Trace::Output(nullptr, outputMsg.c_str());
|
||||
|
||||
// Suppress 3 in stack depth - this function, the bus broadcast that got us here, and Trace::Assert
|
||||
Trace::Output(nullptr, "------------------------------------------------\n");
|
||||
Trace::PrintCallstack(nullptr, 3);
|
||||
Trace::Output(nullptr, "\n==================================================================\n");
|
||||
|
||||
AZ::EnvironmentVariable<bool> inEditorBatchMode = AZ::Environment::FindVariable<bool>("InEditorBatchMode");
|
||||
if (!inEditorBatchMode.IsConstructed() || !inEditorBatchMode.Get())
|
||||
{
|
||||
// Note - CryAssertTrace doesn't actually print any info to logging
|
||||
// it just stores the message internally for the message box in CryAssert to use
|
||||
CryAssertTrace("%s", message);
|
||||
if (CryAssert("Assertion failed", fileName, line, ignore) || Trace::IsDebuggerPresent())
|
||||
{
|
||||
Trace::Break();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CryLogAlways("%s", message);
|
||||
}
|
||||
|
||||
return m_suppressSystemOutput;
|
||||
#else
|
||||
AZ_UNUSED(fileName);
|
||||
AZ_UNUSED(line);
|
||||
AZ_UNUSED(func);
|
||||
AZ_UNUSED(message);
|
||||
return false; // allow AZCore to do its default behavior. This usually results in an application shutdown.
|
||||
#endif
|
||||
}
|
||||
|
||||
bool OnPreError(const char* window, const char* fileName, int line, const char* func, const char* message) override
|
||||
|
||||
@@ -1280,10 +1280,7 @@ void CSystem::RegisterWindowMessageHandler(IWindowMessageHandler* pHandler)
|
||||
void CSystem::UnregisterWindowMessageHandler(IWindowMessageHandler* pHandler)
|
||||
{
|
||||
#if AZ_LEGACY_CRYSYSTEM_TRAIT_USE_MESSAGE_HANDLER
|
||||
#if !defined(NDEBUG)
|
||||
bool bRemoved =
|
||||
#endif
|
||||
stl::find_and_erase(m_windowMessageHandlers, pHandler);
|
||||
[[maybe_unused]] bool bRemoved = stl::find_and_erase(m_windowMessageHandlers, pHandler);
|
||||
assert(pHandler && bRemoved && "This IWindowMessageHandler was not registered");
|
||||
#else
|
||||
CRY_ASSERT(false && "This platform does not support window message handlers");
|
||||
|
||||
@@ -53,11 +53,6 @@ class CWatchdogThread;
|
||||
#define AZ_LEGACY_CRYSYSTEM_TRAIT_ALLOW_CREATE_BACKUP_LOG_FILE 1
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
#if defined(WIN32) || defined(APPLE) || defined(LINUX)
|
||||
#define AZ_LEGACY_CRYSYSTEM_TRAIT_DO_PREASSERT 1
|
||||
#endif
|
||||
|
||||
#if defined(LINUX) || defined(APPLE)
|
||||
#define AZ_LEGACY_CRYSYSTEM_TRAIT_FORWARD_EXCEPTION_POINTERS 1
|
||||
#endif
|
||||
@@ -72,9 +67,7 @@ class CWatchdogThread;
|
||||
#define AZ_LEGACY_CRYSYSTEM_TRAIT_DEBUGCALLSTACK_APPEND_MODULENAME 1
|
||||
#endif
|
||||
|
||||
#if 1
|
||||
#define AZ_LEGACY_CRYSYSTEM_TRAIT_USE_EXCLUDEUPDATE_ON_CONSOLE 0
|
||||
#endif
|
||||
#if defined(WIN32)
|
||||
#define AZ_LEGACY_CRYSYSTEM_TRAIT_USE_MESSAGE_HANDLER 1
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user