Rev 962: Land the fix for bug #430232 (in 0.14) onto qbzr trunk. in http://bazaar.launchpad.net/~qbzr-dev/qbzr/trunk

John Arbash Meinel john at arbash-meinel.com
Wed Sep 16 00:38:25 BST 2009


At http://bazaar.launchpad.net/~qbzr-dev/qbzr/trunk

------------------------------------------------------------
revno: 962 [merge]
revision-id: john at arbash-meinel.com-20090915233625-2e76wb3yl96dudf9
parent: garyvdm at gmail.com-20090915130343-wa5hctc2o6ih2i4a
parent: john at arbash-meinel.com-20090915232926-ycnnq3pzz4dt2gav
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: trunk
timestamp: Tue 2009-09-15 18:36:25 -0500
message:
  Land the fix for bug #430232 (in 0.14) onto qbzr trunk.
modified:
  NEWS.txt                       news.txt-20061226160737-3n8nxv62u38vua63-1
  lib/commands.py                __init__.py-20060903002740-glmbpafh1ov9i46h-1
-------------- next part --------------
=== modified file 'NEWS.txt'
--- a/NEWS.txt	2009-09-10 20:41:55 +0000
+++ b/NEWS.txt	2009-09-15 23:36:25 +0000
@@ -9,6 +9,14 @@
 0.14.2 - in development
 -----------------------
 
+ * qmerge, qcommit, ...:
+   * Fixed a bug where we create the QApp after opening a Branch, but we had
+     already installed the QUIFactory(). A branch can be a lightweight checkout
+     of a remote location which requires a password. Which wants to open a UI
+     dialog, which causes a crash because QApp has not been created yet.
+     (#430232, John Arbash Meinel)
+
+
 0.14.1 - 2009-09-10
 -------------------
 Maintenance release:

=== modified file 'lib/commands.py'
--- a/lib/commands.py	2009-08-31 09:36:23 +0000
+++ b/lib/commands.py	2009-09-15 23:36:25 +0000
@@ -150,6 +150,11 @@
     @install_gettext
     @report_missing_pyqt
     def run(self, *args, **kwargs):
+        # We must create the QApplication before we install the QUIFactory.
+        # This is because once the factory is installed, it is possible that
+        # opening a branch, etc will go to the ui_factory to request a
+        # password, and the app must exist before the dialog can be created.
+        self._application = QtGui.QApplication(sys.argv)
         ui.ui_factory = QUIFactory()
         
         # Set up global exception handling.
@@ -258,14 +263,13 @@
 
     def _qbzr_run(self, filename=None, revision=None, encoding=None,
                   ui_mode=False, no_graph=False):
-        app = QtGui.QApplication(sys.argv)
         win = AnnotateWindow(None, None, None, None,
                              encoding=encoding, ui_mode=ui_mode,
                              loader=self._load_branch,
                              loader_args=(filename, revision),
                              no_graph=no_graph)
         win.show()
-        app.exec_()
+        self._application.exec_()
 
 
 class cmd_qadd(QBzrCommand):
@@ -277,10 +281,9 @@
         tree, selected_list = builtins.tree_files(selected_list)
         if selected_list == ['']:
             selected_list = []
-        application = QtGui.QApplication(sys.argv)
         self.main_window = AddWindow(tree, selected_list, dialog=False, ui_mode=ui_mode)
         self.main_window.show()
-        application.exec_()
+        self._application.exec_()
 
 
 class cmd_qrevert(QBzrCommand):
@@ -292,12 +295,11 @@
         tree, selected_list = builtins.tree_files(selected_list)
         if selected_list == ['']:
             selected_list = []
-        application = QtGui.QApplication(sys.argv)
         self.main_window = RevertWindow(tree, selected_list, dialog=False,
             ui_mode=ui_mode,
             backup=not no_backup)
         self.main_window.show()
-        application.exec_()
+        self._application.exec_()
 
 
 class cmd_qconflicts(QBzrCommand):
@@ -308,10 +310,9 @@
 
     def _qbzr_run(self):
         from bzrlib.plugins.qbzr.lib.conflicts import ConflictsWindow
-        application = QtGui.QApplication(sys.argv)
         self.main_window = ConflictsWindow(u'.')
         self.main_window.show()
-        application.exec_()
+        self._application.exec_()
 
 
 class cmd_qbrowse(QBzrCommand):
@@ -321,13 +322,12 @@
     aliases = ['qbw']
 
     def _qbzr_run(self, revision=None, location=None):
-        app = QtGui.QApplication(sys.argv)
         if revision is None:
             win = BrowseWindow(location = location)
         else:
             win = BrowseWindow(location = location, revision = revision[0])
         win.show()
-        app.exec_()
+        self._application.exec_()
 
 
 class cmd_qcommit(QBzrCommand):
@@ -344,11 +344,10 @@
         tree, selected_list = builtins.tree_files(selected_list)
         if selected_list == ['']:
             selected_list = []
-        application = QtGui.QApplication(sys.argv)
         self.main_window = CommitWindow(tree, selected_list, dialog=False,
             message=message, local=local, ui_mode=ui_mode)
         self.main_window.show()
-        application.exec_()
+        self._application.exec_()
 
 
 class cmd_qdiff(QBzrCommand, DiffArgProvider):
@@ -439,14 +438,13 @@
         self.old = old
         self.new = new
 
-        app = QtGui.QApplication(sys.argv)
         window = DiffWindow(self,
                             complete=complete,
                             encoding=encoding,
                             filter_options=filter_options,
                             ui_mode=ui_mode)
         window.show()
-        app.exec_()
+        self._application.exec_()
 
 
 class cmd_qlog(QBzrCommand):
@@ -476,11 +474,10 @@
                     ]
 
     def _qbzr_run(self, locations_list, ui_mode=False, no_graph=False):
