Fix delete in PictureFlow

This commit is contained in:
Phenom 2016-03-16 19:05:22 +01:00
parent 384131a231
commit 76fddb29af
3 changed files with 30 additions and 33 deletions

View File

@ -82,11 +82,11 @@ PeopleDialog::PeopleDialog(QWidget *parent)
{//First Get Item created in Qt Designer for Internal
int count = idInternal->children().count();
for (int curs = 0; curs < count; ++curs){
for (int curs = 0; curs < count; ++curs){
QObject *obj = idInternal->children().at(curs);
QWidget *wid = qobject_cast<QWidget *>(obj);
QWidget *wid = qobject_cast<QWidget *>(obj);
if (wid) _flowLayoutInt->addWidget(wid);
}//for (int curs = 0; curs < count; ++curs)
}//for (int curs = 0; curs < count; ++curs)
}//End First Get Item created in Qt Designer for Internal
pictureFlowWidgetExternal->setAcceptDrops(true);

View File

@ -293,8 +293,9 @@ PictureFlowState::PictureFlowState():
PictureFlowState::~PictureFlowState()
{
for(int i = 0; i < (int)slideImages.count(); ++i)
delete slideImages[i];
while (! slideImages.isEmpty()) {
delete slideImages.takeFirst();
}
}
// readjust the settings, call this when slide dimension is changed
@ -482,7 +483,7 @@ PictureFlowSoftwareRenderer::~PictureFlowSoftwareRenderer()
{
surfaceCache.clear();
buffer = QImage();
delete blankSurface;
if (blankSurface) delete blankSurface;
}
void PictureFlowSoftwareRenderer::paint()
@ -516,6 +517,7 @@ void PictureFlowSoftwareRenderer::init()
return;
surfaceCache.clear();
if (blankSurface) delete blankSurface;
blankSurface = 0;
size = widget->size();
@ -687,7 +689,7 @@ QImage* PictureFlowSoftwareRenderer::surface(int slideIndex)
bool empty = img ? img->isNull() : true;
if(empty) {
surfaceCache.remove(key);
imageHash.remove(slideIndex);
delete imageHash.take(slideIndex);
if(!blankSurface) {
int sw = state->slideWidth;
int sh = state->slideHeight;
@ -723,29 +725,28 @@ QImage* PictureFlowSoftwareRenderer::surface(int slideIndex)
return blankSurface;
}//if(empty)
#ifdef PICTUREFLOW_QT2
if(img == imageHash[slideIndex])
#endif
#ifdef PICTUREFLOW_QT3
bool exist = imageHash.find(slideIndex) != imageHash.end();
if(exist)
if(img == imageHash.find(slideIndex).data())
#endif
#ifdef PICTUREFLOW_QT4
bool exist = imageHash.contains(slideIndex);
if(exist)
if(img == imageHash.find(slideIndex).value())
#endif
#ifdef PICTUREFLOW_QT3
bool exist = imageHash.find(slideIndex) != imageHash.end();
if(exist)
if(img == imageHash.find(slideIndex).data())
#endif
#ifdef PICTUREFLOW_QT2
if(img == imageHash[slideIndex])
#endif
if(surfaceCache.contains(key))
return surfaceCache[key];
if(surfaceCache.contains(key))
return surfaceCache[key];
QImage* sr = prepareSurface(img, state->slideWidth, state->slideHeight, bgcolor, state->reflectionEffect);
QImage *sr_copy = new QImage(*sr) ;
QImage* sr = prepareSurface(img, state->slideWidth, state->slideHeight, bgcolor, state->reflectionEffect);
surfaceCache.insert(key, sr); // this takes ownership on sr. So we can't use it afterwards
surfaceCache.insert(key, sr); // QCache takes ownership on sr. And delete it when removed.
imageHash.insert(slideIndex, img);
return sr_copy;
return sr;
}
// Renders a slide to offscreen buffer. Returns a rect of the rendered area.
@ -756,7 +757,7 @@ QRect PictureFlowSoftwareRenderer::renderSlide(const SlideInfo &slide, int col1,
if(!blend)
return QRect();
QImage* src = surface(slide.slideIndex);
QImage* src = surface(slide.slideIndex); // src is owned by surfaceCache(QCache) don't delete it.
if(!src)
return QRect();
@ -787,11 +788,8 @@ QRect PictureFlowSoftwareRenderer::renderSlide(const SlideInfo &slide, int col1,
PFreal dist = distance * PFREAL_ONE;
int xi = qMax((PFreal)0, ((w*PFREAL_ONE/2) + fdiv(xs*h, dist+ys)) >> PFREAL_SHIFT);
if(xi >= w)
{
delete src ;
return rect;
}
if(xi >= w)
return rect;
bool flag = false;
rect.setLeft(xi);
@ -860,8 +858,7 @@ QRect PictureFlowSoftwareRenderer::renderSlide(const SlideInfo &slide, int col1,
}//for(int x = qMax(xi, col1); x <= col2; ++x)
rect.setTop(0);
rect.setBottom(h-1);
delete src ;
rect.setBottom(h-1);
return rect;
}
@ -1107,10 +1104,9 @@ void PictureFlow::setCenterIndex(int index)
void PictureFlow::clear()
{
int c = d->state->slideImages.count();
for(int i = 0; i < c; ++i)
delete d->state->slideImages[i];
d->state->slideImages.resize(0);
while (! d->state->slideImages.isEmpty()) {
delete d->state->slideImages.takeFirst();
}
d->state->reset();
triggerRender();

View File

@ -1176,6 +1176,7 @@ identities {
gxscircles {
DEFINES += RS_USE_CIRCLES
# DEFINES += RS_USE_NEW_PEOPLE_DIALOG
HEADERS += \
gui/Circles/CirclesDialog.h \