Because some versions of Qt require a non-const QRegExp, we copy _embedInfos to

a non-const variable:

EmbedInHtml embedInfos(_embedInfos) ;

However, since EmbedInHtml is the base class we lose any information added in
the derived class, which causes a problem with EmbedInHtmlImg when we do a
static_cast to what should have been the proper type here:

const EmbedInHtmlImg& embedImg = static_cast<const EmbedInHtmlImg&>(embedInfos);

embedInfos is not an EmbedInHtmlImg any more, just a mere EmbedInHtml.

We could const_cast the QRegExp object instead but let's keep it simple and
remove the embedInfos constness from the method's signature.


git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3078 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
leander-256 2010-06-07 00:49:26 +00:00
parent 749945dda8
commit 5f2f87537b
2 changed files with 2 additions and 4 deletions

View File

@ -55,10 +55,8 @@ void EmbedInHtmlImg::InitFromAwkwardHash(const QHash< QString, QString >& hash)
* @param[in,out] currentElement The current node (which is of type Element)
* @param[in] embedInfos The regular expression and the type of embedding to use
*/
void embedHtml(QDomDocument& doc, QDomElement& currentElement, const EmbedInHtml& _embedInfos)
void embedHtml(QDomDocument& doc, QDomElement& currentElement, EmbedInHtml& embedInfos)
{
EmbedInHtml embedInfos(_embedInfos) ;
if(embedInfos.myRE.pattern().length() == 0) // we'll get stuck with an empty regexp
return;

View File

@ -103,7 +103,7 @@ public:
};
void embedHtml(QDomDocument& doc, QDomElement& currentElement, const EmbedInHtml& embedInfos);
void embedHtml(QDomDocument& doc, QDomElement& currentElement, EmbedInHtml& embedInfos);
} // namespace RsChat