mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Fix delete in PictureFlow
This commit is contained in:
parent
384131a231
commit
76fddb29af
@ -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_QT4
|
||||
bool exist = imageHash.contains(slideIndex);
|
||||
if(exist)
|
||||
if(img == imageHash.find(slideIndex).value())
|
||||
#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_QT2
|
||||
if(img == imageHash[slideIndex])
|
||||
#ifdef PICTUREFLOW_QT4
|
||||
bool exist = imageHash.contains(slideIndex);
|
||||
if(exist)
|
||||
if(img == imageHash.find(slideIndex).value())
|
||||
#endif
|
||||
if(surfaceCache.contains(key))
|
||||
return surfaceCache[key];
|
||||
|
||||
QImage* sr = prepareSurface(img, state->slideWidth, state->slideHeight, bgcolor, state->reflectionEffect);
|
||||
QImage *sr_copy = new QImage(*sr) ;
|
||||
|
||||
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();
|
||||
|
||||
@ -788,10 +789,7 @@ QRect PictureFlowSoftwareRenderer::renderSlide(const SlideInfo &slide, int col1,
|
||||
|
||||
int xi = qMax((PFreal)0, ((w*PFREAL_ONE/2) + fdiv(xs*h, dist+ys)) >> PFREAL_SHIFT);
|
||||
if(xi >= w)
|
||||
{
|
||||
delete src ;
|
||||
return rect;
|
||||
}
|
||||
|
||||
bool flag = false;
|
||||
rect.setLeft(xi);
|
||||
@ -861,7 +859,6 @@ QRect PictureFlowSoftwareRenderer::renderSlide(const SlideInfo &slide, int col1,
|
||||
|
||||
rect.setTop(0);
|
||||
rect.setBottom(h-1);
|
||||
delete src ;
|
||||
|
||||
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();
|
||||
|
@ -1176,6 +1176,7 @@ identities {
|
||||
|
||||
gxscircles {
|
||||
DEFINES += RS_USE_CIRCLES
|
||||
# DEFINES += RS_USE_NEW_PEOPLE_DIALOG
|
||||
|
||||
HEADERS += \
|
||||
gui/Circles/CirclesDialog.h \
|
||||
|
Loading…
Reference in New Issue
Block a user