Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Half the recipes in a folder are moved when dragged-and-dropped into another folder #195

Closed
cgiacofei opened this issue Feb 17, 2016 · 3 comments

Comments

@cgiacofei
Copy link

I am experiencing some strange behavior in version 2.3.0.

When a folder containing recipes is dragged inside another folder only some of the recipes in the folder are moved.

At first it appears as though the recipes not moved have disappeared, but after saving and closing Brewtarget the recipes will be in there original location when the software is reopened.

I attached a couple screen shots showing what I am talking about.

recipes

@mikfire
Copy link
Contributor

mikfire commented Feb 19, 2016

It is predictable behavior. You will move n/2 or (n+1)/2 items, depending on if there are an even or odd number of items in the folder you are moving. Subfolders in the folder being moved will make things less predictable.

The work around is mildly annoying. Create the target subfolder(s) and move just the recipes into place.

I will get a patch together later, but I really need to consider what happens when moving folders with multiple subfolders.

mikfire pushed a commit to mikfire/brewtarget that referenced this issue Feb 20, 2016
Moving folders used childCount() as the test condition in a for loop. Because
I moved the children into the new folder, childCount() got decremented by one.
This resulted in the loop counter getting incremented, the test condition
getting decremented and me moving only about half the children.

The fix is a bit more involved, since I don't move folders. I capture the
starting childCount at the start and use that for the test condition, and I
only take the first non-folder child through the whole operation. The only
tricky part is that I don't move folders, so I have to increment a counter to
indicate where the first non-folder item is.
@mikfire
Copy link
Contributor

mikfire commented Feb 20, 2016

Should be closed w/ pul request 197

@rocketman768 rocketman768 changed the title Unexpected behavior with recipe folders Half the recipes in a folder are moved when dragged-and-dropped into another folder Feb 20, 2016
mikfire pushed a commit to mikfire/brewtarget that referenced this issue Feb 21, 2016
The rebase generated way too many collisions. It was faster to create a new
branch.

Moving folders used childCount() as the test condition in a for loop. Because
I moved the children into the new folder, childCount() got decremented by one.
This resulted in the loop counter getting incremented, the test condition
getting decremented and me moving only about half the children.

The fix is a bit more involved, since I don't move folders. I capture the
starting childCount at the start and use that for the test condition, and I
only take the first non-folder child through the whole operation. The only
tricky part is that I don't move folders, so I have to increment a counter to
indicate where the first non-folder item is.
rocketman768 added a commit that referenced this issue Feb 28, 2016
@rocketman768
Copy link
Member

Closed in #200.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants