Potential leak of memory pointed to by `region_img` [clang-analyzer]
This warning from the clang-analyzer must be investigated:
.../gui/graphics/DetectorScene.cpp:827:35: warning: Potential leak of memory pointed to by 'region_img' [clang-analyzer-cplusplus.NewDeleteLeaks]
_integrationRegion1 = addPixmap(QPixmap::fromImage(*region_img));
^
.../gui/graphics/DetectorScene.cpp:947:9: note: Assuming the condition is false
if (_integrationRegion1 && !flag) {
^
.../gui/graphics/DetectorScene.cpp:947:29: note: Left side of '&&' is false
if (_integrationRegion1 && !flag) {
^
.../gui/graphics/DetectorScene.cpp:952:9: note: Assuming the condition is false
if (_integrationRegion2 && !flag) {
^
.../gui/graphics/DetectorScene.cpp:952:29: note: Left side of '&&' is false
if (_integrationRegion2 && !flag) {
^
.../gui/graphics/DetectorScene.cpp:961:5: note: Calling 'DetectorScene::loadCurrentImage'
loadCurrentImage();
^
.../gui/graphics/DetectorScene.cpp:785:5: note: Taking false branch
if (!_currentData)
^
.../gui/graphics/DetectorScene.cpp:790:9: note: Assuming the condition is false
if (_currentFrameIndex >= _currentData->nFrames())
^
.../gui/graphics/DetectorScene.cpp:790:5: note: Taking false branch
if (_currentFrameIndex >= _currentData->nFrames())
^
.../gui/graphics/DetectorScene.cpp:793:9: note: Assuming the condition is false
if (_image == nullptr) {
^
.../gui/graphics/DetectorScene.cpp:793:5: note: Taking false branch
if (_image == nullptr) {
^
.../gui/graphics/DetectorScene.cpp:804:9: note: Assuming the condition is true
if (_drawIntegrationRegion1 || _drawIntegrationRegion2) {
^
.../gui/graphics/DetectorScene.cpp:804:33: note: Left side of '||' is true
if (_drawIntegrationRegion1 || _drawIntegrationRegion2) {
^
.../gui/graphics/DetectorScene.cpp:805:9: note: Calling 'DetectorScene::refreshIntegrationOverlay'
refreshIntegrationOverlay();
^
.../gui/graphics/DetectorScene.cpp:817:9: note: Assuming the condition is false
if (!_peak_model_1 && !_peak_model_2)
^
.../gui/graphics/DetectorScene.cpp:817:24: note: Left side of '&&' is false
if (!_peak_model_1 && !_peak_model_2)
^
.../gui/graphics/DetectorScene.cpp:823:9: note: Left side of '&&' is true
if (_peak_model_1 && _drawIntegrationRegion1) {
^
.../gui/graphics/DetectorScene.cpp:823:5: note: Taking true branch
if (_peak_model_1 && _drawIntegrationRegion1) {
^
.../gui/graphics/DetectorScene.cpp:825:30: note: Calling 'DetectorScene::getIntegrationRegionImage'
QImage* region_img = getIntegrationRegionImage(mask, _peakPxColor1, _bkgPxColor1);
^
.../gui/graphics/DetectorScene.cpp:850:26: note: Memory is allocated
QImage* region_img = new QImage(mask.cols(), mask.rows(), QImage::Format_ARGB32);
^
.../gui/graphics/DetectorScene.cpp:852:21: note: Assuming the condition is false
for (int c = 0; c < mask.cols(); ++c) {
^
.../gui/graphics/DetectorScene.cpp:852:5: note: Loop condition is false. Execution continues on line 867
for (int c = 0; c < mask.cols(); ++c) {
^
.../gui/graphics/DetectorScene.cpp:825:30: note: Returned allocated memory
QImage* region_img = getIntegrationRegionImage(mask, _peakPxColor1, _bkgPxColor1);
^
.../gui/graphics/DetectorScene.cpp:826:13: note: Assuming the condition is true
if (!_integrationRegion1) {
^
.../gui/graphics/DetectorScene.cpp:826:9: note: Taking true branch
if (!_integrationRegion1) {
^
.../gui/graphics/DetectorScene.cpp:827:35: note: Potential leak of memory pointed to by 'region_img'
_integrationRegion1 = addPixmap(QPixmap::fromImage(*region_img));
^
.../gui/graphics/DetectorScene.cpp:839:35: warning: Potential leak of memory pointed to by 'region_img' [clang-analyzer-cplusplus.NewDeleteLeaks]
_integrationRegion2 = addPixmap(QPixmap::fromImage(*region_img));
^
.../gui/graphics/DetectorScene.cpp:947:9: note: Assuming the condition is false
if (_integrationRegion1 && !flag) {
^
.../gui/graphics/DetectorScene.cpp:947:29: note: Left side of '&&' is false
if (_integrationRegion1 && !flag) {
^
.../gui/graphics/DetectorScene.cpp:952:9: note: Assuming the condition is false
if (_integrationRegion2 && !flag) {
^
.../gui/graphics/DetectorScene.cpp:952:29: note: Left side of '&&' is false
if (_integrationRegion2 && !flag) {
^
.../gui/graphics/DetectorScene.cpp:961:5: note: Calling 'DetectorScene::loadCurrentImage'
loadCurrentImage();
^
.../gui/graphics/DetectorScene.cpp:785:5: note: Taking false branch
if (!_currentData)
^
.../gui/graphics/DetectorScene.cpp:790:9: note: Assuming the condition is false
if (_currentFrameIndex >= _currentData->nFrames())
^
.../gui/graphics/DetectorScene.cpp:790:5: note: Taking false branch
if (_currentFrameIndex >= _currentData->nFrames())
^
.../gui/graphics/DetectorScene.cpp:793:9: note: Assuming the condition is false
if (_image == nullptr) {
^
.../gui/graphics/DetectorScene.cpp:793:5: note: Taking false branch
if (_image == nullptr) {
^
.../gui/graphics/DetectorScene.cpp:804:9: note: Assuming the condition is true
if (_drawIntegrationRegion1 || _drawIntegrationRegion2) {
^
.../gui/graphics/DetectorScene.cpp:804:33: note: Left side of '||' is true
if (_drawIntegrationRegion1 || _drawIntegrationRegion2) {
^
.../gui/graphics/DetectorScene.cpp:805:9: note: Calling 'DetectorScene::refreshIntegrationOverlay'
refreshIntegrationOverlay();
^
.../gui/graphics/DetectorScene.cpp:817:9: note: Assuming the condition is true
if (!_peak_model_1 && !_peak_model_2)
^
.../gui/graphics/DetectorScene.cpp:817:9: note: Left side of '&&' is true
.../gui/graphics/DetectorScene.cpp:817:27: note: Assuming the condition is false
if (!_peak_model_1 && !_peak_model_2)
^
.../gui/graphics/DetectorScene.cpp:817:5: note: Taking false branch
if (!_peak_model_1 && !_peak_model_2)
^
.../gui/graphics/DetectorScene.cpp:823:23: note: Left side of '&&' is false
if (_peak_model_1 && _drawIntegrationRegion1) {
^
.../gui/graphics/DetectorScene.cpp:834:9: note: Left side of '&&' is true
if (_peak_model_2 && _drawIntegrationRegion2) {
^
.../gui/graphics/DetectorScene.cpp:834:26: note: Assuming the condition is true
if (_peak_model_2 && _drawIntegrationRegion2) {
^
.../gui/graphics/DetectorScene.cpp:834:5: note: Taking true branch
if (_peak_model_2 && _drawIntegrationRegion2) {
^
.../gui/graphics/DetectorScene.cpp:837:30: note: Calling 'DetectorScene::getIntegrationRegionImage'
QImage* region_img = getIntegrationRegionImage(mask, _peakPxColor2, _bkgPxColor2);
^
.../gui/graphics/DetectorScene.cpp:850:26: note: Memory is allocated
QImage* region_img = new QImage(mask.cols(), mask.rows(), QImage::Format_ARGB32);
^
.../gui/graphics/DetectorScene.cpp:852:21: note: Assuming the condition is false
for (int c = 0; c < mask.cols(); ++c) {
^
.../gui/graphics/DetectorScene.cpp:852:5: note: Loop condition is false. Execution continues on line 867
for (int c = 0; c < mask.cols(); ++c) {
^
.../gui/graphics/DetectorScene.cpp:837:30: note: Returned allocated memory
QImage* region_img = getIntegrationRegionImage(mask, _peakPxColor2, _bkgPxColor2);
^
.../gui/graphics/DetectorScene.cpp:838:13: note: Assuming the condition is true
if (!_integrationRegion2) {
^
.../gui/graphics/DetectorScene.cpp:838:9: note: Taking true branch
if (!_integrationRegion2) {
^
.../gui/graphics/DetectorScene.cpp:839:35: note: Potential leak of memory pointed to by 'region_img'
_integrationRegion2 = addPixmap(QPixmap::fromImage(*region_img));