jfjoch_viewer: Trace more potential memory issues
This commit is contained in:
@@ -196,6 +196,10 @@ bool JFJochHttpReader::LoadImage_i(std::shared_ptr<JFJochReaderDataset> &dataset
|
||||
if (!res || res->status != httplib::StatusCode::OK_200)
|
||||
return false;
|
||||
|
||||
if (res->body.empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
buffer.resize(res->body.size());
|
||||
memcpy(buffer.data(), res->body.data(), res->body.size());
|
||||
|
||||
@@ -209,6 +209,11 @@ void JFJochImageReadingWorker::UpdateDataset_i(const std::optional<DiffractionEx
|
||||
file_reader.UpdateGeomMetadata(experiment.value());
|
||||
dataset = file_reader.GetDataset();
|
||||
}
|
||||
if (!dataset) {
|
||||
logger.Error("UpdateDataset_i: dataset is null (http_mode={}) - skipping update to avoid crash", http_mode);
|
||||
return;
|
||||
}
|
||||
|
||||
curr_experiment = dataset->experiment;
|
||||
curr_experiment.ImportIndexingSettings(indexing_settings);
|
||||
curr_experiment.ImportAzimuthalIntegrationSettings(azint_settings);
|
||||
@@ -341,6 +346,12 @@ void JFJochImageReadingWorker::UpdateUserMask_i(const std::vector<uint32_t> &mas
|
||||
file_reader.UpdateUserMask(mask);
|
||||
dataset = file_reader.GetDataset();
|
||||
}
|
||||
|
||||
if (!dataset) {
|
||||
logger.Error("UpdateUserMask_i: dataset is null (http_mode={}) - skipping update to avoid crash", http_mode);
|
||||
return;
|
||||
}
|
||||
|
||||
UpdateAzint_i(dataset.get());
|
||||
|
||||
emit datasetLoaded(dataset);
|
||||
|
||||
@@ -133,6 +133,9 @@ void JFJochViewerDatasetInfo::imageSelectedInChart(int64_t number) {
|
||||
|
||||
void JFJochViewerDatasetInfo::UpdatePlot() {
|
||||
int index = combo_box->currentIndex();
|
||||
if (combo_box->count() == 0 || index < 0)
|
||||
return;
|
||||
|
||||
int val = combo_box->itemData(index).toInt();
|
||||
|
||||
if (dataset) {
|
||||
|
||||
Reference in New Issue
Block a user