comparison mainwindow.cpp @ 113:5fc7b4fc77a8

* Better error handling/reporting; some futile changes to termios handling; avoid weirdly stretching panned view in panner
author Chris Cannam
date Fri, 26 Nov 2010 21:04:40 +0000
parents 4bd17f36d059
children bb2d2eecdd60
comparison
equal deleted inserted replaced
112:4bd17f36d059 113:5fc7b4fc77a8
538 } 538 }
539 539
540 params << "clone" << remoteRepoPath << workFolderPath; 540 params << "clone" << remoteRepoPath << workFolderPath;
541 541
542 hgTabs->setWorkFolderAndRepoNames(workFolderPath, remoteRepoPath); 542 hgTabs->setWorkFolderAndRepoNames(workFolderPath, remoteRepoPath);
543 hgTabs->updateWorkFolderFileList("");
543 544
544 runner->requestAction(HgAction(ACT_CLONEFROMREMOTE, workFolderPath, params)); 545 runner->requestAction(HgAction(ACT_CLONEFROMREMOTE, workFolderPath, params));
545 } 546 }
546 547
547 void MainWindow::hgInit() 548 void MainWindow::hgInit()
1008 } 1009 }
1009 1010
1010 void MainWindow::commandFailed(HgAction action, QString stderr) 1011 void MainWindow::commandFailed(HgAction action, QString stderr)
1011 { 1012 {
1012 DEBUG << "MainWindow::commandFailed" << endl; 1013 DEBUG << "MainWindow::commandFailed" << endl;
1013 // runner -> hideProgBar(); 1014
1014 1015 // Some commands we just have to ignore bad return values from:
1015 //!!! N.B hg incoming returns 1 even if successful, if there were no changes 1016
1017 switch(action.action) {
1018 case ACT_NONE:
1019 // uh huh
1020 return;
1021 case ACT_INCOMING:
1022 // returns non-zero code if the check was successful but there
1023 // are no changes pending
1024 return;
1025 case ACT_FOLDERDIFF:
1026 case ACT_FILEDIFF:
1027 case ACT_CHGSETDIFF:
1028 // external program, unlikely to be anything useful in stderr
1029 // and some return with failure codes when something as basic
1030 // as the user closing the window via the wm happens
1031 return;
1032
1033 default:
1034 }
1035
1036 QString command = action.executable;
1037 if (command == "") command = "hg";
1038 foreach (QString arg, action.params) {
1039 command += " " + arg;
1040 }
1041
1042 QString message = tr("<qt><h3>Command failed</h3>"
1043 "<p>The following command failed:</p>"
1044 "<code>%1</code>"
1045 "%2</qt>")
1046 .arg(command)
1047 .arg((stderr.trimmed() != "") ?
1048 tr("<p>Its output said:</p><code>%1</code>")
1049 .arg(xmlEncode(stderr.left(800))
1050 .replace("\n", "<br>"))
1051 : "");
1052
1053 QMessageBox::warning(this, tr("Command failed"), message);
1016 } 1054 }
1017 1055
1018 void MainWindow::commandCompleted(HgAction completedAction, QString output) 1056 void MainWindow::commandCompleted(HgAction completedAction, QString output)
1019 { 1057 {
1020 bool shouldHgStat = false; 1058 bool shouldHgStat = false;
1046 currentBranch = output.trimmed(); 1084 currentBranch = output.trimmed();
1047 hgTabs->setBranch(currentBranch); 1085 hgTabs->setBranch(currentBranch);
1048 break; 1086 break;
1049 1087
1050 case ACT_STAT: 1088 case ACT_STAT:
1051 hgTabs -> updateWorkFolderFileList(output); 1089 hgTabs->updateWorkFolderFileList(output);
1052 updateFileSystemWatcher(); 1090 updateFileSystemWatcher();
1053 break; 1091 break;
1054 1092
1055 case ACT_INCOMING: 1093 case ACT_INCOMING:
1056 case ACT_ANNOTATE: 1094 case ACT_ANNOTATE: