mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-17 13:24:15 -05:00
Fix delete in PictureFlow
This commit is contained in:
parent
384131a231
commit
76fddb29af
@ -293,8 +293,9 @@ PictureFlowState::PictureFlowState():
|
|||||||
|
|
||||||
PictureFlowState::~PictureFlowState()
|
PictureFlowState::~PictureFlowState()
|
||||||
{
|
{
|
||||||
for(int i = 0; i < (int)slideImages.count(); ++i)
|
while (! slideImages.isEmpty()) {
|
||||||
delete slideImages[i];
|
delete slideImages.takeFirst();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// readjust the settings, call this when slide dimension is changed
|
// readjust the settings, call this when slide dimension is changed
|
||||||
@ -482,7 +483,7 @@ PictureFlowSoftwareRenderer::~PictureFlowSoftwareRenderer()
|
|||||||
{
|
{
|
||||||
surfaceCache.clear();
|
surfaceCache.clear();
|
||||||
buffer = QImage();
|
buffer = QImage();
|
||||||
delete blankSurface;
|
if (blankSurface) delete blankSurface;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PictureFlowSoftwareRenderer::paint()
|
void PictureFlowSoftwareRenderer::paint()
|
||||||
@ -516,6 +517,7 @@ void PictureFlowSoftwareRenderer::init()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
surfaceCache.clear();
|
surfaceCache.clear();
|
||||||
|
if (blankSurface) delete blankSurface;
|
||||||
blankSurface = 0;
|
blankSurface = 0;
|
||||||
|
|
||||||
size = widget->size();
|
size = widget->size();
|
||||||
@ -687,7 +689,7 @@ QImage* PictureFlowSoftwareRenderer::surface(int slideIndex)
|
|||||||
bool empty = img ? img->isNull() : true;
|
bool empty = img ? img->isNull() : true;
|
||||||
if(empty) {
|
if(empty) {
|
||||||
surfaceCache.remove(key);
|
surfaceCache.remove(key);
|
||||||
imageHash.remove(slideIndex);
|
delete imageHash.take(slideIndex);
|
||||||
if(!blankSurface) {
|
if(!blankSurface) {
|
||||||
int sw = state->slideWidth;
|
int sw = state->slideWidth;
|
||||||
int sh = state->slideHeight;
|
int sh = state->slideHeight;
|
||||||
@ -723,29 +725,28 @@ QImage* PictureFlowSoftwareRenderer::surface(int slideIndex)
|
|||||||
return blankSurface;
|
return blankSurface;
|
||||||
}//if(empty)
|
}//if(empty)
|
||||||
|
|
||||||
#ifdef PICTUREFLOW_QT4
|
#ifdef PICTUREFLOW_QT2
|
||||||
bool exist = imageHash.contains(slideIndex);
|
if(img == imageHash[slideIndex])
|
||||||
if(exist)
|
|
||||||
if(img == imageHash.find(slideIndex).value())
|
|
||||||
#endif
|
#endif
|
||||||
#ifdef PICTUREFLOW_QT3
|
#ifdef PICTUREFLOW_QT3
|
||||||
bool exist = imageHash.find(slideIndex) != imageHash.end();
|
bool exist = imageHash.find(slideIndex) != imageHash.end();
|
||||||
if(exist)
|
if(exist)
|
||||||
if(img == imageHash.find(slideIndex).data())
|
if(img == imageHash.find(slideIndex).data())
|
||||||
#endif
|
#endif
|
||||||
#ifdef PICTUREFLOW_QT2
|
#ifdef PICTUREFLOW_QT4
|
||||||
if(img == imageHash[slideIndex])
|
bool exist = imageHash.contains(slideIndex);
|
||||||
|
if(exist)
|
||||||
|
if(img == imageHash.find(slideIndex).value())
|
||||||
#endif
|
#endif
|
||||||
if(surfaceCache.contains(key))
|
if(surfaceCache.contains(key))
|
||||||
return surfaceCache[key];
|
return surfaceCache[key];
|
||||||
|
|
||||||
QImage* sr = prepareSurface(img, state->slideWidth, state->slideHeight, bgcolor, state->reflectionEffect);
|
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);
|
imageHash.insert(slideIndex, img);
|
||||||
|
|
||||||
return sr_copy;
|
return sr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Renders a slide to offscreen buffer. Returns a rect of the rendered area.
|
// 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)
|
if(!blend)
|
||||||
return QRect();
|
return QRect();
|
||||||
|
|
||||||
QImage* src = surface(slide.slideIndex);
|
QImage* src = surface(slide.slideIndex); // src is owned by surfaceCache(QCache) don't delete it.
|
||||||
if(!src)
|
if(!src)
|
||||||
return QRect();
|
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);
|
int xi = qMax((PFreal)0, ((w*PFREAL_ONE/2) + fdiv(xs*h, dist+ys)) >> PFREAL_SHIFT);
|
||||||
if(xi >= w)
|
if(xi >= w)
|
||||||
{
|
|
||||||
delete src ;
|
|
||||||
return rect;
|
return rect;
|
||||||
}
|
|
||||||
|
|
||||||
bool flag = false;
|
bool flag = false;
|
||||||
rect.setLeft(xi);
|
rect.setLeft(xi);
|
||||||
@ -861,7 +859,6 @@ QRect PictureFlowSoftwareRenderer::renderSlide(const SlideInfo &slide, int col1,
|
|||||||
|
|
||||||
rect.setTop(0);
|
rect.setTop(0);
|
||||||
rect.setBottom(h-1);
|
rect.setBottom(h-1);
|
||||||
delete src ;
|
|
||||||
|
|
||||||
return rect;
|
return rect;
|
||||||
}
|
}
|
||||||
@ -1107,10 +1104,9 @@ void PictureFlow::setCenterIndex(int index)
|
|||||||
|
|
||||||
void PictureFlow::clear()
|
void PictureFlow::clear()
|
||||||
{
|
{
|
||||||
int c = d->state->slideImages.count();
|
while (! d->state->slideImages.isEmpty()) {
|
||||||
for(int i = 0; i < c; ++i)
|
delete d->state->slideImages.takeFirst();
|
||||||
delete d->state->slideImages[i];
|
}
|
||||||
d->state->slideImages.resize(0);
|
|
||||||
|
|
||||||
d->state->reset();
|
d->state->reset();
|
||||||
triggerRender();
|
triggerRender();
|
||||||
|
@ -1176,6 +1176,7 @@ identities {
|
|||||||
|
|
||||||
gxscircles {
|
gxscircles {
|
||||||
DEFINES += RS_USE_CIRCLES
|
DEFINES += RS_USE_CIRCLES
|
||||||
|
# DEFINES += RS_USE_NEW_PEOPLE_DIALOG
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
gui/Circles/CirclesDialog.h \
|
gui/Circles/CirclesDialog.h \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user