Skip to content

Commit 96b1c96

Browse files
KodeCRmanup
authored andcommitted
Fix old group0 delete
1 parent 1bacf46 commit 96b1c96

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

de_web_plugin.cpp

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff 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");

0 commit comments

Comments
 (0)