Effort/Make Dialogs Asynchronous

From Apache OpenOffice Wiki
< Effort
Revision as of 16:20, 19 April 2006 by Dkeskar (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

As we proceed with the UNO Threading Framework, it becomes necessary to fix asynchronous dialogs so as to avoid deadlocks. This page documents the background, necessary tasks and their status. Thanks to Kai Sommerfeld for providing this information.

Typical Changes - Example

IMO a simple example for the code changes typical for asyncdialog can be found in /svx/source/dialog/cuigaldlg.cxx and the respective header file in the same directory.

There is a class SearchProgress which creates an instance of class SearchThread. The SearchThread worker thread calls back into VCL (e.g. SearchThread::ImplSearch(): mpBrowser->aLbxFound.InsertEntry()).

In asyncdialogs the latter will lead to a deadlock, because:

  • The thread that calls SearchProgress::Execute() thereby enters the Office Mutex threading environment
  • That thread stays there at least until Execute() returns.
  • But Execute() will never return, because it waits for the SearchThread to end.

In fact it waits indefinetly that CleanUpHdl will be called (handler calls EndDialog() and this will let Execute() return), which is only done from inside SearchThread::onTerminated(). But the worker thread only terminates if it is ably to deliver search results to VCL, but it will never be able to do so because every VCL call will automatically guarded by the Office Mutex threading environment...

The solution was to switch to the new asyncdialog VCL Dialog execution API.

Personal tools