Permalink
Browse files

Fixed Ctrl-C not working due to SDL blocking SIGINT.

If the path is a directory and we failed to generate a log file and
there is no error and we do have a supported log format, set the error
to 'failed to generate log file' instead of 'directory not supported'.
  • Loading branch information...
1 parent 01033b1 commit 5328b8c139fd0ef90d70638bed66ebfa224d914a @acaudwell committed Apr 12, 2012
Showing with 26 additions and 7 deletions.
  1. +20 −5 src/logmill.cpp
  2. +6 −2 src/logmill.h
View
@@ -62,9 +62,22 @@ RLogMill::~RLogMill() {
void RLogMill::run() {
logmill_thread_state = LOGMILL_STATE_FETCHING;
+#if defined(HAVE_PTHREAD) && !defined(_WIN32)
+ sigset_t mask;
+ sigemptyset(&mask);
+
+ // unblock SIGINT so user can cancel
+ // NOTE: assumes SDL is using pthreads
+
+ sigaddset(&mask, SIGINT);
+ pthread_sigmask(SIG_UNBLOCK, &mask, 0);
+#endif
+
+ std::string log_format = gGourceSettings.log_format;
+
try {
- clog = fetchLog();
+ clog = fetchLog(log_format);
} catch(SeekLogException& exception) {
error = "unable to read log file";
@@ -74,7 +87,11 @@ void RLogMill::run() {
if(!clog && error.empty()) {
if(SDLAppDirExists(logfile)) {
- error = "directory not supported";
+ if(!log_format.empty()) {
+ error = "failed to generate log file";
+ } else {
+ error = "directory not supported";
+ }
} else {
error = "unsupported log format (you may need to regenerate your log file)";
}
@@ -141,12 +158,10 @@ bool RLogMill::findRepository(boost::filesystem::path& dir, std::string& log_for
}
-RCommitLog* RLogMill::fetchLog() {
+RCommitLog* RLogMill::fetchLog(std::string& log_format) {
RCommitLog* clog = 0;
- std::string log_format = gGourceSettings.log_format;
-
//if the log format is not specified and 'logfile' is a directory, recursively look for a version control repository.
//this method allows for something strange like someone who having an svn repository inside a git repository
//(in which case it would pick the svn directory as it would encounter that first)
View
@@ -27,6 +27,10 @@
#include "formats/commitlog.h"
+#if defined(HAVE_PTHREAD) && !defined(_WIN32)
+#include <signal.h>
+#endif
+
enum {
LOGMILL_STATE_STARTUP,
LOGMILL_STATE_FETCHING,
@@ -38,7 +42,7 @@ class RLogMill {
SDL_Thread* thread;
SDL_mutex* mutex;
SDL_cond* cond;
-
+
int logmill_thread_state;
std::string logfile;
@@ -47,7 +51,7 @@ class RLogMill {
std::string error;
bool findRepository(boost::filesystem::path& dir, std::string& log_format);
- RCommitLog* fetchLog();
+ RCommitLog* fetchLog(std::string& log_format);
public:
RLogMill(const std::string& logfile);
~RLogMill();

0 comments on commit 5328b8c

Please sign in to comment.