fix #40056: Crash by selecting twice or once all similar elements