MantisBT - Rosetta
View Issue Details
0000228Rosetta[All Projects] Bad Codingpublic2013-03-22 17:022013-11-18 16:49
rmoretti 
rmoretti 
normalminoralways
resolvedfixed 
Trunk 
 
many
n/a
36c2c81b7794e1f70a9520da778b3239dc3757a5
0000228: ScoreFunction cloning
Because of the distinction between ScoreFunction and SymmetricScoreFunction (as well as the other ScoreFunction subclasses), you should never use the copy constructor of ScoreFunction() to make a new copy of a ScoreFunction. Use scorefxn.clone() instead.

Note there's no drawback to this, even if you know that you have a true ScoreFunction.
To find potential violators:

egrep -R 'new[[:space:]]*ScoreFunction[[:space:]]*\([^)]' rosetta/rosetta_source/src

Command currently finds 66 instances. Some are valid, like the 7 in will and neil's apps/pilot directories, which are explicitly intended to take a symmetric scorefunction and asymmetrize it. Most of the rest are probably latent bugs.

They'll need to be checked manually, though.
No tags attached.
Issue History
2013-03-22 17:02rmorettiNew Issue
2013-03-22 17:25smlewisNote Added: 0000210
2013-03-22 17:28SergeyNote Added: 0000211
2013-03-24 19:03rmorettiNote Added: 0000212
2013-11-18 16:49rmorettiFixed in SVN Version => 36c2c81b7794e1f70a9520da778b3239dc3757a5
2013-11-18 16:49rmorettiStatusnew => resolved
2013-11-18 16:49rmorettiResolutionopen => fixed
2013-11-18 16:49rmorettiAssigned To => rmoretti

Notes
(0000210)
smlewis   
2013-03-22 17:25   
Is there a future in privatizing the copy operator to force people to use clone? I am guessing not from your notes.
(0000211)
Sergey   
2013-03-22 17:28   
As Steven suggested: How about declare copy constructor and copy operator as private and never define them? That way it will be impossible to copy without clone.
(0000212)
rmoretti   
2013-03-24 19:03   
If we provide a new method for those few people who explicitly want to convert a scorefunction to the base class (with a name that makes it clear that's what they're doing), I think making the copy constructor private might work.