-        app = QtGui.QApplication(sys.argv)
         window = LogWindow(locations_list, None, None, ui_mode=ui_mode,
                            no_graph=no_graph)
         window.show()
-        app.exec_()
+        self._application.exec_()
 
 
 class cmd_qconfig(QBzrCommand):
@@ -491,10 +488,9 @@
     aliases = ['qconfigure']
 
     def _qbzr_run(self):
-        app = QtGui.QApplication(sys.argv)
         window = QBzrConfigWindow()
         window.show()
-        app.exec_()
+        self._application.exec_()
 
 
 class cmd_qcat(QBzrCommand):
@@ -528,11 +524,10 @@
             return int(not result)
 
 
-        app = QtGui.QApplication(sys.argv)
         window = QBzrCatWindow(filename = filename, revision = revision,
                                encoding = encoding)
         window.show()
-        app.exec_()
+        self._application.exec_()
 
 
 class cmd_qpull(QBzrCommand):
@@ -556,14 +551,13 @@
         except errors.NoWorkingTree:
             tree_to = None
             branch_to = Branch.open_containing(directory)[0]
-        app = QtGui.QApplication(sys.argv)
         self.main_window = QBzrPullWindow(branch_to, tree_to, location,
                                 remember=remember,
                                 overwrite=overwrite,
                                 revision=revision,
                                 ui_mode=ui_mode)
         self.main_window.show()
-        app.exec_()
+        self._application.exec_()
 
 
 class cmd_qmerge(QBzrCommand):
@@ -587,12 +581,11 @@
         except errors.NoWorkingTree:
             tree_to = None
             branch_to = Branch.open_containing(directory)[0]
-        app = QtGui.QApplication(sys.argv)
         self.main_window = QBzrMergeWindow(branch_to, tree_to, location,
             revision=revision, remember=remember, force=force,
             uncommitted=uncommitted, ui_mode=ui_mode)
         self.main_window.show()
-        app.exec_()
+        self._application.exec_()
 
 
 class cmd_qpush(QBzrCommand):
@@ -619,7 +612,6 @@
         except errors.NoWorkingTree:
             tree_to = None
             branch_to = Branch.open_containing(directory)[0]
-        app = QtGui.QApplication(sys.argv)
         self.main_window = QBzrPushWindow(branch_to, tree_to,
                                 location=location,
                                 create_prefix=create_prefix,
@@ -628,7 +620,7 @@
                                 overwrite=overwrite,
                                 ui_mode=ui_mode)
         self.main_window.show()
-        app.exec_()
+        self._application.exec_()
 
 
 class cmd_qbranch(QBzrCommand):
@@ -640,11 +632,10 @@
 
     def _qbzr_run(self, from_location=None, to_location=None,
                   revision=None, ui_mode=False):
