Skip to content

Commit

Permalink
abort the operations when the user closes the progress dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
danielhrisca committed Dec 4, 2024
1 parent 71f03b7 commit 80c8d2a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
2 changes: 0 additions & 2 deletions src/asammdf/blocks/mdf_v4.py
Original file line number Diff line number Diff line change
Expand Up @@ -1690,15 +1690,13 @@ def _load_data(
cc = 0

if finished:
data = []
if rm and invalidation_size:
invalidation_data = []
break

if original_size:
buffer_view[cur_size : cur_size + original_size] = new_data
cur_size += original_size
original_size = 0

if rm and invalidation_size:
invalidation_data.append(new_invalidation_data)
Expand Down
1 change: 0 additions & 1 deletion src/asammdf/gui/widgets/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -2773,7 +2773,6 @@ def apply_processing(self, event):
)

def apply_processing_finished(self):

self._progress = None

def apply_processing_thread(self, file_name, opts, version, needs_filter, channels, progress=None):
Expand Down
22 changes: 15 additions & 7 deletions src/asammdf/mdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -808,6 +808,9 @@ def convert(self, version: str, progress=None) -> MDF:
else:
out.extend(cg_nr, sigs)

if progress and progress.stop:
return TERMINATED

if progress is not None:
if callable(progress):
progress(i + 1, groups_nr)
Expand Down Expand Up @@ -1046,6 +1049,9 @@ def cut(

idx += 1

if progress and progress.stop:
return TERMINATED

# if the cut interval is not found in the measurement
# then append a data group with 0 cycles
if idx == 0 and signals:
Expand Down Expand Up @@ -2055,18 +2061,11 @@ def filter(self, channels: ChannelsType, version: str | None = None, progress=No
**self._kwargs,
)

integer_interpolation_mode = self._integer_interpolation
float_interpolation_mode = self._float_interpolation
mdf.configure(from_other=self)
mdf.header.start_time = self.header.start_time

self.configure(copy_on_get=False)

if self.name:
origin = self.name.name
else:
origin = "New MDF"

groups_nr = len(gps)

if progress is not None:
Expand Down Expand Up @@ -2105,6 +2104,9 @@ def filter(self, channels: ChannelsType, version: str | None = None, progress=No
else:
mdf.extend(cg_nr, sigs)

if progress and progress.stop:
return TERMINATED

if progress is not None:
if callable(progress):
progress(i + 1, groups_nr)
Expand Down Expand Up @@ -2615,6 +2617,9 @@ def concatenate(
if first_timestamp is None:
first_timestamp = master[0]

if progress and progress.stop:
return TERMINATED

last_timestamps[i] = last_timestamp

mdf.configure(copy_on_get=True)
Expand Down Expand Up @@ -2796,6 +2801,9 @@ def stack(

stacked.extend(dg_cntr, signals)

if progress and progress.stop:
return TERMINATED

if dg_cntr is not None:
for index in range(dg_cntr, len(stacked.groups)):
stacked.groups[index].channel_group.comment = (
Expand Down

0 comments on commit 80c8d2a

Please sign in to comment.