mirror of
https://github.com/TomHarte/CLK.git
synced 2024-11-26 23:52:26 +00:00
Merge pull request #624 from TomHarte/BookendCrash
Permits end_data only after a begin_data.
This commit is contained in:
commit
299a7b99ae
@ -208,7 +208,8 @@ uint8_t *ScanTarget::begin_data(size_t required_length, size_t required_alignmen
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Everything checks out, return the pointer.
|
||||
// Everything checks out, note expectation of a future end_data and return the pointer.
|
||||
data_is_allocated_ = true;
|
||||
vended_write_area_pointer_ = write_pointers_.write_area = TextureAddress(aligned_start_x, output_y);
|
||||
return &write_area_texture_[size_t(write_pointers_.write_area) * data_type_size_];
|
||||
|
||||
@ -217,7 +218,7 @@ uint8_t *ScanTarget::begin_data(size_t required_length, size_t required_alignmen
|
||||
}
|
||||
|
||||
void ScanTarget::end_data(size_t actual_length) {
|
||||
if(allocation_has_failed_) return;
|
||||
if(allocation_has_failed_ || !data_is_allocated_) return;
|
||||
|
||||
// Bookend the start of the new data, to safeguard for precision errors in sampling.
|
||||
memcpy(
|
||||
@ -234,6 +235,9 @@ void ScanTarget::end_data(size_t actual_length) {
|
||||
&write_area_texture_[size_t(write_pointers_.write_area - 1) * data_type_size_],
|
||||
&write_area_texture_[size_t(write_pointers_.write_area - 2) * data_type_size_],
|
||||
data_type_size_);
|
||||
|
||||
// Record that no further end_data calls are expected.
|
||||
data_is_allocated_ = false;
|
||||
}
|
||||
|
||||
void ScanTarget::will_change_owner() {
|
||||
|
@ -186,6 +186,7 @@ class ScanTarget: public Outputs::Display::ScanTarget {
|
||||
int vended_write_area_pointer_ = 0;
|
||||
|
||||
// Track allocation failures.
|
||||
bool data_is_allocated_ = false;
|
||||
bool allocation_has_failed_ = false;
|
||||
bool line_allocation_has_failed_ = false;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user