Bug 111304 - const in adviseFast incorrect should removed
Summary: const in adviseFast incorrect should removed
Status: RESOLVED FIXED
Alias: None
Product: kmines
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: Hadacek Nicolas
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-08-22 22:53 UTC by Garrett Kajmowicz
Modified: 2005-08-25 22:54 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Garrett Kajmowicz 2005-08-22 22:53:14 UTC
Version:            (using KDE KDE 3.4.2)
Installed from:    Compiled From Sources

adviseFast.cpp for kmines inappropriately uses a const reference.   This causes const_iterators to attempt to be turned into regular iterators which is a bad thing and violates C++ spec.  Attached is a patch.  Please test and apply.
Comment 1 Garrett Kajmowicz 2005-08-22 22:53:50 UTC
diff -ru kdegames-3.4.2/kmines/solver/adviseFast.cpp kdegames-3.4.2-gk/kmines/solver/adviseFast.cpp
--- kdegames-3.4.2/kmines/solver/adviseFast.cpp 2005-05-23 08:05:21.000000000 -0400
+++ kdegames-3.4.2-gk/kmines/solver/adviseFast.cpp      2005-08-22 16:44:51.000000000 -0400
@@ -131,7 +131,7 @@
                // at least one fact, but don't want to waste time
                // proving it :)
                if(_containingFacts.count(*i)){
-                       CoordSet const &affF = _containingFacts[*i];
+                       CoordSet &affF = _containingFacts[*i];
                        affectedFacts->insert(
                                affF.begin(), affF.end());
                        for(    j=affF.begin();
@@ -163,7 +163,7 @@
        // at least one fact, but don't want to waste time
        // proving it :)
        if(_containingFacts.count(point)){
-               CoordSet const &affF = _containingFacts[point];
+               CoordSet &affF = _containingFacts[point];
                affectedFacts->insert(affF.begin(), affF.end());
                CoordSet::iterator i;
                for(i=affF.begin(); i!=affF.end(); ++i){
Comment 2 Hadacek Nicolas 2005-08-25 22:54:56 UTC
I just commited this patch (this really ought to be const_iterator afaik)

Index: solver/adviseFast.cpp
===================================================================
--- solver/adviseFast.cpp	(revision 453254)
+++ solver/adviseFast.cpp	(working copy)
@@ -124,7 +124,7 @@
 	autorevealed.insert(point);
 	affectedFacts->insert(autorevealed.begin(), autorevealed.end());
 
-	CoordSet::iterator i, j;
+	CoordSet::const_iterator i;
 	for(i=autorevealed.begin(); i!=autorevealed.end(); ++i)
 	{
 		// I still think that each poing will belong to
@@ -134,7 +134,7 @@
 			CoordSet const &affF = _containingFacts[*i];
 			affectedFacts->insert(
 				affF.begin(), affF.end());
-			for(	j=affF.begin();
+			for(CoordSet::const_iterator j=affF.begin();
 				j!=affF.end();
 				++j)
 			{
@@ -165,8 +165,7 @@
 	if(_containingFacts.count(point)){
 		CoordSet const &affF = _containingFacts[point];
 		affectedFacts->insert(affF.begin(), affF.end());
-		CoordSet::iterator i;
-		for(i=affF.begin(); i!=affF.end(); ++i){
+		for(CoordSet::const_iterator i=affF.begin(); i!=affF.end(); ++i){
 			(*this)[*i].pointSet.erase(point);
 			(*this)[*i].mines--;
 			if((*this)[*i].pointSet.empty())