DIRECTOR: Fix check on (shared)cast for formatting

Check for existance of `cast and `sharedcast` before calling
`getCastMember` on it.
This commit is contained in:
Roland van Laar 2022-09-22 17:21:40 +02:00
parent 5a5cfe784b
commit 03da927aaa

View File

@ -189,23 +189,25 @@ bool Debugger::cmdCast(int argc, const char **argv) {
castId = atoi(argv[1]);
debugPrintf("Cast:\n");
if (castId > -1 && !cast->getCastMember(castId)) {
if (!cast) {
debugPrintf("[empty]\n");
} else if (castId > -1 && !cast->getCastMember(castId)) {
debugPrintf("[not found]\n");
} else if (cast) {
} else {
debugPrintf("%s\n", cast->formatCastSummary(castId).c_str());
} else {
debugPrintf("[empty]\n");
}
debugPrintf("\n");
debugPrintf("Shared cast:\n");
if (castId > -1 && !sharedCast->getCastMember(castId)) {
debugPrintf("[not found]\n");
} else if (sharedCast) {
debugPrintf("%s\n", sharedCast->formatCastSummary(castId).c_str());
} else {
if (!sharedCast) {
debugPrintf("[empty]\n");
} else if (castId > -1 && !sharedCast->getCastMember(castId)) {
debugPrintf("[not found]\n");
} else {
debugPrintf("%s\n", sharedCast->formatCastSummary(castId).c_str());
}
debugPrintf("\n");
return true;
}