[Kde-games-devel] KGameSvgDocument

Alexander Sopicki nangkar at gmx.info
Tue Mar 27 10:07:40 CEST 2007


Hi, Mark!

I am not an expert of C++ but I think the problem is the following 
assignment in tsvgdigits.cpp:

m_svgDOM = KGameSvgDocument();

m_svgDOM is not a pointer so the assignment is a copy operation (as it 
uses the default assignment operator of C++) of the value on the right 
hand side to the variable on the left hand side. So the compiler tries 
to change the d-pointer of m_svgDOM to the value of the d-pointer on the 
right hand side which will fail as the d-pointer has been declared as 
const in KGameSvgDocument! You could use a non-constant d-pointer but 
this may have nasty side-effects. Just one assignement like the one 
currently in your code and the d-pointer will point somewhere else! I 
think the best thing to do would be using m_svgDOM_ptr for the 
assignment and remove the m_svgDOM variable. You may have to delete the 
pointer explicitly in your destructor of TSvgDigits if you do that but 
I'm not sure about it. Haven't done any C++ for a while.

Hope that'll lighten the problem a little bit.

Regards,

Alex
> The current compile errors are:
>
> /home/kde-devel/kapp4/kgamesvgdocument.h: In member 
> function ‘KGameSvgDocument& KGameSvgDocument::operator=(const 
> KGameSvgDocument&)’:
>
> /home/kde-devel/kapp4/kgamesvgdocument.h:103: error: non-static const 
> member ‘KGameSvgDocumentPrivate* const KGameSvgDocument::d’, can't use 
> default assignment operator
>
> /home/kde-devel/kapp4/tsvgdigits.cpp: In 
> constructor ‘TSvgDigits::TSvgDigits(QString)’:
>
> /home/kde-devel/kapp4/tsvgdigits.cpp:38: note: synthesized 
> method ‘KGameSvgDocument& KGameSvgDocument::operator=(const 
> KGameSvgDocument&)’ first required here
>
> I've googled on "can't use default assignment operator" but haven't found 
> anything meaningful to me.
>
> Night, and thanks for all the help. :-)
>
> Regards,
>
> Mark
> _______________________________________________
> kde-games-devel mailing list
> kde-games-devel at kde.org
> https://mail.kde.org/mailman/listinfo/kde-games-devel
>   



More information about the kde-games-devel mailing list