diff options
author | Martin Smith <msmith@trolltech.com> | 2010-02-16 07:16:45 (GMT) |
---|---|---|
committer | Martin Smith <msmith@trolltech.com> | 2010-02-16 07:16:45 (GMT) |
commit | 20c00cc256c4c588fdf137de13bdc83d4eb3cc8f (patch) | |
tree | 5f7d86a9737f0254124d81f76ae3e7e41c4588ca /src/corelib | |
parent | 791601cf2bef4f097f5da82b95a05fa731118b40 (diff) | |
parent | 1a5c3af0f3e75a518c27c6bdd3f58896a49b167e (diff) | |
download | Qt-20c00cc256c4c588fdf137de13bdc83d4eb3cc8f.zip Qt-20c00cc256c4c588fdf137de13bdc83d4eb3cc8f.tar.gz Qt-20c00cc256c4c588fdf137de13bdc83d4eb3cc8f.tar.bz2 |
Merge branch '4.6' of git@scm.dev.nokia.troll.no:qt/oslo-staging-1 into 4.6
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/tools/qcontiguouscache.h | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/src/corelib/tools/qcontiguouscache.h b/src/corelib/tools/qcontiguouscache.h index 1f7fdb2..aa5603d 100644 --- a/src/corelib/tools/qcontiguouscache.h +++ b/src/corelib/tools/qcontiguouscache.h @@ -221,22 +221,29 @@ void QContiguousCache<T>::setCapacity(int asize) x.d->alloc = asize; x.d->count = qMin(d->count, asize); x.d->offset = d->offset + d->count - x.d->count; - x.d->start = x.d->offset % x.d->alloc; - T *dest = x.p->array + (x.d->start + x.d->count-1) % x.d->alloc; - T *src = p->array + (d->start + d->count-1) % d->alloc; + if(asize) + x.d->start = x.d->offset % x.d->alloc; + else + x.d->start = 0; + int oldcount = x.d->count; - while (oldcount--) { - if (QTypeInfo<T>::isComplex) { - new (dest) T(*src); - } else { - *dest = *src; + if(oldcount) + { + T *dest = x.p->array + (x.d->start + x.d->count-1) % x.d->alloc; + T *src = p->array + (d->start + d->count-1) % d->alloc; + while (oldcount--) { + if (QTypeInfo<T>::isComplex) { + new (dest) T(*src); + } else { + *dest = *src; + } + if (dest == x.p->array) + dest = x.p->array + x.d->alloc; + dest--; + if (src == p->array) + src = p->array + d->alloc; + src--; } - if (dest == x.p->array) - dest = x.p->array + x.d->alloc; - dest--; - if (src == p->array) - src = p->array + d->alloc; - src--; } /* free old */ free(p); |