Operating system: Ubuntu 18.04.3 LTS
Short description of error
I discovered this issue when testing with the Blender API in 2.80 but I could reproduce it in 2.81:
It seems that when you trigger a custom operator from a custom "panel button", bpy.context.scene will not update correctly after an immediate scene change by setting bpy.context.window.scene. Although I noticed that if you call the operator directly, for example by searching in the search window, it works just fine.
Code in the operator:
# The original script for scene in context.blend_data.scenes: context.window.scene = scene print(context.scene.name)
Exact steps for others to reproduce the error
1 ) Download test blend file
2 ) Hit "Run Script" in the Text Editor
3 ) Open Scene tab in Properties if it isn't already open
4 ) Hit "Change scenes and print" under "Scene Changer"
5 ) Hit space to open search window, search for "change scenes and print" and click it
Result in console:
Scene.005 Scene.005 Scene.005 Scene.005 Scene.005 Scene.005 Scene Scene.001 Scene.002 Scene.003 Scene.004 Scene.005