diff --git a/src/include/global/QGlobals.h b/src/include/global/QGlobals.h index adadbe3..644031a 100644 --- a/src/include/global/QGlobals.h +++ b/src/include/global/QGlobals.h @@ -392,6 +392,12 @@ typedef struct StudyInfo QPushButton *study_label; SeriesMapType *series; StudyInfo():study_label(nullptr), series(nullptr) {} + ~StudyInfo(){ + for(auto item: *series){ + delete item.second; + } + delete series; + } }StudyInfo_t; typedef std::map StudiesMapType; @@ -402,7 +408,13 @@ typedef struct PatientInfo QPushButton *patient_label; StudiesMapType *studies; PatientInfo():patient_label(nullptr), studies(nullptr){ - printf("constr PatientInfo \r\n"); + + } + ~PatientInfo(){ + for(auto item: *studies){ + delete item.second; + } + delete studies; } }PatientInfo_t; typedef std::map PatientsMapType; diff --git a/src/src/QDicomViewer.cpp b/src/src/QDicomViewer.cpp index af7f481..b666e31 100644 --- a/src/src/QDicomViewer.cpp +++ b/src/src/QDicomViewer.cpp @@ -1,4 +1,4 @@ -#include "QDicomViewer.h" +#include "QDicomViewer.h" #include "global/include_all.h" #include "base/SeriesImageSet.h" #include "view/subview/gridpopwidget.h" @@ -1008,7 +1008,7 @@ void QDicomViewer::openAndDrawDICOM(const std::string& dicomName, SeriesOpenMode DicomLoader *helper = DicomLoader::GetInstance(); - + helper->reset(); //load image and tag helper->readTags(dicomName, openMode); auto unique = helper->getDefaultUniqueID(); diff --git a/src/src/view/thumbnailbarwidget.cpp b/src/src/view/thumbnailbarwidget.cpp index b27d58c..0a90d96 100644 --- a/src/src/view/thumbnailbarwidget.cpp +++ b/src/src/view/thumbnailbarwidget.cpp @@ -112,94 +112,74 @@ ThumbnailBarWidget::~ThumbnailBarWidget() { } //------------------------------------------------------- +//TODO: need to remove relevant to the button create in DicomLoader void ThumbnailBarWidget::updateThumbnailBar() { foreach(QWidget *l, LabelList) { seriesPanel->layout()->removeWidget(l); LabelList.removeOne(l); - //delete l; + delete l; } DicomLoader *helper = DicomLoader::GetInstance(); //获取Patient const PatientsMapType & all_patients = helper->getPatientsList(); - for (PatientsMapType::const_iterator it_pa = all_patients.cbegin(); it_pa != all_patients.cend(); it_pa++) - { - //构建Patient panel - QPushButton *patient_lbl = it_pa->second->patient_label; - if (!patient_lbl) - { - patient_lbl = new QPushButton(seriesPanel); - patient_lbl->setObjectName("patient"); - std::string text_pa = ThumbMessages::Format(it_pa->second); - QString qtext = QString::fromStdString(text_pa); - qtext.replace("^", "\n"); - patient_lbl->setText(qtext); - patient_lbl->setEnabled(false); - } - seriesPanel->layout()->addWidget(patient_lbl); - LabelList << patient_lbl; + for (PatientsMapType::const_iterator it_pa = all_patients.cbegin(); it_pa != all_patients.cend(); it_pa++) { + //构建Patient panel + QPushButton *patient_lbl = new QPushButton(seriesPanel); + patient_lbl->setObjectName("patient"); + std::string text_pa = ThumbMessages::Format(it_pa->second); + QString qtext = QString::fromStdString(text_pa); + qtext.replace("^", "\n"); + patient_lbl->setText(qtext); + patient_lbl->setEnabled(false); + seriesPanel->layout()->addWidget(patient_lbl); + LabelList << patient_lbl; - StudiesMapType *studies = it_pa->second->studies; - for (StudiesMapType::const_iterator it_st = studies->cbegin(); it_st != studies->cend(); it_st++) - { - QPushButton *study_lbl = it_st->second->study_label; - if (!study_lbl) - { - study_lbl = new QPushButton(seriesPanel); - study_lbl->setObjectName("study"); - std::string text_st = ThumbMessages::Format(it_st->second); - //study_lbl->setGeometry(0, 0, 100, 100); - study_lbl->setText(QString::fromStdString(text_st)); - study_lbl->setEnabled(false); - //QFont font; - //font.setFamily(QString::fromUtf8("Britannic Bold")); - //study_lbl->setFont(font); - //study_lbl->setWordWrap(true); - //study_lbl->setFrameShape(QFrame::NoFrame); - } - seriesPanel->layout()->addWidget(study_lbl); - //layout->addWidget(study_lbl); - LabelList << study_lbl; + StudiesMapType *studies = it_pa->second->studies; + for (StudiesMapType::const_iterator it_st = studies->cbegin(); it_st != studies->cend(); it_st++) { + QPushButton *study_lbl = new QPushButton(seriesPanel); + study_lbl->setObjectName("study"); + std::string text_st = ThumbMessages::Format(it_st->second); + //study_lbl->setGeometry(0, 0, 100, 100); + study_lbl->setText(QString::fromStdString(text_st)); + study_lbl->setEnabled(false); + + seriesPanel->layout()->addWidget(study_lbl); + //layout->addWidget(study_lbl); + LabelList << study_lbl; - SeriesMapType *series = it_st->second->series; - for (SeriesMapType::const_iterator it_se = series->cbegin(); it_se != series->cend(); it_se++) - { - thumbnailImage *thumbnail = it_se->second->thumb_nail; - if (it_se->second->pixmap_valid==false) - { - //OVERRIDE_LEVEL - if (thumbnail) - { - //if thumbnail is currentImageLabel,set nullptr, or crash - if (currentImageLabel == thumbnail) - { - currentImageLabel = nullptr; - } - delete thumbnail; - thumbnail = nullptr; - } - //wait for update - //thumbnail = new thumbnailImage(this, it_se->second); - thumbnail = createThumbnailImage(seriesPanel, it_se->second); + SeriesMapType *series = it_st->second->series; + for (SeriesMapType::const_iterator it_se = series->cbegin(); it_se != series->cend(); it_se++) { + thumbnailImage *thumbnail = it_se->second->thumb_nail; + if (it_se->second->pixmap_valid == false) { + //OVERRIDE_LEVEL + if (thumbnail) { + //if thumbnail is currentImageLabel,set nullptr, or crash + if (currentImageLabel == thumbnail) { + currentImageLabel = nullptr; + } + delete thumbnail; + thumbnail = nullptr; + } + //wait for update + //thumbnail = new thumbnailImage(this, it_se->second); + thumbnail = createThumbnailImage(seriesPanel, it_se->second); - //update pointer point to new thumbnail - it_se->second->thumb_nail = thumbnail; - it_se->second->pixmap_valid = true; - } - seriesPanel->layout()->addWidget(thumbnail); - //save all thumbnail in one list - LabelList << thumbnail; - //imageLabelList << thumbnail; + //update pointer point to new thumbnail + it_se->second->thumb_nail = thumbnail; + it_se->second->pixmap_valid = true; + } + seriesPanel->layout()->addWidget(thumbnail); + //save all thumbnail in one list + LabelList << thumbnail; + //imageLabelList << thumbnail; - } - - - } - - } + } + } + } } thumbnailImage* ThumbnailBarWidget::createThumbnailImage(QWidget *parent, SeriesInfo_t* series_info) {