@@ -197,24 +197,23 @@ void MaskRomTool::clear(){
197
197
// Select nothing.
198
198
scene->selection =QList<QGraphicsItem*>();
199
199
200
- foreach (RomBitItem* item, bits)
201
- delete item ;
200
+ for ( auto i=bits. constBegin (); i!= bits. constEnd (); i++ )
201
+ delete *i ;
202
202
bits.clear ();
203
203
assert (bits.isEmpty ());
204
204
bits.empty ();
205
- foreach (RomBitFix* item, bitfixes)
206
- delete item ;
205
+ for ( auto i=bitfixes. constBegin (); i!= bitfixes. constEnd (); i++ )
206
+ delete *i ;
207
207
bitfixes.clear ();
208
-
209
208
assert (bitfixes.isEmpty ());
210
209
bitfixes.empty ();
211
- foreach (RomLineItem* item, rows)
212
- delete item ;
210
+ for ( auto i = rows. constBegin (); i != rows. constEnd (); i++ )
211
+ delete *i ;
213
212
rows.clear ();
214
213
assert (rows.isEmpty ());
215
214
rows.empty ();
216
- foreach (RomLineItem* item, cols)
217
- delete item ;
215
+ for ( auto i = cols. constBegin (); i != cols. constEnd (); i++ )
216
+ delete *i ;
218
217
cols.clear ();
219
218
assert (cols.isEmpty ());
220
219
cols.empty ();
@@ -549,14 +548,14 @@ void MaskRomTool::setLinesVisible(bool b){
549
548
}
550
549
void MaskRomTool::setBitsVisible (bool b){
551
550
bitsVisible=b; // Default for new bits.
552
- foreach (QGraphicsItem* item, bits)
553
- item ->setVisible (b);
554
- foreach (QGraphicsItem* item, bitfixes)
555
- item ->setVisible (b);
551
+ for ( auto i=bits. constBegin (); i!= bits. constEnd (); i++ )
552
+ (*i) ->setVisible (b);
553
+ for ( auto i=bitfixes. constBegin (); i!= bitfixes. constEnd (); i++ )
554
+ (*i) ->setVisible (b);
556
555
}
557
556
void MaskRomTool::setViolationsVisible (bool b){
558
- foreach (QGraphicsItem* item, violations)
559
- item ->setVisible (b);
557
+ for ( auto i=violations. constBegin (); i!= violations. constEnd (); i++ )
558
+ (*i) ->setVisible (b);
560
559
}
561
560
562
561
// Highlights one item close to the center.
@@ -1047,8 +1046,8 @@ void MaskRomTool::updateThresholdHistogram(bool force){
1047
1046
reds[i]=greens[i]=blues[i]=0 ;
1048
1047
1049
1048
// Count the bits of each color.
1050
- foreach (RomBitItem* bit, bits){
1051
- long pixel=bit ->bitvalue_raw (this , background);
1049
+ for ( auto i=bits. constBegin (); i!= bits. constEnd (); i++ ){
1050
+ long pixel=(*i) ->bitvalue_raw (this , background);
1052
1051
int r=((pixel>>16 )&0xFF );
1053
1052
int g=((pixel>>8 )&0xFF );
1054
1053
int b=((pixel)&0xFF );
@@ -1137,10 +1136,10 @@ void MaskRomTool::setBitSize(qreal size){
1137
1136
bitSize=size;
1138
1137
1139
1138
// We do not remark the bits here, but we do resize them.
1140
- foreach (RomBitItem* bit, bits)
1141
- bit ->setBitSize (bitSize);
1142
- foreach (RomBitFix* fix, bitfixes)
1143
- fix ->setBitSize (bitSize);
1139
+ for ( auto i=bits. constBegin (); i!= bits. constEnd (); i++ )
1140
+ (*i) ->setBitSize (bitSize);
1141
+ for ( auto i=bitfixes. constBegin (); i!= bitfixes. constEnd (); i++ )
1142
+ (*i) ->setBitSize (bitSize);
1144
1143
1145
1144
// Violations are not dynamically resized.
1146
1145
RomRuleViolation::bitSize=bitSize;
@@ -1645,6 +1644,7 @@ void MaskRomTool::clearBits(bool full){
1645
1644
* wipe away bits without hogging the redraw thread. Like markBits(),
1646
1645
* it might take a few frames to finish on large projects.
1647
1646
*/
1647
+ /* Older method, supported partial erase but performed deep copies.
1648
1648
foreach(QGraphicsItem* item, bits){
1649
1649
if(isPointVisible(item->pos())){
1650
1650
scene->removeItem(item);
@@ -1667,18 +1667,28 @@ void MaskRomTool::clearBits(bool full){
1667
1667
return;
1668
1668
}
1669
1669
}
1670
-
1671
1670
//For a full erase, we eliminate items in bulk.
1672
1671
if(full)
1673
1672
bits.clear();
1673
+ */
1674
+
1675
+ // This avoids a deep copy, but cannot be partial.
1676
+ for (auto i=bits.constBegin (); i!=bits.constEnd (); i++){
1677
+ scene->removeItem (*i);
1678
+ delete *i;
1679
+ bitcount--;
1680
+ }
1681
+ bits.clear ();
1682
+
1683
+
1674
1684
assert (bits.isEmpty ());
1675
1685
1676
1686
1677
1687
// Reset the markers so we can start again.
1678
- foreach (RomLineItem* line, rows)
1679
- line ->marked =false ;
1680
- foreach (RomLineItem* line, cols)
1681
- line ->marked =false ;
1688
+ for ( auto i = rows. constBegin (); i != rows. constEnd (); i++ )
1689
+ (*i) ->marked =false ;
1690
+ for ( auto i = cols. constBegin (); i != cols. constEnd (); i++ )
1691
+ (*i) ->marked =false ;
1682
1692
1683
1693
// Next step is to mark the bits.
1684
1694
bitcount=0 ;
@@ -1710,9 +1720,9 @@ void MaskRomTool::markFixes(){
1710
1720
1711
1721
// Marks up all of the known bits with new samples.
1712
1722
void MaskRomTool::remarkBits (){
1713
- foreach (RomBitItem* bit, bits){
1714
- bit ->bitvalue_raw (this , background);
1715
- bit ->bitvalue_sample (this , background, thresholdR, thresholdG, thresholdB);
1723
+ for ( auto i=bits. constBegin (); i!= bits. constEnd (); i++ ){
1724
+ (*i) ->bitvalue_raw (this , background);
1725
+ (*i) ->bitvalue_sample (this , background, thresholdR, thresholdG, thresholdB);
1716
1726
}
1717
1727
// We remark all fixes here, because it's fast.
1718
1728
markFixes ();
@@ -1983,15 +1993,15 @@ void MaskRomTool::highlightAdrRange(uint32_t start, uint32_t end){
1983
1993
// Update the decoding and mark the bits.
1984
1994
gatorom ();
1985
1995
1986
- foreach (RomBitItem* b, bits){
1987
- uint32_t a=b ->adr ;
1996
+ for ( auto i=bits. constBegin (); i!= bits. constEnd (); i++ ){
1997
+ uint32_t a=(*i) ->adr ;
1988
1998
1989
1999
if (start<=a && a<=end){
1990
- RomRuleViolation* violation=new RomRuleViolation (b ->pos (),
2000
+ RomRuleViolation* violation=new RomRuleViolation ((*i) ->pos (),
1991
2001
QString::asprintf (" bit&0x%02x at 0x%04x" ,
1992
- (unsigned int ) b ->mask ,a),
2002
+ (unsigned int ) (*i) ->mask ,a),
1993
2003
QString::asprintf (" bit&0x%02x at 0x%04x" ,
1994
- (unsigned int ) b ->mask ,a));
2004
+ (unsigned int ) (*i) ->mask ,a));
1995
2005
violation->error =false ;
1996
2006
addViolation (violation);
1997
2007
}
0 commit comments