Strangely, I fixed the issue by a new import of the project. Perhaps the modifications I had made on the old objects were causing some inconsistencies, so it paid off to delete the problematic objects and re-import them (or the whole project, just to be on the safe side). Luckily, there were not so many grids and queries in my case. The problem hasn't appeared since then.
Thank you all for the support!