[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    khtml - render_text: Q3PtrVector->QVector
From:       Peter_Kümmel <syntheticpp () gmx ! net>
Date:       2006-06-27 20:29:30
Message-ID: 44A1952A.5010900 () gmx ! net
[Download RAW message or body]

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<T>::operator[](int i);

In the patch I compare the references to the pointers,
not the pointers, could this be a problem?

Peter

["qvector.diff" (text/plain)]

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 <q3ptrvector.h>
+#include <qvector.h>
 #include <assert.h>
 
 class QPainter;
@@ -133,15 +133,15 @@
     friend class RenderText;
 };
 
-class InlineTextBoxArray : public Q3PtrVector<InlineTextBox>
+class InlineTextBoxArray : public QVector<InlineTextBox*>
 {
 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<InlineTextBox*>(d1)->m_y - static_cast<InlineTextBox*>(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;
 }


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic