From kde-core-devel Tue Jun 27 20:29:30 2006 From: =?ISO-8859-1?Q?Peter_K=FCmmel?= Date: Tue, 27 Jun 2006 20:29:30 +0000 To: kde-core-devel Subject: khtml - render_text: Q3PtrVector->QVector Message-Id: <44A1952A.5010900 () gmx ! net> X-MARC-Message: https://marc.info/?l=kde-core-devel&m=115144010001515 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--------------070407000700050909090209" This is a multi-part message in MIME format. --------------070407000700050909090209 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit I get a strange linker error when compiling khtml with msvc: it could not find Q3GVector::at, even though this function is an inline function. Maybe this is because of the debug mode, but trying to force the inlining doesn't work. Before fiddling around with this Q3Support code I've used QVector instead, which solves the linker error. Is it possible to apply the attached patch? The only point where I'm not sure is the replacement of the 'compareItems' function: int Q3GVector::compareItems( Item d1, Item d2 ) { return d1 != d2; // compare pointers } T & QVector::operator[](int i); In the patch I compare the references to the pointers, not the pointers, could this be a problem? Peter --------------070407000700050909090209 Content-Type: text/plain; name="qvector.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="qvector.diff" Index: rendering/render_text.h =================================================================== --- rendering/render_text.h (revision 555414) +++ rendering/render_text.h (working copy) @@ -30,7 +30,7 @@ #include "rendering/render_object.h" #include "rendering/render_line.h" -#include +#include #include class QPainter; @@ -133,15 +133,15 @@ friend class RenderText; }; -class InlineTextBoxArray : public Q3PtrVector +class InlineTextBoxArray : public QVector { public: InlineTextBoxArray(); InlineTextBox* first(); - int findFirstMatching( Item ) const; - virtual int compareItems( Item, Item ); + int findFirstMatching( InlineTextBox* ) const; + virtual int compareItems( InlineTextBox*, InlineTextBox* ); }; class RenderText : public RenderObject Index: rendering/render_text.cpp =================================================================== --- rendering/render_text.cpp (revision 555414) +++ rendering/render_text.cpp (working copy) @@ -487,19 +487,18 @@ InlineTextBoxArray::InlineTextBoxArray() { - setAutoDelete(false); } -int InlineTextBoxArray::compareItems( Item d1, Item d2 ) +int InlineTextBoxArray::compareItems( InlineTextBox* d1, InlineTextBox* d2 ) { assert(d1); assert(d2); - return static_cast(d1)->m_y - static_cast(d2)->m_y; + return d1->m_y - d2->m_y; } // remove this once QVector::bsearch is fixed -int InlineTextBoxArray::findFirstMatching(Item d) const +int InlineTextBoxArray::findFirstMatching(InlineTextBox* d) const { int len = count(); @@ -517,7 +516,7 @@ if ( (*this)[mid] == 0 ) // null item greater res = -1; else - res = ((Q3GVector*)this)->compareItems( d, (*this)[mid] ); + res = d != (*this)[mid] ; if ( res < 0 ) n2 = mid - 1; else if ( res > 0 ) @@ -530,7 +529,7 @@ /* if ( !found ) return -1; */ // search to first one equal or bigger - while ( found && (mid > 0) && !((Q3GVector*)this)->compareItems(d, (*this)[mid-1]) ) + while ( found && (mid > 0) && !( d != (*this)[mid-1] ) ) mid--; return mid; } --------------070407000700050909090209--