Issue 5218, fix of deadlock in StatisticsChart on Windows XP and Win7.

svn: r18613
This commit is contained in:
Peter Landgren 2011-12-17 13:57:50 +00:00
parent 739cbdfdb9
commit 5a28c86ae7

View File

@ -51,7 +51,7 @@ import gtk
from gen.ggettext import gettext as _ from gen.ggettext import gettext as _
import config import config
import Errors import Errors
from gui.utils import ProgressMeter, open_file_with_default_application from gui.utils import open_file_with_default_application
from QuestionDialog import ErrorDialog, OptionDialog from QuestionDialog import ErrorDialog, OptionDialog
from gen.plug.report import (CATEGORY_TEXT, CATEGORY_DRAW, CATEGORY_BOOK, from gen.plug.report import (CATEGORY_TEXT, CATEGORY_DRAW, CATEGORY_BOOK,
CATEGORY_CODE, CATEGORY_WEB, CATEGORY_GRAPHVIZ, CATEGORY_CODE, CATEGORY_WEB, CATEGORY_GRAPHVIZ,
@ -70,43 +70,6 @@ import Utils
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
URL_REPORT_PAGE = URL_MANUAL_PAGE + "_-_Reports" URL_REPORT_PAGE = URL_MANUAL_PAGE + "_-_Reports"
#-------------------------------------------------------------------------------
#
# Private Functions
#
#-------------------------------------------------------------------------------
def _run_long_process_in_thread(func, header):
"""
This function will spawn a new thread to execute the provided function.
While the function is running, a progress bar will be created.
The progress bar will show activity while the function executes.
@param func: A function that will take an unknown amount of time to
complete.
@type category: callable
@param header: A header for the progress bar.
Example: "Updating Data"
@type name: string
@return: nothing
"""
pbar = ProgressMeter(_('Processing File'))
pbar.set_pass(total=40,
mode=ProgressMeter.MODE_ACTIVITY,
header=header)
sys_thread = threading.Thread(target=func)
sys_thread.start()
while sys_thread.isAlive():
# The loop runs 20 times per second until the thread completes.
# With the progress pass total set at 40, it should move across the bar
# every two seconds.
time.sleep(0.05)
pbar.step()
pbar.close()
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# ReportDialog class # ReportDialog class
@ -703,7 +666,7 @@ def report(dbstate, uistate, person, report_class, options_class,
# bar. So the progress bar should not be used. # bar. So the progress bar should not be used.
do_report() do_report()
else: else:
_run_long_process_in_thread(do_report, dialog.report_name) do_report()
if dialog.open_with_app.get_active(): if dialog.open_with_app.get_active():
out_file = dialog.options.get_output() out_file = dialog.options.get_output()