Class: Cosmos::Splash
Defined Under Namespace
Classes: SplashDialogBox
Class Method Summary collapse
Class Method Details
.execute(parent, wait_for_complete = false, &block) ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/cosmos/gui/dialogs/splash.rb', line 74 def self.execute(parent, wait_for_complete = false, &block) # Create the dialog and show it dialog = SplashDialogBox.new(parent) dialog.show unless wait_for_complete dialog.raise # Create a new thread to run the block # WARNING! If you need to update your own gui you must wrap it with: # Qt.execute_in_main_thread(true) do # < Update the GUI > # end complete = false Thread.new do error = nil begin yield dialog rescue Exception => e error = e end # If the block threw an error show it before allowing the application to crash if error Qt.execute_in_main_thread(true) do ExceptionDialog.new(parent, error, "Error During Startup") end end Qt.execute_in_main_thread(true) do # Once the block has completed we hide and dispose the dialog to allow the main application to take over dialog.hide dialog.dispose unless wait_for_complete end complete = true end dialog.exec if wait_for_complete dialog.dispose if wait_for_complete end |