[Kde-games-devel] KGameSvgDocument

Kleag kleag at free.fr
Tue Mar 27 09:43:22 CEST 2007


Hello,

I don't understand exactly what happens but if you remove the constness of the 
d pointer, it compiles. As it is private, I'm not sure it's necessary to set 
it const ?
Furthermore I found that about the default assignment operator:
"A number of people also suggested an improvement to my original advice: "If 
you don’t want it, declare it private and give it an empty implementation." 
You actually don’t have to give an unwanted function an implementation at 
all. You can declare the function private and not define it. The declaration 
will suppress the compiler-generated version of the function, but not 
defining it saves you from having to supply dummy code that doesn’t actually 
do anything and will never get called. Furthermore, while declaring the 
function private will prevent outside classes from calling it, it won’t 
prevent the same class from calling it. If you don’t supply an 
implementation, the class will get a link error if it calls its own unwanted 
magic functions. This is somewhat nonintuitive to debug, but it’s better than 
having the compiler silently let the caller get away with calling a function 
nobody’s supposed to call."
here: 
http://www.icu-project.org/docs/papers/cpp_report/the_assignment_operator_revisited.html
I had no time to read it completely but it seems very interesting.

Finaly, there is a constness problem with your elementByUniqueAttributeValue 
method: it cannot be const as it calls setCurrentNode. So, all methods using 
it cannot be const too.

Hope this helps.

Regards,

Kleag
Le mardi 27 mars 2007, Mark A. Taff a écrit :
> On Monday 26 March 2007 12:04:58 Mark A. Taff wrote:
> > I would very much appreciate any critiques on the class, from my coding
> > style, to the api, to help with the d-pointer issue, to anything else
> > obvious to an experienced c++ coder, yet oblivious to me. ;-)
>
> I have made several changes based on feedback from <tsdgeos> (Albert Astals
> Cid) (Thanks!) in #kdegames on freenode:
>
> 1) removed excessive use of the @author tag
> 2) added "const" to the end of the method declarations & definitions for
> accessor methods, as they obviously aren't going to be changing values
> 3) Clarified the documentation for elementById()
> 4) Abstracted elementById() into elementByUniqueAttributeValue(), with
> elementById now a convenience function
> 5) Switched from Latin1 to Utf8 for reading and writing the SVG file
> 6) Reimplemented my d-pointer code, as this has to happen prior to svn
> commit, even though it is currently broken.
>
> This code won't compile due to an unknown issue in my d-pointer setup,
> likely a confusion on my part about const/static.  Even then, it probably
> has another bug relating to passing info between the public and private
> classes, like in setCurrentNode and setCurrentElement.
>
> I haven't tested some of the recent changes (due to the d-pointer issues),
> but I don't forsee any issues with them.
>
> If anyone wants to compile my test app to help figure out what I'm doing
> wrong with my d-pointer, get the code at:
> http://marktaff.com/tmp/kgamelcd/kapp4-20070326.tar.gz
>
> The class in question can be had at:
> http://www.marktaff.com/tmp/kgamelcd/kapp4/kgamesvgdocument.cpp
> http://www.marktaff.com/tmp/kgamelcd/kapp4/kgamesvgdocument.h
>
> I have left the code in an uncompileable state for the night; first time
> ever. Hope it doesn't come back to bite me.
>
> 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



-- 
KsirK - a turn-based strategy game for KDE
http://gna.org/projects/ksirk

KGraphViewer - a GraphViz dot graphs viewer
http://extragear.kde.org/apps/kgraphviewer


More information about the kde-games-devel mailing list