-        app = QtGui.QApplication(sys.argv)
         self.main_window = QBzrBranchWindow(from_location, to_location,
                                   revision=revision, ui_mode=ui_mode)
         self.main_window.show()
-        app.exec_()
+        self._application.exec_()
 
 
 class cmd_qinfo(QBzrCommand):
@@ -654,10 +645,9 @@
     takes_args = ['location?']
 
     def _qbzr_run(self, location=u'.'):
-        app = QtGui.QApplication(sys.argv)
         window = QBzrInfoWindow(location)
         window.show()
-        app.exec_()
+        self._application.exec_()
 
 
 class cmd_qinit(QBzrCommand):
@@ -667,10 +657,9 @@
     takes_args = ['location?']
 
     def _qbzr_run(self, location=u'.', ui_mode=False):
-        app = QtGui.QApplication(sys.argv)
         self.main_window = QBzrInitWindow(location, ui_mode=ui_mode)
         self.main_window.show()
-        app.exec_()
+        self._application.exec_()
 
 
 class cmd_merge(bzrlib.builtins.cmd_merge, DiffArgProvider):
@@ -709,10 +698,9 @@
         
         self.merger = merger
         try:
-            application = QtGui.QApplication(sys.argv)
             window = DiffWindow(self, encoding=self._encoding)
             window.show()
-            application.exec_()
+            self._application.exec_()
         finally:
             if self.tt:
                 self.tt.finalize()
@@ -745,11 +733,10 @@
             BzrDirFormat.unregister_control_format(SvnWorkingTreeDirFormat)
             format_registry.remove('subversion-wc')
         # Start QBzr
-        app = QtGui.QApplication(sys.argv)
         window = QBzrMainWindow()
         window.setDirectory(osutils.realpath(u'.'))
         window.show()
-        app.exec_()
+        self._application.exec_()
 
 
 class cmd_qsubprocess(Command):
@@ -825,7 +812,7 @@
             window = UpdateBranchWindow(tb.branch, ui_mode=ui_mode)
         self.main_window = window
         self.main_window.show()
-        app.exec_()
+        self._application.exec_()
 
 
 class cmd_qgetnew(QBzrCommand):
@@ -837,10 +824,9 @@
 
     def _qbzr_run(self, location=u".", ui_mode=False):
         from bzrlib.plugins.qbzr.lib.getnew import GetNewWorkingTreeWindow
-        app = QtGui.QApplication(sys.argv)
         self.main_window = GetNewWorkingTreeWindow(location, ui_mode=ui_mode)
         self.main_window.show()
-        app.exec_()
+        self._application.exec_()
 
 
 class cmd_qhelp(QBzrCommand):
@@ -852,9 +838,8 @@
     hidden = True
 
     def _qbzr_run(self, topic):
-        app = QtGui.QApplication(sys.argv)
         window = show_help(topic)
-        app.exec_()
+        self._application.exec_()
 
 
 class cmd_qtag(QBzrCommand):
@@ -874,11 +859,10 @@
         branch = Branch.open_containing(directory)[0]
         # determine action based on given options
         action = TagWindow.action_from_options(force=force, delete=delete)
-        app = QtGui.QApplication(sys.argv)
         self.main_window = TagWindow(branch, tag_name=tag_name, action=action,
             revision=revision, ui_mode=ui_mode)
         self.main_window.show()
-        app.exec_()
+        self._application.exec_()
 
 
 class cmd_quncommit(QBzrCommand):
@@ -890,10 +874,9 @@
     takes_args = ["location?"]
 
     def _qbzr_run(self, location=u'.', ui_mode=False):
-        app = QtGui.QApplication(sys.argv)
         window = QBzrUncommitWindow(location, ui_mode=ui_mode)
         window.show()
-        app.exec_()
+        self._application.exec_()
 
 
 class cmd_qviewer(QBzrCommand):
@@ -907,10 +890,9 @@
     _see_also = ['qcat']
 
     def _qbzr_run(self, filename, encoding=None):
-        app = QtGui.QApplication(sys.argv)
         window = QBzrViewWindow(filename=filename, encoding=encoding)
         window.show()
-        app.exec_()
+        self._application.exec_()
 
 
 class cmd_qversion(QBzrCommand):
@@ -921,10 +903,9 @@
 
     def _qbzr_run(self):
         from bzrlib.plugins.qbzr.lib.sysinfo import QBzrSysInfoWindow
