File tree Expand file tree Collapse file tree 1 file changed +15
-8
lines changed
Expand file tree Collapse file tree 1 file changed +15
-8
lines changed Original file line number Diff line number Diff line change @@ -336,31 +336,38 @@ DeRestPluginPrivate::DeRestPluginPrivate(QObject *parent) :
336336 }
337337
338338 // create default group
339+ // get new id
339340 if (gwGroup0 == 0)
340341 {
341- // get new id and replace old group0 and get new id
342342 for (uint16_t i = 0xFFF0; i > 0; i--) // 0 and larger than 0xfff7 is not valid for Osram Lightify
343343 {
344344 Group* group = getGroupForId(i);
345345 if (!group)
346346 {
347347 gwGroup0 = i;
348- // delete old group 0
349- Group* group = getGroupForId(0);
350- if (group)
351- {
352- group->setState(Group::StateDeleted);
353- }
348+ break;
349+ }
350+ }
351+ }
352+
353+ // delete old group 0
354+ if (gwGroup0 != 0)
355+ {
356+ for (Group& group : groups)
357+ {
358+ if (group.address() == 0 && !(group.state() == Group::StateDeleted || group.state() == Group::StateDeleteFromDB))
359+ {
360+ group.setState(Group::StateDeleted);
354361 queSaveDb(DB_CONFIG | DB_GROUPS, DB_LONG_SAVE_DELAY);
355362 break;
356363 }
357364 }
358365 }
359366
367+ // create new group 0
360368 Group* group = getGroupForId(gwGroup0);
361369 if (!group)
362370 {
363- // new default group
364371 Group group;
365372 group.setAddress(gwGroup0);
366373 group.setName("All");
You can’t perform that action at this time.
0 commit comments