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

List:       kfm-devel
Subject:    Pointer to reference to QChar? (Was: Re: CSSMediaRule::insertRule)
From:       Martijn Klingens <mklingens () ism ! nl>
Date:       2001-09-25 13:37:15
[Download RAW message or body]

On Tuesday 25 September 2001 12:28, Lars Knoll wrote:
> CSSMediaRuleImpl::insertRule( const DOMString &str )
> {
> 	CSSRuleImpl *rule = parseRule( str.unicode(), str.unicode() + str.length()
> ); // insert the rule into the list

This gives a compilation warning. It took me quite some time to 
figure out what exactly went wrong. The error is

----
css_ruleimpl.cpp: In method `long unsigned int 
DOM::CSSMediaRuleImpl::insertRule(const DOM::DOMString &, long unsigned int)':
css_ruleimpl.cpp:216: initializing non-const `const QChar *&' with `QChar *' 
will use a temporary
cssparser.h:179: in passing argument 1 of 
`DOM::StyleBaseImpl::parseRule(const QChar *&, const QChar *)'
----

The problem is the prototype of parseRule():

CSSRuleImpl *parseRule(const QChar *&curP, const QChar *endP);

the first argument takes a pointer to a _reference_ instead of just a 
pointer, so the temporary that unicode() returns makes the compiler complain.

Workaround is to use

const QChar *curP = rule.unicode();
CSSRuleImpl *newRule = parseRule( curP, curP + rule.length() );

Question is why behaviour is like this. Is this intended? The combination of 
pointer and reference (and especially the const version of this) sounds a bit 
superfluous to me. And results in hard-to-understand errors...

Martijn

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

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