Skip to content

Commit

Permalink
Std: Uses Alert() and DebugBreak() for MQL only
Browse files Browse the repository at this point in the history
  • Loading branch information
kenorb committed Apr 27, 2024
1 parent af7b695 commit d290033
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Std.h
Original file line number Diff line number Diff line change
Expand Up @@ -308,23 +308,29 @@ struct AsSeriesReleaseEnsurer {
AsSeriesReleaseEnsurer(int _num_buffs) : released(false), num_buffs(_num_buffs) {}
void done(int _num_buffs) {
if (_num_buffs != num_buffs) {
#ifdef __MQL__
Alert("You have acquired ", num_buffs, " buffers via ACQUIRE_BUFFER", num_buffs,
"(), but now trying to release with mismatched RELEASE_BUFFER", _num_buffs, "()!");
DebugBreak();
#endif
}

if (released) {
#ifdef __MQL__
Alert("You have used RELEASE_BUFFER", num_buffs, "() again which is not required!");
DebugBreak();
#endif
}

released = true;
}
~AsSeriesReleaseEnsurer() {
if (!released) {
#ifdef __MQL__
Alert("You have used ACQUIRE_BUFFER", num_buffs, "() but didn't release buffer(s) via RELEASE_BUFFER", num_buffs,
"() before returning from the scope!");
DebugBreak();
#endif
}
}
};
Expand Down

0 comments on commit d290033

Please sign in to comment.