hildogjr / KiCost

Build cost spreadsheet for a KiCad project.
MIT License
496 stars 97 forks source link

Fix the GUI messages #454

Closed set-soft closed 3 years ago

set-soft commented 3 years ago
set-soft commented 3 years ago

Some comments about:

  1. I underestimated the muti-thread problem. My previous patch fixed the GUI crash, but also blocked the GUI ;-)
  2. The main problem is that only the main thread can touch the GUI. Other threads must pass the calls using things like wx.CallAfter()
  3. We needed some mechanism to notify the end of the KiCost work.
  4. The trick used to redirect log messages wasn't enough. In fact it just redirected print because the default stream for logging is stderr, which is currently used by the progress bar. And what is worst, once you initialized a logger changing sys.stderr does nothing, because the logger has its own copy. So I delayed the logger initialization so the GUI code can use the fake stream for the logger.
hildogjr commented 3 years ago

I will merger this since this fix a lot of GUI issues. But GUI still needing some work.