4646#include < QSaveFile>
4747#include < QStringList>
4848#include < QTextDocument>
49+ #include < QTimer>
4950#include < QTranslator>
5051
5152#include " core/georeferencing.h"
@@ -221,8 +222,12 @@ MapColorMap Map::MapColorSet::importSet(const Map::MapColorSet& other, std::vect
221222 {
222223 colors.reserve (colors.size () + import_count);
223224
224- MapColorSetMergeList merge_list;
225- merge_list.resize (other.colors .size ());
225+ // The conflict resolution algorithm below is simplified by setting
226+ // iterator `selected_item` to a real list element which is not related
227+ // to the actual color sets we are merging. This is the extra element
228+ // identified as `end_of_merge_list`.
229+ MapColorSetMergeList merge_list{other.colors .size () + 1 };
230+ const auto end_of_merge_list = end (merge_list) - 1 ;
226231
227232 bool priorities_changed = false ;
228233
@@ -249,15 +254,15 @@ MapColorMap Map::MapColorSet::importSet(const Map::MapColorSet& other, std::vect
249254 }
250255 ++merge_list_item;
251256 }
252- Q_ASSERT (merge_list_item == merge_list. end () );
257+ Q_ASSERT (merge_list_item == end_of_merge_list );
253258
254259 size_t iteration_number = 1 ;
255260 while (true )
256261 {
257262 // Evaluate bounds and conflicting order of colors
258263 int max_conflict_reduction = 0 ;
259- auto selected_item = merge_list. end ();
260- for (merge_list_item = merge_list. begin (); merge_list_item != merge_list. end () ; ++merge_list_item)
264+ auto selected_item = end_of_merge_list; // Note: non-const copy of an iterator
265+ for (merge_list_item = begin (merge_list ); merge_list_item != end_of_merge_list ; ++merge_list_item)
261266 {
262267 // Check all lower colors for a higher dest_index
263268 std::size_t & lower_bound (merge_list_item->lower_bound );
@@ -281,7 +286,7 @@ MapColorMap Map::MapColorSet::importSet(const Map::MapColorSet& other, std::vect
281286 // Check all higher colors for a lower dest_index
282287 std::size_t & upper_bound (merge_list_item->upper_bound );
283288 upper_bound = merge_list_item->dest_color ? merge_list_item->dest_index : colors.size ();
284- for (++it; it != merge_list. end () ; ++it)
289+ for (++it; it != end_of_merge_list ; ++it)
285290 {
286291 if (it->dest_color )
287292 {
@@ -319,7 +324,7 @@ MapColorMap Map::MapColorSet::importSet(const Map::MapColorSet& other, std::vect
319324 int conflict_reduction = merge_list_item->lower_errors ;
320325 // Check new conflicts with insertion index: (selected_item->lower_bound+1)
321326 it = merge_list_item;
322- for (++it; it != merge_list. end () ; ++it)
327+ for (++it; it != end_of_merge_list ; ++it)
323328 {
324329 if (it->dest_color && (selected_item->lower_bound +1 ) > it->dest_index )
325330 --conflict_reduction;
@@ -337,8 +342,8 @@ MapColorMap Map::MapColorSet::importSet(const Map::MapColorSet& other, std::vect
337342 // Abort if no conflicts or maximum iteration count reached.
338343 // The latter condition is just to prevent endless loops in
339344 // case of bugs and should not occur theoretically.
340- if (selected_item == merge_list. end () ||
341- iteration_number > merge_list.size ())
345+ if (selected_item == end_of_merge_list
346+ || iteration_number > merge_list.size ())
342347 break ;
343348
344349 // Solve selected conflict item
@@ -365,6 +370,8 @@ MapColorMap Map::MapColorSet::importSet(const Map::MapColorSet& other, std::vect
365370 ++iteration_number;
366371 }
367372
373+ merge_list.erase (end_of_merge_list); // no longer needed
374+
368375 // Some missing colors may be spot color compositions which can be
369376 // resolved to new colors only after all colors have been created.
370377 // That is why we create all missing colors first.
@@ -448,9 +455,6 @@ Map::Map()
448455 georeferencing.reset (new Georeferencing ());
449456 init ();
450457
451- connect (this , &Map::symbolAdded, this , &Map::updateSymbolIconZoom, Qt::QueuedConnection);
452- connect (this , &Map::symbolChanged, this , &Map::updateSymbolIconZoom, Qt::QueuedConnection);
453- connect (this , &Map::symbolDeleted, this , &Map::updateSymbolIconZoom, Qt::QueuedConnection);
454458 connect (this , &Map::colorAdded, this , &Map::checkSpotColorPresence);
455459 connect (this , &Map::colorChanged, this , &Map::checkSpotColorPresence);
456460 connect (this , &Map::colorDeleted, this , &Map::checkSpotColorPresence);
@@ -1884,6 +1888,11 @@ int Map::findSymbolIndex(const Symbol* symbol) const
18841888
18851889void Map::setSymbolsDirty ()
18861890{
1891+ if (symbol_icon_scale > 0 )
1892+ {
1893+ symbol_icon_scale = 0 ;
1894+ QTimer::singleShot (0 , this , SLOT (updateSymbolIconZoom ()));
1895+ }
18871896 symbols_dirty = true ;
18881897 setHasUnsavedChanges (true );
18891898}
@@ -1980,6 +1989,8 @@ void Map::updateSymbolIconZoom()
19801989 values.reserve (symbols.size ());
19811990 for (const auto symbol : symbols)
19821991 {
1992+ if (symbol->isHelperSymbol ())
1993+ continue ;
19831994 auto size = symbol->dimensionForIcon ();
19841995 if (size > 0 )
19851996 values.push_back (size);
0 commit comments