Class: Cosmos::Splash
Defined Under Namespace
Classes: SplashDialogBox
Class Method Summary collapse
Class Method Details
.execute(parent, wait_for_complete = false, &block) ⇒ Object
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 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/cosmos/gui/dialogs/splash.rb', line 82 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 Thread.new do error = nil begin yield dialog rescue Exception => e error = e end @complete = true # 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 unless wait_for_complete # Need to make sure all Qt.execute_in_main_thread() have completed before disposing or # we will segfault Qt::RubyThreadFix.queue.pop.call until Qt::RubyThreadFix.queue.empty? dialog.dispose end end end if wait_for_complete dialog.exec # Need to make sure all Qt.execute_in_main_thread() have completed before disposing or # we will segfault Qt::RubyThreadFix.queue.pop.call until Qt::RubyThreadFix.queue.empty? dialog.dispose end end |