Fix disappearing DKDM folders when dragging a folder into its own child (#2540)
authorCarl Hetherington <cth@carlh.net>
Mon, 29 May 2023 23:29:28 +0000 (01:29 +0200)
committerCarl Hetherington <cth@carlh.net>
Tue, 30 May 2023 09:00:01 +0000 (11:00 +0200)
src/tools/dcpomatic_kdm.cc

index 5393a7fd17476ad0a5cb02da25bbe55c7b49f7bd..12fa614ccabce6f3423336d5ed668eeb5eeef9d8 100644 (file)
@@ -527,6 +527,15 @@ private:
                        group = to->second->parent();
                }
 
+               /* Check we're not adding a group to one of its children */
+               auto to_parent = group;
+               while (to_parent) {
+                       if (from->second == to_parent) {
+                               return;
+                       }
+                       to_parent = to_parent->parent();
+               }
+
                DCPOMATIC_ASSERT (group);
                DCPOMATIC_ASSERT (from->second->parent ());