Looks sensible to me.

Stefan Schimanski wrote:
> STL's vector doesn't give access to the data required by Qt, but
> QVector does. So this slight variation of your proposed patch:
>
>        // double the size if needed
>        static QVector<QPoint> points(32);
>        if (np > points.size())
>                points.resize(2 * np);
>
> Will commit if nobody complains.
>
> Stefan
>
>> On Sat, May 19, 2007 at 06:51:17PM +0200, Stefan Schimanski wrote:
>>> Here is the patch. Comments?
>>>
>>> Wonder if there is something like that in Boost, but didn't find it.
>>>
>>> Stefan
>>
>>
>> Index: src/frontends/qt4/QLPainter.cpp
>> ===================================================================
>> --- src/frontends/qt4/QLPainter.cpp    (Revision 18423)
>> +++ src/frontends/qt4/QLPainter.cpp    (Arbeitskopie)
>> @@ -114,8 +114,15 @@
>>      if (!isDrawingEnabled())
>>          return;
>>     
>> -    // Must use new as np is not known at compile time.
>> -    boost::scoped_array<QPoint> points(new QPoint[np]);
>> +    // double the size if needed
>> +    static size_t size = 32;
>> +    static QPoint * points = new QPoint[size];
>> +    if (size_t(np) > size) {
>> +        delete[] points;
>> +        while (size_t(np) > size)
>> +            size *= 2;
>> +        points = new QPoint[size];
>> +    }
>>
>> Simpler:
>>
>>     static std::vector<QPoint> points;
>>     if (np > points.size())   
>>         points.resize(2 * np)
>>
>> Andre'
>


-- 
==================================================================
Richard G Heck, Jr
Professor of Philosophy
Brown University
http://frege.brown.edu/heck/
==================================================================
Get my public key from http://sks.keyserver.penguin.de
Hash: 0x1DE91F1E66FFBDEC
Learn how to sign your email using Thunderbird and GnuPG at:
http://dudu.dyn.2-h.org/nist/gpg-enigmail-howto

Reply via email to