Fixed fossil process termination on Windows
Abstracted fossil ui url Added (disabled) code to detect fossil ui launch port FossilOrigin-Name: e8b33f373c855cce60dd9fc528b7684f85849d5d
This commit is contained in:
		| @@ -639,7 +639,11 @@ bool MainWindow::runFossilRaw(const QStringList &args, QStringList *output, int | |||||||
| 		if(fossilAbort) | 		if(fossilAbort) | ||||||
| 		{ | 		{ | ||||||
| 			log("\n* Terminated *\n"); | 			log("\n* Terminated *\n"); | ||||||
|  | 			#ifdef Q_WS_WIN | ||||||
|  | 				fossilUI.kill(); // QT on windows cannot terminate console processes with QProcess::terminate | ||||||
|  | 			#else | ||||||
| 				process.terminate(); | 				process.terminate(); | ||||||
|  | 			#endif | ||||||
| 			break; | 			break; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| @@ -903,6 +907,7 @@ bool MainWindow::startUI() | |||||||
| 	if(uiRunning()) | 	if(uiRunning()) | ||||||
| 		return true; | 		return true; | ||||||
|  |  | ||||||
|  | 	fossilUI.setParent(this); | ||||||
| 	fossilUI.setProcessChannelMode(QProcess::MergedChannels); | 	fossilUI.setProcessChannelMode(QProcess::MergedChannels); | ||||||
| 	fossilUI.setWorkingDirectory(getCurrentWorkspace()); | 	fossilUI.setWorkingDirectory(getCurrentWorkspace()); | ||||||
|  |  | ||||||
| @@ -910,12 +915,38 @@ bool MainWindow::startUI() | |||||||
| 	QString fossil = getFossilPath(); | 	QString fossil = getFossilPath(); | ||||||
|  |  | ||||||
| 	fossilUI.start(fossil, QStringList() << "ui"); | 	fossilUI.start(fossil, QStringList() << "ui"); | ||||||
| 	if(!fossilUI.waitForStarted()) | 	if(!fossilUI.waitForStarted() || fossilUI.state()!=QProcess::Running) | ||||||
| 	{ | 	{ | ||||||
| 		log(fossil+ tr(" does not exist") +"\n"); | 		log(fossil+ tr(" does not exist") +"\n"); | ||||||
|  | 		ui->actionFossilUI->setChecked(false); | ||||||
| 		return false; | 		return false; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | #if 0 | ||||||
|  | 	QString buffer; | ||||||
|  | 	while(buffer.indexOf(EOL_MARK)==-1) | ||||||
|  | 	{ | ||||||
|  | 		fossilUI.waitForReadyRead(500); | ||||||
|  | 		buffer += fossilUI.readAll(); | ||||||
|  | 		QCoreApplication::processEvents(); | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	fossilUIPort.clear(); | ||||||
|  |  | ||||||
|  | 	// Parse output to determine the running port | ||||||
|  | 	// "Listening for HTTP requests on TCP port 8080" | ||||||
|  | 	int idx = buffer.indexOf("TCP Port "); | ||||||
|  | 	if(idx!=-1) | ||||||
|  | 		fossilUIPort = buffer.mid(idx, 4); | ||||||
|  | 	else | ||||||
|  | 		fossilUIPort = "8080"; // Have a sensible default if we failed to parse the message | ||||||
|  | #else | ||||||
|  | 	fossilUIPort = "8080"; | ||||||
|  | #endif | ||||||
|  |  | ||||||
|  |  | ||||||
|  | 	ui->actionFossilUI->setChecked(true); | ||||||
|  |  | ||||||
| 	return true; | 	return true; | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -923,14 +954,20 @@ bool MainWindow::startUI() | |||||||
| void MainWindow::stopUI() | void MainWindow::stopUI() | ||||||
| { | { | ||||||
| 	if(uiRunning()) | 	if(uiRunning()) | ||||||
|  | 	{ | ||||||
|  | #ifdef Q_WS_WIN | ||||||
|  | 		fossilUI.kill(); // QT on windows cannot terminate console processes with QProcess::terminate | ||||||
|  | #else | ||||||
| 		fossilUI.terminate(); | 		fossilUI.terminate(); | ||||||
|  | #endif | ||||||
|  | 	} | ||||||
|  | 	ui->actionFossilUI->setChecked(false); | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| //------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ | ||||||
| void MainWindow::on_actionFossilUI_toggled(bool arg1) | void MainWindow::on_actionFossilUI_triggered() | ||||||
| { | { | ||||||
| 	if(arg1) | 	if(!uiRunning()) | ||||||
| 		startUI(); | 		startUI(); | ||||||
| 	else | 	else | ||||||
| 		stopUI(); | 		stopUI(); | ||||||
| @@ -950,7 +987,7 @@ void MainWindow::on_actionTimeline_triggered() | |||||||
|  |  | ||||||
| 	Q_ASSERT(uiRunning()); | 	Q_ASSERT(uiRunning()); | ||||||
|  |  | ||||||
| 	QDesktopServices::openUrl(QUrl("http://127.0.0.1:8080/timeline")); | 	QDesktopServices::openUrl(QUrl(getFossilHttpAddress()+"/timeline")); | ||||||
| } | } | ||||||
|  |  | ||||||
| //------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ | ||||||
| @@ -966,14 +1003,14 @@ void MainWindow::on_actionHistory_triggered() | |||||||
|  |  | ||||||
| 	for(QStringList::iterator it = selection.begin(); it!=selection.end(); ++it) | 	for(QStringList::iterator it = selection.begin(); it!=selection.end(); ++it) | ||||||
| 	{ | 	{ | ||||||
|                 QDesktopServices::openUrl(QUrl("http://127.0.0.1:8080/finfo?name="+*it)); | 				QDesktopServices::openUrl(QUrl(getFossilHttpAddress()+"/finfo?name="+*it)); | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
| //------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ | ||||||
| void MainWindow::on_tableView_doubleClicked(const QModelIndex &/*index*/) | void MainWindow::on_tableView_doubleClicked(const QModelIndex &/*index*/) | ||||||
| { | { | ||||||
| 	on_actionOpenFile_triggered(); | 	on_actionDiff_triggered(); | ||||||
| } | } | ||||||
|  |  | ||||||
| //------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ | ||||||
| @@ -1383,3 +1420,10 @@ void MainWindow::on_actionViewUnknown_triggered() | |||||||
| { | { | ||||||
| 	refresh(); | 	refresh(); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | //------------------------------------------------------------------------------ | ||||||
|  | QString MainWindow::getFossilHttpAddress() | ||||||
|  | { | ||||||
|  | 	return "http://127.0.0.1:"+fossilUIPort; | ||||||
|  | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -118,6 +118,7 @@ private: | |||||||
| 	void rebuildRecent(); | 	void rebuildRecent(); | ||||||
| 	bool openWorkspace(const QString &dir); | 	bool openWorkspace(const QString &dir); | ||||||
| 	QString getFossilPath(); | 	QString getFossilPath(); | ||||||
|  | 	QString getFossilHttpAddress(); | ||||||
|  |  | ||||||
| 	enum RepoStatus | 	enum RepoStatus | ||||||
| 	{ | 	{ | ||||||
| @@ -136,7 +137,7 @@ private slots: | |||||||
| 	void on_actionRefresh_triggered(); | 	void on_actionRefresh_triggered(); | ||||||
| 	void on_actionOpen_triggered(); | 	void on_actionOpen_triggered(); | ||||||
| 	void on_actionDiff_triggered(); | 	void on_actionDiff_triggered(); | ||||||
| 	void on_actionFossilUI_toggled(bool arg1); | 	void on_actionFossilUI_triggered(); | ||||||
| 	void on_actionQuit_triggered(); | 	void on_actionQuit_triggered(); | ||||||
| 	void on_actionTimeline_triggered(); | 	void on_actionTimeline_triggered(); | ||||||
| 	void on_actionHistory_triggered(); | 	void on_actionHistory_triggered(); | ||||||
| @@ -171,6 +172,7 @@ private: | |||||||
| 	Ui::MainWindow		*ui; | 	Ui::MainWindow		*ui; | ||||||
| 	QStandardItemModel	itemModel; | 	QStandardItemModel	itemModel; | ||||||
| 	QProcess			fossilUI; | 	QProcess			fossilUI; | ||||||
|  | 	QString				fossilUIPort; | ||||||
| 	class QAction		*recentWorkspaceActs[MAX_RECENT]; | 	class QAction		*recentWorkspaceActs[MAX_RECENT]; | ||||||
| 	class QLabel		*statusLabel; | 	class QLabel		*statusLabel; | ||||||
| 	bool				fossilAbort;	// FIXME: No GUI for it yet | 	bool				fossilAbort;	// FIXME: No GUI for it yet | ||||||
|   | |||||||
| @@ -86,7 +86,7 @@ | |||||||
|      <x>0</x> |      <x>0</x> | ||||||
|      <y>0</y> |      <y>0</y> | ||||||
|      <width>865</width> |      <width>865</width> | ||||||
|      <height>27</height> |      <height>21</height> | ||||||
|     </rect> |     </rect> | ||||||
|    </property> |    </property> | ||||||
|    <widget class="QMenu" name="menuFile"> |    <widget class="QMenu" name="menuFile"> | ||||||
|   | |||||||
							
								
								
									
										16
									
								
								manifest
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								manifest
									
									
									
									
									
								
							| @@ -1,14 +1,14 @@ | |||||||
| C Fixed\sfossil\spath\sdetection\son\swindows\nThe\ssettings\sdialog\snow\squotes\spaths\sto\sexternal\stools\sif\sthey\scontain\sspaces\n | C Fixed\sfossil\sprocess\stermination\son\sWindows\nAbstracted\sfossil\sui\surl\nAdded\s(disabled)\scode\sto\sdetect\sfossil\sui\slaunch\sport\n | ||||||
| D 2011-09-03T12:33:47.295 | D 2011-09-03T15:03:01.556 | ||||||
| F CommitDialog.cpp a1fcdc94933f4e1a144224c7c70f1e067d3ee31e | F CommitDialog.cpp a1fcdc94933f4e1a144224c7c70f1e067d3ee31e | ||||||
| F CommitDialog.h 0550b1b652924ae54b6f6c9274cad2d4c491808a | F CommitDialog.h 0550b1b652924ae54b6f6c9274cad2d4c491808a | ||||||
| F CommitDialog.ui 5067623f6af6f5a42c87df903278e383e945e154 | F CommitDialog.ui 5067623f6af6f5a42c87df903278e383e945e154 | ||||||
| F FileActionDialog.cpp fcaebf9986f789b3440d5390b3458ad5f86fe0c8 | F FileActionDialog.cpp fcaebf9986f789b3440d5390b3458ad5f86fe0c8 | ||||||
| F FileActionDialog.h 15db1650b3a13d70bc338371e4c033c66e3b79ce | F FileActionDialog.h 15db1650b3a13d70bc338371e4c033c66e3b79ce | ||||||
| F FileActionDialog.ui c63644428579741aeb5fa052e237ba799ced9ad7 | F FileActionDialog.ui c63644428579741aeb5fa052e237ba799ced9ad7 | ||||||
| F MainWindow.cpp 7d7371085c08bbacc347a1b656d0a352a234c3f9 | F MainWindow.cpp 741cb2db89baf6330d3bfe87c99fb5918b5b2516 | ||||||
| F MainWindow.h 21fbbabd8b827d0b49fe3d40763b71042205fc3d | F MainWindow.h cb4d2ab3c3fb3ecc26c5d162358316516090a89e | ||||||
| F MainWindow.ui 5d10c04ab0f19f9b38a4da0abb0b36a00ff12efc | F MainWindow.ui fcce2709fd2dc332061ee72cbc5a5a17adfd0779 | ||||||
| F RepoDialog.cpp 8f20e1511526973555c774350ec413dcecf51c9e | F RepoDialog.cpp 8f20e1511526973555c774350ec413dcecf51c9e | ||||||
| F RepoDialog.h a958c5f98f1e6882bf41dbdd2e4df3cb89700802 | F RepoDialog.h a958c5f98f1e6882bf41dbdd2e4df3cb89700802 | ||||||
| F RepoDialog.ui be7b18199c04a3003f3c7534a616cd7441b7bb0c | F RepoDialog.ui be7b18199c04a3003f3c7534a616cd7441b7bb0c | ||||||
| @@ -173,7 +173,7 @@ F icons/fuel.icns 81e535004b62db801a02f3e15d0a33afc9d4070b | |||||||
| F icons/fuel.ico eb529ab3332a17b9302ef3e851db5b9ebce2a038 | F icons/fuel.ico eb529ab3332a17b9302ef3e851db5b9ebce2a038 | ||||||
| F main.cpp 083845039c167badd57a4abf482dd3d5e77aab35 | F main.cpp 083845039c167badd57a4abf482dd3d5e77aab35 | ||||||
| F resources.qrc e98383ed205f4e37100c60057e0129c3b86dea53 | F resources.qrc e98383ed205f4e37100c60057e0129c3b86dea53 | ||||||
| P ee85c090a173816f1d8053a7c982ab7facfe5c8b | P 208e56425e61f15f00ee2bbe200de18fda7fbc07 | ||||||
| R 3f3a7738535c921e5dd68fe8b5c4cc7b | R b8326070b54d51ef8c16887c4286d870 | ||||||
| U kostas | U kostas | ||||||
| Z dad7dd77b03e67f817ef15852b8851a5 | Z ba35c3d1bb569a4e3dbcd9d6ff41a92f | ||||||
|   | |||||||
| @@ -1 +1 @@ | |||||||
| 208e56425e61f15f00ee2bbe200de18fda7fbc07 | e8b33f373c855cce60dd9fc528b7684f85849d5d | ||||||
		Reference in New Issue
	
	Block a user