-        application = QtGui.QApplication(sys.argv)
         window = QBzrSysInfoWindow()
         window.show()
-        application.exec_()
+        self._application.exec_()
 
 
 class cmd_qplugins(QBzrCommand):
@@ -936,10 +917,9 @@
 
     def _qbzr_run(self):
         from bzrlib.plugins.qbzr.lib.plugins import QBzrPluginsWindow
-        app = QtGui.QApplication(sys.argv)
         window = QBzrPluginsWindow()
         window.show()
-        app.exec_()
+        self._application.exec_()
 
 
 class cmd_qupdate(QBzrCommand):
@@ -949,13 +929,12 @@
     takes_options = [ui_mode_option]
 
     def _qbzr_run(self, directory=None, ui_mode=False):
-        application = QtGui.QApplication(sys.argv)
         tree = open_tree(directory, ui_mode)
         if tree is None:
             return
         self.main_window = QBzrUpdateWindow(tree, ui_mode)
         self.main_window.show()
-        application.exec_()
+        self._application.exec_()
 
 
 class cmd_qsend(QBzrCommand):
@@ -966,10 +945,9 @@
     
     def _qbzr_run(self, submit_branch=".", public_branch=None, ui_mode=False):
         branch = Branch.open_containing(submit_branch)[0]
-        app = QtGui.QApplication(sys.argv)
         window = SendWindow(branch, ui_mode)
         window.show()
-        app.exec_()
+        self._application.exec_()
 
 
 class cmd_qswitch(QBzrCommand):
@@ -981,12 +959,11 @@
     def _qbzr_run(self, location=None, ui_mode=False):
         from bzrlib.plugins.qbzr.lib.switch import QBzrSwitchWindow
         
-        application = QtGui.QApplication(sys.argv)
         branch = Branch.open_containing(".")[0]
         bzrdir = BzrDir.open_containing(".")[0]
         self.main_window = QBzrSwitchWindow(branch, bzrdir, location, ui_mode)
         self.main_window.show()
-        application.exec_() 
+        self._application.exec_() 
 
 
 class cmd_qunbind(QBzrCommand):
@@ -996,14 +973,13 @@
     def _qbzr_run(self, ui_mode=False):
         from bzrlib.plugins.qbzr.lib.unbind import QBzrUnbindDialog
         
-        application = QtGui.QApplication(sys.argv)
         branch = Branch.open_containing(".")[0]
         if branch.get_bound_location() == None:
             raise errors.BzrCommandError("This branch is not bound.")
         
         self.main_window = QBzrUnbindDialog(branch, ui_mode)
         self.main_window.show()
-        application.exec_() 
+        self._application.exec_() 
 
 
 class cmd_qexport(QBzrCommand):
@@ -1020,7 +996,6 @@
     def _qbzr_run(self, dest=None, branch_or_subdir=None, ui_mode=False):
         from bzrlib.plugins.qbzr.lib.export import QBzrExportDialog
         
-        application = QtGui.QApplication(sys.argv)
         if branch_or_subdir == None:
             branch = Branch.open_containing(".")[0]
         else:
@@ -1028,7 +1003,7 @@
         
         window = QBzrExportDialog(dest, branch, ui_mode)
         window.show()
-        application.exec_() 
+        self._application.exec_() 
 
 
 class cmd_qbind(QBzrCommand):
@@ -1043,13 +1018,11 @@
     def _qbzr_run(self, location=None, ui_mode=False):
         from bzrlib.plugins.qbzr.lib.bind import QBzrBindDialog
         
-        application = QtGui.QApplication(sys.argv)
-
         branch = Branch.open_containing(".")[0]
         
         self.main_window = QBzrBindDialog(branch, location, ui_mode)
         self.main_window.show()
-        application.exec_()
+        self._application.exec_()
 
 
 class cmd_qrun(QBzrCommand):
@@ -1066,7 +1039,6 @@
 
     def _qbzr_run(self, ui_mode=False, directory=None):
         from bzrlib.plugins.qbzr.lib.run import QBzrRunDialog
-        app = QtGui.QApplication(sys.argv)
         window = QBzrRunDialog(workdir=directory, ui_mode=ui_mode)
         window.show()
-        app.exec_()
+        self._application.exec_()



More information about the bazaar-commits mailing list