From d8a99917386146f47fc178c80b1d07f9e94aa121 Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Sat, 18 Feb 2012 23:26:39 -0800 Subject: [PATCH] Fix to avoid calling signal_block off of hte main thread --- fish_tests.cpp | 7 +++++++ highlight.cpp | 2 +- highlight.h | 2 +- history.cpp | 5 +++-- reader.cpp | 2 +- signal.cpp | 2 ++ 6 files changed, 15 insertions(+), 5 deletions(-) diff --git a/fish_tests.cpp b/fish_tests.cpp index d39745b55..e81a7c35e 100644 --- a/fish_tests.cpp +++ b/fish_tests.cpp @@ -50,6 +50,7 @@ #include "event.h" #include "path.h" #include "history.h" +#include "highlight.h" /** The number of tests to run @@ -552,6 +553,11 @@ static void test_colors() assert(rgb_color_t(L"mooganta").is_none()); } +/* Testing autosuggestion */ +static void test_autosuggest() { + bool autosuggest_handle_special(const wcstring &str, const wcstring &working_directory, bool *outSuggestionOK); +} + /** Test speed of completion calculations @@ -734,6 +740,7 @@ int main( int argc, char **argv ) test_expand(); test_path(); test_colors(); + test_autosuggest(); history_tests_t::test_history(); say( L"Encountered %d errors in low-level tests", err_count ); diff --git a/highlight.cpp b/highlight.cpp index 55a029139..eea6eb21b 100644 --- a/highlight.cpp +++ b/highlight.cpp @@ -528,7 +528,7 @@ static int has_expand_reserved( const wchar_t *str ) return 0; } -bool autosuggest_handle_special(const wcstring &str, const env_vars &vars, const wcstring &working_directory, bool *outSuggestionOK) { +bool autosuggest_handle_special(const wcstring &str, const wcstring &working_directory, bool *outSuggestionOK) { ASSERT_IS_BACKGROUND_THREAD(); assert(outSuggestionOK != NULL); diff --git a/highlight.h b/highlight.h index 2e3669e23..e23c7f9ad 100644 --- a/highlight.h +++ b/highlight.h @@ -106,7 +106,7 @@ void highlight_universal( const wchar_t *buff, int *color, int pos, wcstring_lis */ rgb_color_t highlight_get_color( int highlight, bool is_background ); -bool autosuggest_handle_special(const wcstring &str, const env_vars &vars, const wcstring &working_directory, bool *outSuggestionOK); +bool autosuggest_handle_special(const wcstring &str, const wcstring &working_directory, bool *outSuggestionOK); #endif diff --git a/history.cpp b/history.cpp index 09657b5ea..f61f47fcf 100644 --- a/history.cpp +++ b/history.cpp @@ -404,7 +404,8 @@ void history_t::load_old_if_needed(void) int fd; int ok=0; - signal_block(); + // PCA not sure why signals were blocked here + //signal_block(); wcstring filename = history_filename(name, L""); if( ! filename.empty() ) @@ -427,7 +428,7 @@ void history_t::load_old_if_needed(void) close( fd ); } } - signal_unblock(); + //signal_unblock(); } void history_search_t::skip_matches(const wcstring_list_t &skips) { diff --git a/reader.cpp b/reader.cpp index 69269c02f..d69af92e1 100644 --- a/reader.cpp +++ b/reader.cpp @@ -1287,7 +1287,7 @@ struct autosuggestion_context_t { while (searcher.go_backwards()) { history_item_t item = searcher.current_item(); bool item_ok = false; - if (autosuggest_handle_special(item.str(), vars, working_directory, &item_ok)) { + if (autosuggest_handle_special(item.str(), working_directory, &item_ok)) { /* The command autosuggestion was handled specially, so we're done */ } else { /* See if the item has any required paths */ diff --git a/signal.cpp b/signal.cpp index 8679eba35..53dc26471 100644 --- a/signal.cpp +++ b/signal.cpp @@ -633,6 +633,7 @@ void signal_handle( int sig, int do_handle ) void signal_block() { + ASSERT_IS_MAIN_THREAD(); sigset_t chldset; if( !block_count ) @@ -647,6 +648,7 @@ void signal_block() void signal_unblock() { + ASSERT_IS_MAIN_THREAD(); sigset_t chldset; block_count--;