0001-CMakeLists-Fix-compile-error-with-as-needed-ldflag.patch0000644000175000017500000000467612242030400021560 0ustar hhhhFrom 1d162bb1ce51b31d5cca18b3fe3dcfccacccdb13 Mon Sep 17 00:00:00 2001 From: "H.Habighorst" Date: Sat, 16 Nov 2013 17:52:38 +0100 Subject: [PATCH 01/15] CMakeLists: Fix compile error with as-needed ldflag --- backend/wbprivate/CMakeLists.txt | 2 ++ backend/wbpublic/CMakeLists.txt | 2 +- library/base/CMakeLists.txt | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/backend/wbprivate/CMakeLists.txt b/backend/wbprivate/CMakeLists.txt index d9511d8..ced0165 100644 --- a/backend/wbprivate/CMakeLists.txt +++ b/backend/wbprivate/CMakeLists.txt @@ -8,6 +8,7 @@ include_directories(. ${GRT_INCLUDE_DIRS} ${ANTLR3C_INCLUDE_DIRS} ${MYSQLCPPCONN_INCLUDE_DIRS} + ${PCRE_INCLUDE_DIRS} ${PROJECT_SOURCE_DIR} ${PROJECT_SOURCE_DIR}/library/grt/src ${PROJECT_SOURCE_DIR}/library/base @@ -99,6 +100,7 @@ target_link_libraries(wbprivate ${SIGC++_LIBRARIES} ${LIBZIP_LIBRARIES} ${TINYXML_LIBRARY} + ${PCRE_LIBRARIES} ) #install(TARGETS wbprivate DESTINATION ${WB_INSTALL_LIB_DIR}) diff --git a/backend/wbpublic/CMakeLists.txt b/backend/wbpublic/CMakeLists.txt index 8df538d..f8b3d1a 100644 --- a/backend/wbpublic/CMakeLists.txt +++ b/backend/wbpublic/CMakeLists.txt @@ -176,6 +176,6 @@ add_library(wbpublic # ) #endif() -target_link_libraries(wbpublic wbbase mdcanvas mforms cdbc ${VSQLITE_LIBRARIES} wbscintilla mysqlparser ${CAIRO_LIBRARIES} ${GNOME_KEYRING_LIBRARIES} ${CTEMPLATE_LIBRARIES} ${OPENGL_LIBRARIES}) +target_link_libraries(wbpublic wbbase mdcanvas mforms cdbc ${VSQLITE_LIBRARIES} wbscintilla mysqlparser ${CAIRO_LIBRARIES} ${GNOME_KEYRING_LIBRARIES} ${CTEMPLATE_LIBRARIES} ${OPENGL_LIBRARIES} ${PCRE_LIBRARIES}) install(TARGETS wbpublic DESTINATION ${WB_INSTALL_LIB_DIR}) diff --git a/library/base/CMakeLists.txt b/library/base/CMakeLists.txt index cac31a3..3c0cfe1 100644 --- a/library/base/CMakeLists.txt +++ b/library/base/CMakeLists.txt @@ -2,6 +2,6 @@ add_library(wbbase util_functions.cpp sqlstring.cpp file_functions.cpp file_utilities.cpp threaded_timer.cpp string_utilities.cpp geometry.cpp notifications.cpp ui_form.cpp config_file.cpp drawing.cpp log.cpp threading.cpp profiling.cpp) -target_link_libraries(wbbase ${CAIRO_LIBRARIES} ${GLIB_LIBRARIES} ${GTHREAD_LIBRARIES}) +target_link_libraries(wbbase ${CAIRO_LIBRARIES} ${GLIB_LIBRARIES} ${GTHREAD_LIBRARIES} ${PCRE_LIBRARIES}) install(TARGETS wbbase DESTINATION ${WB_INSTALL_LIB_DIR}) -- 1.8.4.3 0002-CMakeLists-Bump-minimum-version-of-CMake-to-2.8.10.patch0000644000175000017500000000140712242030400021003 0ustar hhhhFrom f787e9388ec9055603d956c276c202b71d23aef7 Mon Sep 17 00:00:00 2001 From: "H.Habighorst" Date: Sat, 16 Nov 2013 18:04:01 +0100 Subject: [PATCH 02/15] CMakeLists: Bump minimum version of CMake to 2.8.10 see http://public.kitware.com/Bug/bug_relationship_graph.php?bug_id=12049 for a detailed bug report. --- CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index eb0bce6..82469ea 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,6 @@ -cmake_minimum_required (VERSION 2.8) # 2.8 needed because of ExternalProject +# 2.8.10 because of multilib issue with FindGTK2 (Kitware Bug #12049) +cmake_minimum_required (VERSION 2.8.10) project(WORKBENCH) -- 1.8.4.3 0003-CMakeLists-Set-minimum-python-version-to-2.7.0.patch0000644000175000017500000000206312242030400020510 0ustar hhhhFrom 4abe2f13dd7f8ea7d8f2d4771db7ed27b4f37c75 Mon Sep 17 00:00:00 2001 From: "H.Habighorst" Date: Sat, 16 Nov 2013 18:16:52 +0100 Subject: [PATCH 03/15] CMakeLists: Set minimum python version to 2.7.0 - Python 3 or greater is not supported --- CMakeLists.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 82469ea..d3b6156 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,6 @@ cmake_minimum_required (VERSION 2.8.10) project(WORKBENCH) - # About MySQL and CMake # http://dev.mysql.com/doc/internals/en/autotools-to-cmake.html # http://www.lenzg.net/archives/291-Building-MySQL-Server-with-CMake-on-LinuxUnix.html @@ -46,7 +45,7 @@ if (ANTLR3C_FOUND) endif () # In Ubuntu 13.04, the built-in check for python fails.. so we have to resort to the check with pkg-config (which doesn't work in many distros) -find_package(PythonLibs) +find_package(PythonLibs 2.7) if (NOT PYTHONLIBS_FOUND) pkg_check_modules(PYTHON REQUIRED python) endif () -- 1.8.4.3 0004-Remove-usage-of-g_thread_init-deprecated.patch0000644000175000017500000001015112242030400020056 0ustar hhhhFrom 42fa302791e6258afb450fde18d0f8d233587f2e Mon Sep 17 00:00:00 2001 From: "H.Habighorst" Date: Sat, 16 Nov 2013 19:36:10 +0100 Subject: [PATCH 04/15] Remove usage of g_thread_init (deprecated). --- backend/wbpublic/grt/grt_manager.cpp | 18 ++++-------------- frontend/linux/workbench/main.cpp | 5 +++-- library/base/threaded_timer.cpp | 2 -- library/base/unit-tests/file_utilities_test.cpp | 3 --- library/canvas/src/mdc_canvas_view.cpp | 1 - plugins/migration/copytable/main.cpp | 3 --- 6 files changed, 7 insertions(+), 25 deletions(-) diff --git a/backend/wbpublic/grt/grt_manager.cpp b/backend/wbpublic/grt/grt_manager.cpp index 4675686..525b2cb 100644 --- a/backend/wbpublic/grt/grt_manager.cpp +++ b/backend/wbpublic/grt/grt_manager.cpp @@ -46,22 +46,9 @@ static GThread *main_thread= 0; std::map GRTManager::_instances; - GStaticMutex _instance_mutex = G_STATIC_MUTEX_INIT; -static void init_all() -{ - if (!main_thread) - { - if (!g_thread_supported()) g_thread_init(NULL); - main_thread= g_thread_self(); - if (!g_thread_supported()) - throw std::runtime_error("Could not initialize Glib thread support"); - } -} - - GRTManager *create_grt_manager(bool threaded, bool verbose = false) { return new GRTManager(threaded, verbose); @@ -75,7 +62,10 @@ GRTManager::GRTManager(bool threaded, bool verbose) _current_idle_signal = 0; - init_all(); + if (!main_thread) + { + main_thread= g_thread_self(); + } _idle_mutex= g_mutex_new(); _timer_mutex= g_mutex_new(); diff --git a/frontend/linux/workbench/main.cpp b/frontend/linux/workbench/main.cpp index 12e1c13..0f3338d 100644 --- a/frontend/linux/workbench/main.cpp +++ b/frontend/linux/workbench/main.cpp @@ -52,9 +52,10 @@ int main(int argc, char **argv) g_log_set_always_fatal((GLogLevelFlags)(G_LOG_LEVEL_CRITICAL|G_LOG_LEVEL_ERROR)); #endif - init_gdk_thread_callbacks(); // This call MUST be before g_threads_init is called - g_thread_init(NULL); + // This call MUST be before gdk_threads_init is called + init_gdk_thread_callbacks(); gdk_threads_init(); + // process cmdline options int i= 1; wb::WBOptions wboptions; diff --git a/library/base/threaded_timer.cpp b/library/base/threaded_timer.cpp index 471e19f..a81db73 100644 --- a/library/base/threaded_timer.cpp +++ b/library/base/threaded_timer.cpp @@ -44,8 +44,6 @@ ThreadedTimer* ThreadedTimer::get() G_LOCK(_timer); if (_timer == NULL) { - if (!g_thread_supported()) - g_thread_init(NULL); _timer= new ThreadedTimer(BASE_FREQUENCY); } G_UNLOCK(_timer); diff --git a/library/base/unit-tests/file_utilities_test.cpp b/library/base/unit-tests/file_utilities_test.cpp index ce16aa2..752affa 100755 --- a/library/base/unit-tests/file_utilities_test.cpp +++ b/library/base/unit-tests/file_utilities_test.cpp @@ -97,9 +97,6 @@ TEST_DATA_CONSTRUCTOR(file_utilities_test) remove(TEST_FILE_NAME04); remove(dir_unicode_name); remove(file_unicode_name); - - // Initialize the thread system - if (!g_thread_supported ()) g_thread_init (NULL); } TEST_DATA_DESTRUCTOR(file_utilities_test) diff --git a/library/canvas/src/mdc_canvas_view.cpp b/library/canvas/src/mdc_canvas_view.cpp index d4a28f2..ead2932 100644 --- a/library/canvas/src/mdc_canvas_view.cpp +++ b/library/canvas/src/mdc_canvas_view.cpp @@ -61,7 +61,6 @@ struct CanvasAutoLock CanvasView::CanvasView(int width, int height) : _fps(0), _total_item_cache_mem(0), _last_click_info(3) { - if (!g_thread_supported()) g_thread_init(NULL); g_static_rec_mutex_init(&_lock); _page_size= Size(2000, 1500); diff --git a/plugins/migration/copytable/main.cpp b/plugins/migration/copytable/main.cpp index a89597a..52d30b5 100644 --- a/plugins/migration/copytable/main.cpp +++ b/plugins/migration/copytable/main.cpp @@ -238,9 +238,6 @@ bool read_tasks_from_file(const std::string file_name, bool count_only, TaskQueu int main(int argc, char **argv) { - if (!g_thread_supported()) - g_thread_init(NULL); - TaskQueue tables; std::string source_password; -- 1.8.4.3 0005-Prevent-crash-at-startup-by-checking-the-environment.patch0000644000175000017500000000452212242030400022353 0ustar hhhhFrom aea4f67e620dd6568da57984dda5238369495f7e Mon Sep 17 00:00:00 2001 From: "H.Habighorst" Date: Sat, 16 Nov 2013 19:37:09 +0100 Subject: [PATCH 05/15] Prevent crash at startup by checking the environment options. --- frontend/linux/workbench/main.cpp | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/frontend/linux/workbench/main.cpp b/frontend/linux/workbench/main.cpp index 0f3338d..79a7bb5 100644 --- a/frontend/linux/workbench/main.cpp +++ b/frontend/linux/workbench/main.cpp @@ -58,15 +58,31 @@ int main(int argc, char **argv) // process cmdline options int i= 1; + char *basedir; + char *plugin_search_path; + char *module_search_path; + wb::WBOptions wboptions; wboptions.user_data_dir = std::string(g_get_home_dir()).append("/.mysql/workbench"); base::Logger log(wboptions.user_data_dir, getenv("MWB_LOG_TO_STDERR")!=NULL); - wboptions.basedir = getenv("MWB_DATA_DIR"); - wboptions.plugin_search_path = getenv("MWB_PLUGIN_DIR"); + basedir = getenv("MWB_DATA_DIR"); + plugin_search_path = getenv("MWB_PLUGIN_DIR"); + module_search_path = getenv("MWB_MODULE_DIR"); + if ( !basedir || !plugin_search_path || !module_search_path ) { + char *script_name = g_strdup(argv[0]); + if (g_str_has_suffix(script_name, "-bin")) + script_name[strlen(script_name)-4]= 0; + printf("To start MySQL Workbench, use %s instead of %s\n", script_name, argv[0]); + g_free(script_name); + exit(1); + } + + wboptions.basedir = basedir; + wboptions.plugin_search_path = plugin_search_path; wboptions.struct_search_path = wboptions.basedir + "/grt"; - wboptions.module_search_path = getenv("MWB_MODULE_DIR"); + wboptions.module_search_path = module_search_path; g_set_application_name("MySQL Workbench"); @@ -76,15 +92,6 @@ int main(int argc, char **argv) if (getenv("WB_VERBOSE")) wboptions.verbose = true; - if (!getenv("MWB_DATA_DIR")) - { - char *script_name = g_strdup(argv[0]); - if (g_str_has_suffix(script_name, "-bin")) - script_name[strlen(script_name)-4]= 0; - printf("To start MySQL Workbench, use %s instead of %s\n", script_name, argv[0]); - exit(1); - } - mforms::gtk::init(getenv("WB_FORCE_SYSTEM_COLORS") != NULL); mforms::gtk::WizardImpl::set_icon_path(wboptions.basedir+"/images"); -- 1.8.4.3 0006-CMakeLists-Explicitly-disable-unused-parameter-warni.patch0000644000175000017500000000171712242030400022354 0ustar hhhhFrom 98986d50e576b1c4d829b665e3bc5daa01c6e1cc Mon Sep 17 00:00:00 2001 From: "H.Habighorst" Date: Sat, 16 Nov 2013 20:04:39 +0100 Subject: [PATCH 06/15] CMakeLists: Explicitly disable unused parameter warnings. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d3b6156..650e776 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -190,7 +190,7 @@ set(BUILD_SHARED_LIBS ON) # By default all libs will be built as shared libs # Add some common compiler flags. TODO: Shouldn't this be done checking if whatever compiler # we use supports each flag to allow for non-gcc compilers in Linux (as above)? if (CMAKE_COMPILER_IS_GNUCXX) - add_definitions(-Wall -Wsign-compare -Wextra -Wno-unused -Wno-deprecated -DTIXML_USE_STL=1) + add_definitions(-Wall -Wsign-compare -Wextra -Wno-unused -Wno-unused-parameter -Wno-deprecated -DTIXML_USE_STL=1) endif() -- 1.8.4.3 0007-Fix-deprecated-g_cond-usage-g_mutex-usage.patch0000644000175000017500000022726512242030400020171 0ustar hhhhFrom ae0eac09b7d07148e9f3a4e2dfb8fc7a7aef3b64 Mon Sep 17 00:00:00 2001 From: "H.Habighorst" Date: Sat, 16 Nov 2013 20:06:54 +0100 Subject: [PATCH 07/15] Fix deprecated g_cond usage & g_mutex usage. Static g_conds don't require initialisation. --- backend/wbprivate/sqlide/wb_sql_editor_buffer.cpp | 25 ++++---- backend/wbprivate/sqlide/wb_sql_editor_form.cpp | 56 ++++++++--------- backend/wbprivate/sqlide/wb_sql_editor_form.h | 10 +-- .../sqlide/wb_sql_editor_tree_controller.cpp | 8 +-- .../sqlide/wb_sql_editor_tree_controller.h | 2 +- backend/wbprivate/workbench/wb_context.cpp | 13 ++-- backend/wbprivate/workbench/wb_context.h | 2 +- backend/wbpublic/grt/common.cpp | 10 +-- backend/wbpublic/grt/common.h | 2 +- backend/wbpublic/grt/grt_dispatcher.h | 22 +++---- backend/wbpublic/grt/grt_manager.cpp | 56 ++++++++--------- backend/wbpublic/grt/grt_manager.h | 6 +- backend/wbpublic/grt/tree_model.h | 15 ++--- .../sqlide/autocomplete_object_name_cache.cpp | 72 +++++++++++----------- .../sqlide/autocomplete_object_name_cache.h | 6 +- backend/wbpublic/sqlide/sql_editor_be.cpp | 40 ++++++------ .../unit-tests/autocompletion_cache_test.cpp | 29 +++++---- .../sql_editor_be_autocomplete_tests.cpp | 27 ++++---- frontend/linux/workbench/sqlide_form.cpp | 13 ++-- frontend/linux/workbench/sqlide_form.h | 4 +- library/base/base/threaded_timer.h | 2 +- library/base/threaded_timer.cpp | 28 ++++----- library/forms/utilities.cpp | 11 +++- modules/db.mysql.query/src/dbquery.cpp | 58 ++++++++--------- plugins/db.search/DbSearchPanel.cpp | 28 ++++----- plugins/migration/copytable/copytable.cpp | 12 ++-- plugins/migration/copytable/copytable.h | 2 +- 27 files changed, 279 insertions(+), 280 deletions(-) diff --git a/backend/wbprivate/sqlide/wb_sql_editor_buffer.cpp b/backend/wbprivate/sqlide/wb_sql_editor_buffer.cpp index 88320d9..7cba8e5 100644 --- a/backend/wbprivate/sqlide/wb_sql_editor_buffer.cpp +++ b/backend/wbprivate/sqlide/wb_sql_editor_buffer.cpp @@ -73,7 +73,7 @@ void SqlEditorForm::auto_save() // Save all script buffers, including scratch buffers void SqlEditorForm::save_workspace(const std::string &workspace_name, bool is_autosave) { - GMutexLock sql_editors_mutex(_sql_editors_mutex); + GMutexLock sql_editors_mutex(&_sql_editors_mutex); if (_sql_editors.size() < 1 || (_sql_editors.size() == 1 && _sql_editors[0]->is_scratch && _sql_editors[0]->editor->empty())) return; @@ -517,12 +517,12 @@ int SqlEditorForm::add_sql_editor(bool scratch, bool start_collapsed) boost::bind(&SqlEditorForm::do_partial_ui_refresh, this, (int)RefreshEditorTitle)); int sql_editor_index; { - GMutexLock sql_editors_mutex(_sql_editors_mutex); + GMutexLock sql_editors_mutex(&_sql_editors_mutex); Sql_editor_info::Ref info(new Sql_editor_info()); info->toolbar = setup_editor_toolbar(sql_editor); info->editor = sql_editor; info->is_scratch = scratch; - info->recordset_mutex = g_mutex_new(); + g_mutex_init(&info->recordset_mutex); info->start_collapsed = start_collapsed; if (!scratch) info->caption = strfmt("SQL File %i", ++_sql_editors_serial); @@ -596,7 +596,7 @@ void SqlEditorForm::remove_sql_editor(int editor_index) info->editor->stop_processing(); { // Notify the UI that recordsets must be closed. - GMutexLock lock(info->recordset_mutex); + GMutexLock lock(&info->recordset_mutex); RecordsetsRef rsets = info->recordsets; if (rsets != NULL) { @@ -608,12 +608,11 @@ void SqlEditorForm::remove_sql_editor(int editor_index) } } } - g_mutex_free(info->recordset_mutex); - info->recordset_mutex = NULL; + g_mutex_clear(&info->recordset_mutex); Sql_editor::Ref active_sql_editor; { - GMutexLock sql_editors_mutex(_sql_editors_mutex); + GMutexLock sql_editors_mutex(&_sql_editors_mutex); if ((editor_index < 0) || (editor_index >= (int)_sql_editors.size())) return; @@ -647,7 +646,7 @@ void SqlEditorForm::remove_sql_editor(int editor_index) int SqlEditorForm::sql_editor_count() { - GMutexLock sql_editors_mutex(_sql_editors_mutex); + GMutexLock sql_editors_mutex(&_sql_editors_mutex); return _sql_editors.size(); } @@ -677,7 +676,7 @@ Sql_editor::Ref SqlEditorForm::active_sql_editor_or_new_scratch() Sql_editor::Ref SqlEditorForm::sql_editor(int new_index) { - GMutexLock sql_editors_mutex(_sql_editors_mutex); + GMutexLock sql_editors_mutex(&_sql_editors_mutex); if (new_index >= 0 && new_index < (int)_sql_editors.size()) return _sql_editors.at(new_index)->editor; return Sql_editor::Ref(); @@ -690,7 +689,7 @@ bool SqlEditorForm::sql_editor_reorder(Sql_editor::Ref editor, int new_index) if (old_index < 0 || old_index == new_index || new_index < 0) return false; - GMutexTryLock editor_lock(_sql_editors_mutex); + GMutexTryLock editor_lock(&_sql_editors_mutex); if (editor_lock.locked()) { // First reorder auto-save files so file names are correct in case of errors. @@ -741,13 +740,13 @@ bool SqlEditorForm::sql_editor_will_close(int new_index) { int edited_recordsets = 0; { - GMutexLock sql_editors_mutex(_sql_editors_mutex); + GMutexLock sql_editors_mutex(&_sql_editors_mutex); if (new_index < 0 || new_index >= (int)_sql_editors.size() || _sql_editors.at(new_index)->busy) return false; } // the recordset lock will prevent the editor from being closed elsewhere - GMutexTryLock recordset_mutex(_sql_editors[new_index]->recordset_mutex); + GMutexTryLock recordset_mutex(&_sql_editors[new_index]->recordset_mutex); if (!recordset_mutex.locked()) return false; { @@ -905,7 +904,7 @@ RecordsetsRef SqlEditorForm::sql_editor_recordsets(const int index) int SqlEditorForm::sql_editor_index(Sql_editor::Ref editor) { - GMutexLock ed_lock(_sql_editors_mutex); + GMutexLock ed_lock(&_sql_editors_mutex); for (int i= 0; i < (int)_sql_editors.size(); i++) { if (_sql_editors[i]->editor == editor) diff --git a/backend/wbprivate/sqlide/wb_sql_editor_form.cpp b/backend/wbprivate/sqlide/wb_sql_editor_form.cpp index f91aa71..1940c98 100644 --- a/backend/wbprivate/sqlide/wb_sql_editor_form.cpp +++ b/backend/wbprivate/sqlide/wb_sql_editor_form.cpp @@ -217,10 +217,10 @@ SqlEditorForm::SqlEditorForm(wb::WBContextSQLIDE *wbsql, const db_mgmt_Connectio NotificationCenter::get()->add_observer(this, "GNColorsChanged"); GRTNotificationCenter::get()->add_grt_observer(this, "GRNServerStateChanged"); - _sql_editors_mutex= g_mutex_new(); - _aux_dbc_conn_mutex= g_mutex_new(); - _usr_dbc_conn_mutex= g_mutex_new(); - _keep_alive_thread_mutex= g_mutex_new(); + g_mutex_init(&_sql_editors_mutex); + g_mutex_init(&_aux_dbc_conn_mutex); + g_mutex_init(&_usr_dbc_conn_mutex); + g_mutex_init(&_keep_alive_thread_mutex); _dbc_auth = sql::Authentication::create(_connection, ""); @@ -311,7 +311,7 @@ SqlEditorForm::~SqlEditorForm() { // Ensure all processing is stopped before freeing the info structure, otherwise references // are kept that prevent the correct deletion of the editor. - GMutexLock sql_editors_mutex(_sql_editors_mutex); + GMutexLock sql_editors_mutex(&_sql_editors_mutex); BOOST_FOREACH (Sql_editor_info::Ref sql_editor_info, _sql_editors) sql_editor_info->editor->stop_processing(); } @@ -336,10 +336,10 @@ SqlEditorForm::~SqlEditorForm() reset_keep_alive_thread(); - g_mutex_free(_keep_alive_thread_mutex); - g_mutex_free(_usr_dbc_conn_mutex); - g_mutex_free(_aux_dbc_conn_mutex); - g_mutex_free(_sql_editors_mutex); + g_mutex_clear(&_keep_alive_thread_mutex); + g_mutex_clear(&_usr_dbc_conn_mutex); + g_mutex_clear(&_aux_dbc_conn_mutex); + g_mutex_clear(&_sql_editors_mutex); } @@ -395,7 +395,7 @@ void SqlEditorForm::handle_notification(const std::string &name, void *sender, b void SqlEditorForm::reset_keep_alive_thread() { - GMutexLock keep_alive_thread_lock(_keep_alive_thread_mutex); + GMutexLock keep_alive_thread_lock(&_keep_alive_thread_mutex); if (_keep_alive_thread) { _keep_alive_thread->stop(true); @@ -410,13 +410,13 @@ grt::StringRef SqlEditorForm::do_disconnect(grt::GRT *grt) sql::Driver *dbc_driver= _usr_dbc_conn->ref->getDriver(); { - GMutexLock lock(_usr_dbc_conn_mutex); + GMutexLock lock(&_usr_dbc_conn_mutex); close_connection(_usr_dbc_conn); _usr_dbc_conn->ref.reset(); } { - GMutexLock lock(_aux_dbc_conn_mutex); + GMutexLock lock(&_aux_dbc_conn_mutex); close_connection(_aux_dbc_conn); _aux_dbc_conn->ref.reset(); } @@ -558,7 +558,7 @@ void SqlEditorForm::cache_sql_mode() if (sql_mode != _sql_mode) { _sql_mode= sql_mode; - GMutexLock sql_editors_mutex(_sql_editors_mutex); + GMutexLock sql_editors_mutex(&_sql_editors_mutex); BOOST_FOREACH (Sql_editor_info::Ref sql_editor_info, _sql_editors) sql_editor_info->editor->sql_mode(sql_mode); } @@ -893,8 +893,8 @@ grt::StringRef SqlEditorForm::do_connect(grt::GRT *grt, boost::shared_ptrref.reset(); _usr_dbc_conn->ref.reset(); @@ -1045,7 +1045,7 @@ void SqlEditorForm::on_cache_action(bool active) bool SqlEditorForm::connected() const { - if (_usr_dbc_conn_mutex && _usr_dbc_conn && _usr_dbc_conn->ref.get_ptr()) + if (&_usr_dbc_conn_mutex && _usr_dbc_conn && _usr_dbc_conn->ref.get_ptr()) return true; // we don't need to PING the server every time we want to check if the editor is connected return false; } @@ -1053,7 +1053,7 @@ bool SqlEditorForm::connected() const base::GMutexLock SqlEditorForm::ensure_valid_aux_connection(sql::Dbc_connection_handler::Ref &conn) { - GMutexLock lock(ensure_valid_dbc_connection(_aux_dbc_conn, _aux_dbc_conn_mutex)); + GMutexLock lock(ensure_valid_dbc_connection(_aux_dbc_conn, &_aux_dbc_conn_mutex)); conn = _aux_dbc_conn; return lock; } @@ -1061,13 +1061,13 @@ base::GMutexLock SqlEditorForm::ensure_valid_aux_connection(sql::Dbc_connection_ GMutexLock SqlEditorForm::ensure_valid_aux_connection() { - return ensure_valid_dbc_connection(_aux_dbc_conn, _aux_dbc_conn_mutex); + return ensure_valid_dbc_connection(_aux_dbc_conn, &_aux_dbc_conn_mutex); } GMutexLock SqlEditorForm::ensure_valid_usr_connection() { - return ensure_valid_dbc_connection(_usr_dbc_conn, _usr_dbc_conn_mutex); + return ensure_valid_dbc_connection(_usr_dbc_conn, &_usr_dbc_conn_mutex); } @@ -1436,7 +1436,7 @@ grt::StringRef SqlEditorForm::do_exec_sql(grt::GRT *grt, Ptr self_ptr, boost::sh // close all recordsets for the same editor if (info) { - GMutexTryLock recordsets_mutex(info->recordset_mutex); + GMutexTryLock recordsets_mutex(&info->recordset_mutex); if (!recordsets_mutex.locked()) throw std::runtime_error("The editor is busy and cannot execute the query now. Please try again later."); @@ -1464,7 +1464,7 @@ grt::StringRef SqlEditorForm::do_exec_sql(grt::GRT *grt, Ptr self_ptr, boost::sh } } result_list->swap(*recordsets.get()); - result_list_mutex = info->recordset_mutex; + result_list_mutex = &info->recordset_mutex; } } @@ -1961,7 +1961,7 @@ void SqlEditorForm::send_message_keep_alive() Recordset::Ref SqlEditorForm::active_recordset(int editor) { - GMutexLock lock(_sql_editors_mutex); + GMutexLock lock(&_sql_editors_mutex); if (editor >= 0 && editor < (int)_sql_editors.size()) return _sql_editors[editor]->active_recordset; return Recordset::Ref(); @@ -1969,7 +1969,7 @@ Recordset::Ref SqlEditorForm::active_recordset(int editor) void SqlEditorForm::active_recordset(int editor, Recordset::Ref rset) { - GMutexLock lock(_sql_editors_mutex); + GMutexLock lock(&_sql_editors_mutex); if (editor >= 0 && editor < (int)_sql_editors.size()) { bool found = false; @@ -1998,12 +1998,12 @@ void SqlEditorForm::active_recordset(int editor, Recordset::Ref rset) bool SqlEditorForm::recordset_reorder(int editor, Recordset::Ref value, int new_index) { - GMutexTryLock lock(_sql_editors_mutex); + GMutexTryLock lock(&_sql_editors_mutex); if (lock.locked()) { if (editor >= 0 && editor < (int)_sql_editors.size()) { - GMutexTryLock rlock(_sql_editors[editor]->recordset_mutex); + GMutexTryLock rlock(&_sql_editors[editor]->recordset_mutex); if (rlock.locked()) { RecordsetsRef recordsets(sql_editor_recordsets(editor)); @@ -2034,11 +2034,11 @@ void SqlEditorForm::on_close_recordset(Recordset::Ptr rs_ptr) RETURN_IF_FAIL_TO_RETAIN_WEAK_PTR (Recordset, rs_ptr, rs) { { - GMutexLock ed_lock(_sql_editors_mutex); + GMutexLock ed_lock(&_sql_editors_mutex); editor = sql_editor_index_for_recordset(rs_ref->key()); if (editor >= 0) { - GMutexLock recordsets_mutex(_sql_editors[editor]->recordset_mutex); + GMutexLock recordsets_mutex(&_sql_editors[editor]->recordset_mutex); RecordsetsRef rsets(sql_editor_recordsets(editor)); rsets->erase(std::find(rsets->begin(), rsets->end(), rs_ref)); if (_sql_editors[editor]->active_recordset == rs_ref) @@ -2594,7 +2594,7 @@ bool SqlEditorForm::can_close_(bool interactive) return false; { - GMutexTryLock lock(_sql_editors[i]->recordset_mutex); + GMutexTryLock lock(&_sql_editors[i]->recordset_mutex); if (!lock.locked()) return false; diff --git a/backend/wbprivate/sqlide/wb_sql_editor_form.h b/backend/wbprivate/sqlide/wb_sql_editor_form.h index 886ef18..396458d 100644 --- a/backend/wbprivate/sqlide/wb_sql_editor_form.h +++ b/backend/wbprivate/sqlide/wb_sql_editor_form.h @@ -154,7 +154,7 @@ private: Sql_editor::Ref editor; RecordsetsRef recordsets; Recordset::Ref active_recordset; - GMutex *recordset_mutex; + GMutex recordset_mutex; time_t file_timestamp; int rs_sequence; bool is_scratch; @@ -167,7 +167,7 @@ private: Sql_editors _sql_editors; int _sql_editors_serial; int _scratch_editors_serial; - GMutex *_sql_editors_mutex; + GMutex _sql_editors_mutex; boost::shared_ptr setup_editor_toolbar(Sql_editor::Ref editor); void set_editor_tool_items_enbled(const std::string &name, bool flag); @@ -258,7 +258,7 @@ public: private: bec::TimerActionThread *_keep_alive_thread; - GMutex *_keep_alive_thread_mutex; + GMutex _keep_alive_thread_mutex; private: void send_message_keep_alive(); void reset_keep_alive_thread(); @@ -266,10 +266,10 @@ private: db_mgmt_ConnectionRef _connection; // connection for maintenance operations, fetching schema contents & live editors (DDL only) sql::Dbc_connection_handler::Ref _aux_dbc_conn; - GMutex *_aux_dbc_conn_mutex; + GMutex _aux_dbc_conn_mutex; // connection for running sql scripts sql::Dbc_connection_handler::Ref _usr_dbc_conn; - GMutex *_usr_dbc_conn_mutex; + GMutex _usr_dbc_conn_mutex; sql::Authentication::Ref _dbc_auth; diff --git a/backend/wbprivate/sqlide/wb_sql_editor_tree_controller.cpp b/backend/wbprivate/sqlide/wb_sql_editor_tree_controller.cpp index b18b622..829bd18 100644 --- a/backend/wbprivate/sqlide/wb_sql_editor_tree_controller.cpp +++ b/backend/wbprivate/sqlide/wb_sql_editor_tree_controller.cpp @@ -138,7 +138,7 @@ SqlEditorTreeController::SqlEditorTreeController(SqlEditorForm *owner) grt::GRTNotificationCenter::get()->add_grt_observer(this, "GRNPreferencesDidClose"); grt::GRTNotificationCenter::get()->add_grt_observer(this, "GRNSQLEditorReconnected"); - _schema_contents_mutex= g_mutex_new(); + g_mutex_init(&_schema_contents_mutex); _base_schema_tree.is_schema_contents_enabled(_grtm->get_app_option_int("DbSqlEditor:ShowSchemaTreeSchemaContents", 1) != 0); _filtered_schema_tree.is_schema_contents_enabled(_grtm->get_app_option_int("DbSqlEditor:ShowSchemaTreeSchemaContents", 1) != 0); @@ -157,7 +157,7 @@ SqlEditorTreeController::SqlEditorTreeController(SqlEditorForm *owner) SqlEditorTreeController::~SqlEditorTreeController() { grt::GRTNotificationCenter::get()->remove_grt_observer(this); - g_mutex_free(_schema_contents_mutex); + g_mutex_clear(&_schema_contents_mutex); delete _taskbar_box; delete _info_tabview; @@ -489,7 +489,7 @@ grt::StringRef SqlEditorTreeController::do_fetch_live_schema_contents(grt::GRT * std::vector > table_list; std::vector > routine_list; - GMutexLock schema_contents_mutex(_schema_contents_mutex); + GMutexLock schema_contents_mutex(&_schema_contents_mutex); if (arrived_slot.empty()) return grt::StringRef(""); @@ -1158,7 +1158,7 @@ wb::LiveSchemaTree::ObjectType SqlEditorTreeController::fetch_object_type(const try { - GMutexLock schema_contents_mutex(_schema_contents_mutex); + GMutexLock schema_contents_mutex(&_schema_contents_mutex); { sql::Dbc_connection_handler::Ref conn; diff --git a/backend/wbprivate/sqlide/wb_sql_editor_tree_controller.h b/backend/wbprivate/sqlide/wb_sql_editor_tree_controller.h index 34cf168..31eef50 100644 --- a/backend/wbprivate/sqlide/wb_sql_editor_tree_controller.h +++ b/backend/wbprivate/sqlide/wb_sql_editor_tree_controller.h @@ -78,7 +78,7 @@ private: wb::LiveSchemaTree *_schema_tree; wb::LiveSchemaTree _base_schema_tree; wb::LiveSchemaTree _filtered_schema_tree; - GMutex *_schema_contents_mutex; + GMutex _schema_contents_mutex; GrtThreadedTask::Ref live_schema_fetch_task; GrtThreadedTask::Ref live_schemata_refresh_task; bool _is_refreshing_schema_tree; diff --git a/backend/wbprivate/workbench/wb_context.cpp b/backend/wbprivate/workbench/wb_context.cpp index 7cf6ad9..98bd76a 100644 --- a/backend/wbprivate/workbench/wb_context.cpp +++ b/backend/wbprivate/workbench/wb_context.cpp @@ -554,9 +554,8 @@ WBContext::WBContext(WBContextUI *ui, bool verbose) if (getenv("DEBUG_UNDO")) _manager->get_grt()->get_undo_manager()->enable_logging_to(&std::cout); - - _pending_refresh_mutex= g_mutex_new(); + g_mutex_init(&_pending_refresh_mutex); _plugin_manager= _manager->get_plugin_manager(); _plugin_manager->set_registry_paths(PLUGIN_LIST_PATH, PLUGIN_GROUP_PATH); @@ -2353,9 +2352,9 @@ bool WBContext::cancel_idle_tasks() { bool result = _manager->cancel_idle_tasks(); - g_mutex_lock(_pending_refresh_mutex); + g_mutex_lock(&_pending_refresh_mutex); _pending_refreshes.clear(); - g_mutex_unlock(_pending_refresh_mutex); + g_mutex_unlock(&_pending_refresh_mutex); return result; } @@ -2373,7 +2372,7 @@ void WBContext::flush_idle_tasks() mdc::Timestamp now= mdc::get_time(); - g_mutex_lock(_pending_refresh_mutex); + g_mutex_lock(&_pending_refresh_mutex); std::list refreshes; // separate the requests that can be executed now @@ -2391,7 +2390,7 @@ void WBContext::flush_idle_tasks() iter= next; } - g_mutex_unlock(_pending_refresh_mutex); + g_mutex_unlock(&_pending_refresh_mutex); // send the refresh requests for (std::list::iterator iter= refreshes.begin(); @@ -2407,7 +2406,7 @@ void WBContext::flush_idle_tasks() void WBContext::request_refresh(RefreshType type, const std::string &str, NativeHandle ptr) { - GMutexLock lock(_pending_refresh_mutex); + GMutexLock lock(&_pending_refresh_mutex); mdc::Timestamp now= mdc::get_time(); diff --git a/backend/wbprivate/workbench/wb_context.h b/backend/wbprivate/workbench/wb_context.h index 6f348c9..b0a874d 100644 --- a/backend/wbprivate/workbench/wb_context.h +++ b/backend/wbprivate/workbench/wb_context.h @@ -378,7 +378,7 @@ namespace wb { }; std::list _pending_refreshes; - GMutex *_pending_refresh_mutex; + GMutex _pending_refresh_mutex; WBContextUI *_uicontext; WBContextModel *_model_context; diff --git a/backend/wbpublic/grt/common.cpp b/backend/wbpublic/grt/common.cpp index 1c9a0ce..695c74c 100644 --- a/backend/wbpublic/grt/common.cpp +++ b/backend/wbpublic/grt/common.cpp @@ -309,13 +309,13 @@ namespace bec { TimerActionThread::TimerActionThread(const Action &action, gulong milliseconds) : _action(action), _microseconds(milliseconds * 1000) { - _action_mutex= g_mutex_new(); + g_mutex_init(&_action_mutex); _thread= g_thread_create(start, this, FALSE, NULL); } TimerActionThread::~TimerActionThread() { - g_mutex_free(_action_mutex); + g_mutex_clear(&_action_mutex); } TimerActionThread * TimerActionThread::create(const Action &action, gulong milliseconds) @@ -332,7 +332,7 @@ namespace bec { void TimerActionThread::stop(bool clear_exit_signal) { - GMutexLock action_mutex(_action_mutex); + GMutexLock action_mutex(&_action_mutex); _action= Action(); if (clear_exit_signal) on_exit.disconnect_all_slots(); @@ -348,14 +348,14 @@ namespace bec { { g_usleep(poll_interval); { - GMutexLock action_mutex(_action_mutex); + GMutexLock action_mutex(&_action_mutex); if (_action.empty()) goto exit; } } g_usleep(d.rem); { - GMutexLock action_mutex(_action_mutex); + GMutexLock action_mutex(&_action_mutex); if (_action.empty()) goto exit; if (_microseconds != 0) diff --git a/backend/wbpublic/grt/common.h b/backend/wbpublic/grt/common.h index c005379..cebbdb2 100644 --- a/backend/wbpublic/grt/common.h +++ b/backend/wbpublic/grt/common.h @@ -282,7 +282,7 @@ namespace bec { void stop(bool clear_exit_signal); boost::signals2::signal on_exit; private: - GMutex *_action_mutex; + GMutex _action_mutex; Action _action; gulong _microseconds; GThread *_thread; diff --git a/backend/wbpublic/grt/grt_dispatcher.h b/backend/wbpublic/grt/grt_dispatcher.h index 8abf71d..8d6cb09 100644 --- a/backend/wbpublic/grt/grt_dispatcher.h +++ b/backend/wbpublic/grt/grt_dispatcher.h @@ -39,16 +39,16 @@ namespace bec { class DispatcherCallbackBase { - GMutex *_mutex; - GCond *_cond; + GMutex _mutex; + GCond _cond; int _refcount; public: DispatcherCallbackBase() : _refcount(1) { - _mutex= g_mutex_new(); - _cond= g_cond_new(); + g_mutex_init(&_mutex); + g_cond_init(&_cond); } DispatcherCallbackBase *retain() @@ -67,24 +67,22 @@ namespace bec { virtual ~DispatcherCallbackBase() { signal(); - g_mutex_free(_mutex); - _mutex = 0; - g_cond_free(_cond); - _cond = 0; + g_mutex_clear(&_mutex); + g_cond_clear(&_cond); } virtual void execute()= 0; void wait() { - g_mutex_lock(_mutex); - g_cond_wait(_cond, _mutex); - g_mutex_unlock(_mutex); + g_mutex_lock(&_mutex); + g_cond_wait(&_cond, &_mutex); + g_mutex_unlock(&_mutex); } void signal() { - g_cond_signal(_cond); + g_cond_signal(&_cond); } }; diff --git a/backend/wbpublic/grt/grt_manager.cpp b/backend/wbpublic/grt/grt_manager.cpp index 525b2cb..64caa4e 100644 --- a/backend/wbpublic/grt/grt_manager.cpp +++ b/backend/wbpublic/grt/grt_manager.cpp @@ -67,9 +67,9 @@ GRTManager::GRTManager(bool threaded, bool verbose) main_thread= g_thread_self(); } - _idle_mutex= g_mutex_new(); - _timer_mutex= g_mutex_new(); - _disp_map_mutex= g_mutex_new(); + g_mutex_init(&_idle_mutex); + g_mutex_init(&_timer_mutex); + g_mutex_init(&_disp_map_mutex); _grt= new GRT(); @@ -219,9 +219,9 @@ GRTManager::~GRTManager() for (std::list::iterator iter= _timers.begin(); iter != _timers.end(); ++iter) delete *iter; - g_mutex_free(_disp_map_mutex); - g_mutex_free(_timer_mutex); - g_mutex_free(_idle_mutex); + g_mutex_clear(&_disp_map_mutex); + g_mutex_clear(&_timer_mutex); + g_mutex_clear(&_idle_mutex); } @@ -282,14 +282,14 @@ void GRTManager::execute_grt_task(const std::string &title, void GRTManager::add_dispatcher(GRTDispatcher::Ref disp) { - GMutexLock disp_map_mutex(_disp_map_mutex); + GMutexLock disp_map_mutex(&_disp_map_mutex); _disp_map[disp]; } void GRTManager::remove_dispatcher(GRTDispatcher *disp) { - GMutexLock disp_map_mutex(_disp_map_mutex); + GMutexLock disp_map_mutex(&_disp_map_mutex); for (DispMap::iterator i= _disp_map.begin(), end= _disp_map.end(); i != end; ++i) { if (i->first.get() == disp) @@ -379,7 +379,7 @@ bool GRTManager::initialize_shell(const std::string &shell_type) bool GRTManager::cancel_idle_tasks() { // { TODO -// GMutexLock disp_map_mutex(_disp_map_mutex); +// GMutexLock disp_map_mutex(&_disp_map_mutex); // for (DispMap::iterator i = _disp_map.begin(), i_end = _disp_map.end(); i != i_end; ++i) // i->first->cancel_all_tasks(); // } @@ -388,7 +388,7 @@ bool GRTManager::cancel_idle_tasks() return false; block_idle_tasks(); // TODO: use idle mutex. - GMutexLock lock(_idle_mutex); + GMutexLock lock(&_idle_mutex); _current_idle_signal = 0; _idle_signals[0].disconnect_all_slots(); _idle_signals[1].disconnect_all_slots(); @@ -407,7 +407,7 @@ void GRTManager::perform_idle_tasks() DispMap copy; { - GMutexLock disp_map_mutex(_disp_map_mutex); + GMutexLock disp_map_mutex(&_disp_map_mutex); copy= _disp_map; } @@ -429,7 +429,7 @@ void GRTManager::perform_idle_tasks() int signal_to_emit = 0; { - GMutexLock lock(_idle_mutex); + GMutexLock lock(&_idle_mutex); signal_to_emit = _current_idle_signal; _current_idle_signal = _current_idle_signal ? 0 : 1; } @@ -456,7 +456,7 @@ boost::signals2::connection GRTManager::run_once_when_idle(const boost::function if (!slot) throw std::invalid_argument("Adding null slot for idle"); - GMutexLock lock(_idle_mutex); + GMutexLock lock(&_idle_mutex); return _idle_signals[_current_idle_signal].connect(slot); } @@ -465,7 +465,7 @@ void GRTManager::run_once_when_idle(base::trackable *owner, const boost::functio { if (!slot) throw std::invalid_argument("Adding null slot for idle"); - GMutexLock lock(_idle_mutex); + GMutexLock lock(&_idle_mutex); owner->track_connection(_idle_signals[_current_idle_signal].connect(slot)); } @@ -524,7 +524,7 @@ GRTManager::Timer *GRTManager::run_every(const boost::function &slot, d double delay= timer->delay_for_next_trigger(now); - g_mutex_lock(_timer_mutex); + g_mutex_lock(&_timer_mutex); // insert it in order of delay for next trigger bool inserted= false; for (std::list::iterator iter= _timers.begin(); iter != _timers.end(); ++iter) @@ -538,7 +538,7 @@ GRTManager::Timer *GRTManager::run_every(const boost::function &slot, d } if (!inserted) _timers.push_back(timer); - g_mutex_unlock(_timer_mutex); + g_mutex_unlock(&_timer_mutex); _timeout_request(); @@ -548,7 +548,7 @@ GRTManager::Timer *GRTManager::run_every(const boost::function &slot, d void GRTManager::cancel_timer(GRTManager::Timer *timer) { - g_mutex_lock(_timer_mutex); + g_mutex_lock(&_timer_mutex); std::list::iterator it= std::find(_timers.begin(), _timers.end(), timer); if (it != _timers.end()) { @@ -559,7 +559,7 @@ void GRTManager::cancel_timer(GRTManager::Timer *timer) _cancelled_timers.insert(timer); // if the timer is not in the timers list, then it may be getting executed, // so add it to a list of timers so it doesn't get readded to the timers list - g_mutex_unlock(_timer_mutex); + g_mutex_unlock(&_timer_mutex); } @@ -571,7 +571,7 @@ void GRTManager::flush_timers() std::list triggered; // first get a list of timers that trigger now - g_mutex_lock(_timer_mutex); + g_mutex_lock(&_timer_mutex); std::list::iterator next, iter= _timers.begin(); while (iter != _timers.end()) { @@ -586,7 +586,7 @@ void GRTManager::flush_timers() iter= next; } - g_mutex_unlock(_timer_mutex); + g_mutex_unlock(&_timer_mutex); // after this point it's impossible for the timer to be cancelled // because it is not in the timers list anymore @@ -601,7 +601,7 @@ void GRTManager::flush_timers() { double delay= (*iter)->delay_for_next_trigger(now); - g_mutex_lock(_timer_mutex); + g_mutex_lock(&_timer_mutex); if (_cancelled_timers.find(*iter) == _cancelled_timers.end()) { @@ -622,18 +622,18 @@ void GRTManager::flush_timers() else delete *iter; - g_mutex_unlock(_timer_mutex); + g_mutex_unlock(&_timer_mutex); } else { - g_mutex_lock(_timer_mutex); + g_mutex_lock(&_timer_mutex); delete *iter; - g_mutex_unlock(_timer_mutex); + g_mutex_unlock(&_timer_mutex); } } - g_mutex_lock(_timer_mutex); + g_mutex_lock(&_timer_mutex); _cancelled_timers.clear(); - g_mutex_unlock(_timer_mutex); + g_mutex_unlock(&_timer_mutex); } @@ -641,7 +641,7 @@ double GRTManager::delay_for_next_timeout() { double delay= -1; - g_mutex_lock(_timer_mutex); + g_mutex_lock(&_timer_mutex); if (!_timers.empty()) { GTimeVal now; @@ -650,7 +650,7 @@ double GRTManager::delay_for_next_timeout() if (delay < 0) delay= 0.0; } - g_mutex_unlock(_timer_mutex); + g_mutex_unlock(&_timer_mutex); return delay; } diff --git a/backend/wbpublic/grt/grt_manager.h b/backend/wbpublic/grt/grt_manager.h index ac78bac..71ddded 100644 --- a/backend/wbpublic/grt/grt_manager.h +++ b/backend/wbpublic/grt/grt_manager.h @@ -202,8 +202,8 @@ namespace bec { grt::GRT *_grt; bool _has_unsaved_changes; GRTDispatcher::Ref _dispatcher; - GMutex *_idle_mutex; - GMutex *_timer_mutex; + GMutex _idle_mutex; + GMutex _timer_mutex; public: @@ -212,7 +212,7 @@ namespace bec { protected: typedef std::map DispMap; DispMap _disp_map; - GMutex *_disp_map_mutex; + GMutex _disp_map_mutex; PluginManager *_plugin_manager; diff --git a/backend/wbpublic/grt/tree_model.h b/backend/wbpublic/grt/tree_model.h index 1cee0ec..532b167 100644 --- a/backend/wbpublic/grt/tree_model.h +++ b/backend/wbpublic/grt/tree_model.h @@ -79,17 +79,18 @@ namespace bec Pool() : _pool(4) - , _sync(g_mutex_new()) - {} + { + g_mutex_init(&_sync); + } ~Pool() { { - base::GMutexLock lock(_sync); + base::GMutexLock lock(&_sync); std::for_each(_pool.begin(), _pool.end(), Pool::delete_object); } - g_mutex_free(_sync); + g_mutex_clear(&_sync); } T* get() @@ -97,7 +98,7 @@ namespace bec T* item = 0; try { - base::GMutexLock lock(_sync); + base::GMutexLock lock(&_sync); if ( _pool.size() > 0 ) { item = _pool.back(); @@ -119,13 +120,13 @@ namespace bec void put(T* item) { - base::GMutexLock lock(_sync); + base::GMutexLock lock(&_sync); _pool.push_back(item); } private: std::vector _pool; - GMutex *_sync; //! Protect against concurrent access within threads + GMutex _sync; //! Protect against concurrent access within threads }; /** diff --git a/backend/wbpublic/sqlide/autocomplete_object_name_cache.cpp b/backend/wbpublic/sqlide/autocomplete_object_name_cache.cpp index 0122b39..6b2e6de 100644 --- a/backend/wbpublic/sqlide/autocomplete_object_name_cache.cpp +++ b/backend/wbpublic/sqlide/autocomplete_object_name_cache.cpp @@ -54,9 +54,9 @@ AutoCompleteCache::AutoCompleteCache(const std::string &connection_id, : _refresh_thread(0), _connection_id(connection_id), _get_connection(get_connection), _schema_list_fetched(false), _shutdown(false) { _feedback = feedback; - _pending_mutex = g_mutex_new(); - _shutdown_mutex = g_mutex_new(); - _sqconn_mutex = g_mutex_new(); + g_mutex_init(&_pending_mutex); + g_mutex_init(&_shutdown_mutex); + g_mutex_init(&_sqconn_mutex); _sqconn = new sqlite::connection(make_path(cache_dir, _connection_id)+".cache"); sqlite::execute(*_sqconn, "PRAGMA temp_store=MEMORY", true); sqlite::execute(*_sqconn, "PRAGMA synchronous=NORMAL", true); @@ -98,11 +98,11 @@ AutoCompleteCache::AutoCompleteCache(const std::string &connection_id, void AutoCompleteCache::shutdown() { - base::GMutexLock sd_lock(_shutdown_mutex); + base::GMutexLock sd_lock(&_shutdown_mutex); _shutdown = true; { - base::GMutexLock lock(_pending_mutex); + base::GMutexLock lock(&_pending_mutex); _pending_refresh_schema.clear(); _feedback = NULL; } @@ -123,9 +123,9 @@ AutoCompleteCache::~AutoCompleteCache() g_assert(_shutdown); delete _sqconn; - g_mutex_free(_sqconn_mutex); - g_mutex_free(_pending_mutex); - g_mutex_free(_shutdown_mutex); + g_mutex_clear(&_sqconn_mutex); + g_mutex_clear(&_pending_mutex); + g_mutex_clear(&_shutdown_mutex); } //-------------------------------------------------------------------------------------------------- @@ -138,8 +138,8 @@ std::vector AutoCompleteCache::get_matching_schema_names(const std if (!_shutdown) { // Ensures shutdown is not done while processing - base::GMutexLock sd_lock(_shutdown_mutex); - base::GMutexLock lock(_sqconn_mutex); + base::GMutexLock sd_lock(&_shutdown_mutex); + base::GMutexLock lock(&_sqconn_mutex); sqlite::query q(*_sqconn, "SELECT name FROM schemas WHERE name LIKE ? ESCAPE '\\'"); q.bind(1, base::escape_sql_string(prefix, true) + "%"); if (q.emit()) @@ -175,8 +175,8 @@ std::vector AutoCompleteCache::get_matching_table_names(const std:: if (!_shutdown) { // Ensures shutdown is not done while processing - base::GMutexLock sd_lock(_shutdown_mutex); - base::GMutexLock lock(_sqconn_mutex); + base::GMutexLock sd_lock(&_shutdown_mutex); + base::GMutexLock lock(&_sqconn_mutex); sqlite::query q(*_sqconn, "SELECT name FROM tables WHERE schema LIKE ? ESCAPE '\\' AND name LIKE ? ESCAPE '\\'"); q.bind(1, schema.size() == 0 ? "%" : base::escape_sql_string(schema, true)); q.bind(2, base::escape_sql_string(prefix, true) + "%"); @@ -213,8 +213,8 @@ std::vector AutoCompleteCache::get_matching_column_names(const std: if (!_shutdown) { // Ensures shutdown is not done while processing - base::GMutexLock sd_lock(_shutdown_mutex); - base::GMutexLock lock(_sqconn_mutex); + base::GMutexLock sd_lock(&_shutdown_mutex); + base::GMutexLock lock(&_sqconn_mutex); sqlite::query q(*_sqconn, "SELECT name FROM columns WHERE schema LIKE ? ESCAPE '\\' " "AND tabl LIKE ? ESCAPE '\\' AND name LIKE ? ESCAPE '\\'"); q.bind(1, schema.size() == 0 ? "%" : base::escape_sql_string(schema, true)); @@ -255,8 +255,8 @@ std::vector AutoCompleteCache::get_matching_procedure_names(const s if (!_shutdown) { // Ensures shutdown is not done while processing - base::GMutexLock sd_lock(_shutdown_mutex); - base::GMutexLock lock(_sqconn_mutex); + base::GMutexLock sd_lock(&_shutdown_mutex); + base::GMutexLock lock(&_sqconn_mutex); sqlite::query q(*_sqconn, "SELECT name FROM routines WHERE schema LIKE ? ESCAPE '\\' " "AND name LIKE ? ESCAPE '\\' AND is_function=0"); q.bind(1, schema.size() == 0 ? "%" : base::escape_sql_string(schema, true)); @@ -295,8 +295,8 @@ std::vector AutoCompleteCache::get_matching_function_names(const st if (!_shutdown) { // Ensures shutdown is not done while processing - base::GMutexLock sd_lock(_shutdown_mutex); - base::GMutexLock lock(_sqconn_mutex); + base::GMutexLock sd_lock(&_shutdown_mutex); + base::GMutexLock lock(&_sqconn_mutex); sqlite::query q(*_sqconn, "SELECT name FROM routines WHERE schema LIKE ? ESCAPE '\\' " "AND name LIKE ? ESCAPE '\\' AND is_function=1"); q.bind(1, schema.size() == 0 ? "%" : base::escape_sql_string(schema, true)); @@ -335,8 +335,8 @@ bool AutoCompleteCache::refresh_schema_cache_if_needed(const std::string &schema if (!_shutdown) { // Ensures shutdown is not done while processing - base::GMutexLock sd_lock(_shutdown_mutex); - base::GMutexLock lock(_sqconn_mutex); + base::GMutexLock sd_lock(&_shutdown_mutex); + base::GMutexLock lock(&_sqconn_mutex); sqlite::query q(*_sqconn, "SELECT last_refresh FROM schemas WHERE name LIKE ? ESCAPE '\\' "); q.bind(1, schema.size() == 0 ? "%" : base::escape_sql_string(schema, true)); if (q.emit()) @@ -627,7 +627,7 @@ void AutoCompleteCache::init_db() bool AutoCompleteCache::is_schema_list_fetch_done() { - base::GMutexLock lock(_sqconn_mutex); + base::GMutexLock lock(&_sqconn_mutex); sqlite::query q(*_sqconn, "select * from schemas"); if (q.emit()) return true; @@ -637,7 +637,7 @@ bool AutoCompleteCache::is_schema_list_fetch_done() bool AutoCompleteCache::is_schema_tables_fetch_done(const std::string &schema) { - base::GMutexLock lock(_sqconn_mutex); + base::GMutexLock lock(&_sqconn_mutex); sqlite::query q(*_sqconn, "select * from tables where schema = ?"); q.bind(1, schema); if (q.emit()) @@ -647,7 +647,7 @@ bool AutoCompleteCache::is_schema_tables_fetch_done(const std::string &schema) bool AutoCompleteCache::is_schema_table_columns_fetch_done(const std::string &schema, const std::string &table) { - base::GMutexLock lock(_sqconn_mutex); + base::GMutexLock lock(&_sqconn_mutex); sqlite::query q(*_sqconn, "select * from columns where schema = ? and tabl = ?"); q.bind(1, schema); q.bind(2, table); @@ -658,7 +658,7 @@ bool AutoCompleteCache::is_schema_table_columns_fetch_done(const std::string &sc bool AutoCompleteCache::is_schema_routines_fetch_done(const std::string &schema) { - base::GMutexLock lock(_sqconn_mutex); + base::GMutexLock lock(&_sqconn_mutex); sqlite::query q(*_sqconn, "select * from routines where schema = ?"); q.bind(1, schema); if (q.emit()) @@ -694,8 +694,8 @@ void AutoCompleteCache::update_schemas(const std::vector &schemas) if (!_shutdown) { // Ensures shutdown is not done while processing - base::GMutexLock sd_lock(_shutdown_mutex); - base::GMutexLock lock(_sqconn_mutex); + base::GMutexLock sd_lock(&_shutdown_mutex); + base::GMutexLock lock(&_sqconn_mutex); std::map old_schema_update_times; { @@ -758,8 +758,8 @@ void AutoCompleteCache::update_schema_tables(const std::string &schema, if (!_shutdown) { // Ensures shutdown is not done while processing - base::GMutexLock sd_lock(_shutdown_mutex); - base::GMutexLock lock(_sqconn_mutex); + base::GMutexLock sd_lock(&_shutdown_mutex); + base::GMutexLock lock(&_sqconn_mutex); touch_schema_record(schema); @@ -807,8 +807,8 @@ void AutoCompleteCache::update_schema_routines(const std::string &schema, if (!_shutdown) { // Ensures shutdown is not done while processing - base::GMutexLock sd_lock(_shutdown_mutex); - base::GMutexLock lock(_sqconn_mutex); + base::GMutexLock sd_lock(&_shutdown_mutex); + base::GMutexLock lock(&_sqconn_mutex); touch_schema_record(schema); @@ -856,8 +856,8 @@ void AutoCompleteCache::update_table_columns(const std::string &schema, const st if (!_shutdown) { // Ensures shutdown is not done while processing - base::GMutexLock sd_lock(_shutdown_mutex); - base::GMutexLock lock(_sqconn_mutex); + base::GMutexLock sd_lock(&_shutdown_mutex); + base::GMutexLock lock(&_sqconn_mutex); sqlide::Sqlite_transaction_guarder trans(_sqconn, false); //will be commited when will go out of the scope try { @@ -901,8 +901,8 @@ void AutoCompleteCache::add_pending_refresh(const std::string& task) if (!_shutdown) { // Ensures shutdown is not done while processing - base::GMutexLock sd_lock(_shutdown_mutex); - base::GMutexLock lock(_pending_mutex); + base::GMutexLock sd_lock(&_shutdown_mutex); + base::GMutexLock lock(&_pending_mutex); if ((!task.empty() || !_schema_list_fetched) && std::find(_pending_refresh_schema.begin(), _pending_refresh_schema.end(), task) == _pending_refresh_schema.end()) { @@ -922,8 +922,8 @@ bool AutoCompleteCache::get_pending_refresh(std::string &task) if (!_shutdown) { // Ensures shutdown is not done while processing - base::GMutexLock sd_lock(_shutdown_mutex); - base::GMutexLock lock(_pending_mutex); + base::GMutexLock sd_lock(&_shutdown_mutex); + base::GMutexLock lock(&_pending_mutex); if (!_pending_refresh_schema.empty()) { diff --git a/backend/wbpublic/sqlide/autocomplete_object_name_cache.h b/backend/wbpublic/sqlide/autocomplete_object_name_cache.h index 834bc62..0f341ee 100644 --- a/backend/wbpublic/sqlide/autocomplete_object_name_cache.h +++ b/backend/wbpublic/sqlide/autocomplete_object_name_cache.h @@ -79,14 +79,14 @@ private: void add_pending_refresh(const std::string& task); void create_worker_thread(); - GMutex *_sqconn_mutex; + GMutex _sqconn_mutex; sqlite::connection *_sqconn; GThread *_refresh_thread; - GMutex *_shutdown_mutex; + GMutex _shutdown_mutex; - GMutex *_pending_mutex; + GMutex _pending_mutex; std::list _pending_refresh_schema; std::string _connection_id; diff --git a/backend/wbpublic/sqlide/sql_editor_be.cpp b/backend/wbpublic/sqlide/sql_editor_be.cpp index 9f56939..a2b091f 100644 --- a/backend/wbpublic/sqlide/sql_editor_be.cpp +++ b/backend/wbpublic/sqlide/sql_editor_be.cpp @@ -79,7 +79,7 @@ public: Sql_semantic_check::Ref _sql_checker; GrtThreadedTask::Ref _sql_checker_task; - GMutex *_sql_checker_mutex; + GMutex _sql_checker_mutex; int _sql_checker_tag; bool _clearance_pending; bec::GRTManager::Timer* _current_timer; @@ -97,12 +97,12 @@ public: }; typedef std::vector SqlErrors; SqlErrors _parse_error_cache; // Temporary storage used during parsing. - GMutex *_sql_errors_mutex; + GMutex _sql_errors_mutex; std::vector > _parse_errors; // Permanent error storage. unsigned int _last_error_count; bool _splitting_required; - GMutex *_sql_statement_borders_mutex; + GMutex _sql_statement_borders_mutex; // Each entry is a pair of statement position (byte position) and statement length (also bytes). std::vector > _statement_ranges; @@ -174,9 +174,10 @@ Sql_editor::Sql_editor(db_mgmt_RdbmsRef rdbms, GrtVersionRef version) d->_sql_check_progress_msg_throttle = 500; - d->_sql_checker_mutex = g_mutex_new(); - d->_sql_errors_mutex = g_mutex_new(); - d->_sql_statement_borders_mutex = g_mutex_new(); + g_mutex_init(&d->_sql_checker_mutex); + g_mutex_init(&d->_sql_errors_mutex); + g_mutex_init(&d->_sql_statement_borders_mutex); + d->_splitting_required = false; d->_grtm= GRTManager::get_instance_for(rdbms->get_grt()); @@ -244,9 +245,9 @@ Sql_editor::~Sql_editor() { // We lock all mutexes for a moment here to ensure no background thread is still holding them. - GMutexLock sql_checker_mutex(d->_sql_checker_mutex); - GMutexLock sql_errors_mutex(d->_sql_errors_mutex); - GMutexLock sql_statement_borders_mutex(d->_sql_statement_borders_mutex); + GMutexLock sql_checker_mutex(&d->_sql_checker_mutex); + GMutexLock sql_errors_mutex(&d->_sql_errors_mutex); + GMutexLock sql_statement_borders_mutex(&d->_sql_statement_borders_mutex); d->_is_sql_check_enabled = false; } @@ -259,10 +260,9 @@ Sql_editor::~Sql_editor() delete _code_editor; // Descendants which set _editor_config are responsible to free it. - - g_mutex_free(d->_sql_checker_mutex); - g_mutex_free(d->_sql_errors_mutex); - g_mutex_free(d->_sql_statement_borders_mutex); + g_mutex_clear(&d->_sql_checker_mutex); + g_mutex_clear(&d->_sql_errors_mutex); + g_mutex_clear(&d->_sql_statement_borders_mutex); delete d; } @@ -755,7 +755,7 @@ bool Sql_editor::check_sql(bool sync) d->_sql_checker_tag++; { - GMutexLock sql_errors_mutex(d->_sql_errors_mutex); + GMutexLock sql_errors_mutex(&d->_sql_errors_mutex); d->_parse_error_cache.clear(); d->_parse_errors.clear(); } @@ -781,11 +781,11 @@ grt::StringRef Sql_editor::do_check_sql(grt::GRT *grt, Ptr self_ptr) // server parser based splitter. // TODO: instead doing another splitting let the parser use the result of this dedicated run. { - GMutexLock sql_statement_borders_mutex(d->_sql_statement_borders_mutex); + GMutexLock sql_statement_borders_mutex(&d->_sql_statement_borders_mutex); d->split_statements_if_required(); } - GMutexLock sql_checker_mutex(d->_sql_checker_mutex); + GMutexLock sql_checker_mutex(&d->_sql_checker_mutex); // Serves as flag that we should go out here immediately (when closing the editor). if (!d->_is_sql_check_enabled) @@ -822,7 +822,7 @@ int Sql_editor::on_sql_error(int tok_lineno, int tok_line_pos, int tok_len, cons return 0; d->_last_error_count++; { - GMutexLock sql_errors_mutex(d->_sql_errors_mutex); + GMutexLock sql_errors_mutex(&d->_sql_errors_mutex); d->_parse_error_cache.push_back(Private::SqlError(tok_lineno, tok_line_pos, tok_len, msg, tag)); } request_sql_check_results_refresh(); @@ -871,7 +871,7 @@ int Sql_editor::on_sql_check_progress(float progress, const std::string &msg, in // Add all statement markers here too. { - GMutexLock sql_statement_borders_mutex(d->_sql_statement_borders_mutex); + GMutexLock sql_statement_borders_mutex(&d->_sql_statement_borders_mutex); for (std::vector >::const_iterator iterator = d->_statement_ranges.begin(); iterator != d->_statement_ranges.end(); ++iterator) { @@ -896,7 +896,7 @@ int Sql_editor::on_sql_check_progress(float progress, const std::string &msg, in { Private::SqlErrors sql_errors; { - GMutexLock sql_errors_mutex(d->_sql_errors_mutex); + GMutexLock sql_errors_mutex(&d->_sql_errors_mutex); d->_parse_error_cache.swap(sql_errors); } @@ -1196,7 +1196,7 @@ bool Sql_editor::get_current_statement_ranges(int &start, int &end) // In case the splitter is right now processing the text we wait here until its done. // If the splitter wasn't triggered yet (e.g. when typing fast and then immediately running a statement) // then we do the splitting here instead. - GMutexLock sql_statement_borders_mutex(d->_sql_statement_borders_mutex); + GMutexLock sql_statement_borders_mutex(&d->_sql_statement_borders_mutex); d->split_statements_if_required(); if (d->_statement_ranges.empty()) diff --git a/backend/wbpublic/sqlide/unit-tests/autocompletion_cache_test.cpp b/backend/wbpublic/sqlide/unit-tests/autocompletion_cache_test.cpp index ea39489..3910522 100644 --- a/backend/wbpublic/sqlide/unit-tests/autocompletion_cache_test.cpp +++ b/backend/wbpublic/sqlide/unit-tests/autocompletion_cache_test.cpp @@ -29,13 +29,13 @@ using namespace grt; using namespace wb; // Helper to wait for cache operations to finish. -static GMutex *cache_mutex; -static GCond *cache_condition; +static GMutex cache_mutex; +static GCond cache_condition; BEGIN_TEST_DATA_CLASS(autocompletion_cache_test) public: GRT _grt; - GMutex *_connection_mutex; + GMutex _connection_mutex; sql::Dbc_connection_handler::Ref _conn; AutoCompleteCache *_cache; @@ -45,9 +45,7 @@ TEST_DATA_CONSTRUCTOR(autocompletion_cache_test) _grt.scan_metaclasses_in("../../res/grt/"); _grt.end_loading_metaclasses(); - _connection_mutex = g_mutex_new(); - cache_mutex = g_mutex_new(); - cache_condition = g_cond_new(); + g_mutex_init(_connection_mutex); // setup the sakila db in server setup_sakila_db(); @@ -58,11 +56,12 @@ TEST_DATA_DESTRUCTOR(autocompletion_cache_test) // cleanup_sakila_db(); _cache->shutdown(); delete _cache; + g_mutex_clear(_connection_mutex); } base::GMutexLock get_connection(sql::Dbc_connection_handler::Ref &conn) { - base::GMutexLock lock(_connection_mutex); + base::GMutexLock lock(&_connection_mutex); conn = _conn; return lock; } @@ -75,9 +74,9 @@ static void cache_callback(bool working) { if (!working) { - g_mutex_lock(cache_mutex); - g_cond_signal(cache_condition); - g_mutex_unlock(cache_mutex); + g_mutex_lock(&cache_mutex); + g_cond_signal(&cache_condition); + g_mutex_unlock(&cache_mutex); } } @@ -138,7 +137,7 @@ TEST_FUNCTION(10) // The loops are not necessary, but there can be spurious condition signals, // as the glib docs say. while (!_cache->is_schema_list_fetch_done()) - g_cond_wait(cache_condition, cache_mutex); + g_cond_wait(&cache_condition, &cache_mutex); list = _cache->get_matching_schema_names(""); int found = 0; @@ -175,7 +174,7 @@ TEST_FUNCTION(12) std::vector list = _cache->get_matching_table_names("sakila", "ac"); while (!_cache->is_schema_tables_fetch_done("sakila")) - g_cond_wait(cache_condition, cache_mutex); + g_cond_wait(&cache_condition, &cache_mutex); // get the list now list = _cache->get_matching_table_names("sakila", "ac"); @@ -195,7 +194,7 @@ TEST_FUNCTION(14) std::vector list = _cache->get_matching_function_names("sakila", "inv"); while (!_cache->is_schema_routines_fetch_done("sakila")) - g_cond_wait(cache_condition, cache_mutex); + g_cond_wait(&cache_condition, &cache_mutex); // get the list now list = _cache->get_matching_function_names("sakila", "inv"); @@ -212,7 +211,7 @@ TEST_FUNCTION(16) std::vector list = _cache->get_matching_procedure_names("sakila", "fi"); while (!_cache->is_schema_routines_fetch_done("sakila")) - g_cond_wait(cache_condition, cache_mutex); + g_cond_wait(&cache_condition, &cache_mutex); // get the list now list = _cache->get_matching_procedure_names("sakila", "fi"); @@ -230,7 +229,7 @@ TEST_FUNCTION(18) std::vector list = _cache->get_matching_column_names("sakila", "actor", "a"); while (!_cache->is_schema_table_columns_fetch_done("sakila", "actor")) - g_cond_wait(cache_condition, cache_mutex); + g_cond_wait(&cache_condition, &cache_mutex); // get the list now list = _cache->get_matching_column_names("sakila", "actor", "a"); diff --git a/backend/wbpublic/sqlide/unit-tests/sql_editor_be_autocomplete_tests.cpp b/backend/wbpublic/sqlide/unit-tests/sql_editor_be_autocomplete_tests.cpp index 85aad31..0627c5c 100644 --- a/backend/wbpublic/sqlide/unit-tests/sql_editor_be_autocomplete_tests.cpp +++ b/backend/wbpublic/sqlide/unit-tests/sql_editor_be_autocomplete_tests.cpp @@ -33,14 +33,14 @@ using namespace bec; using namespace wb; // Helper to wait for cache operations to finish. -static GMutex *cache_mutex; -static GCond *cache_condition; +static GMutex cache_mutex; +static GCond cache_condition; struct ac_test_entry { int version_first; // First supported version for this entry int version_last; // Last supported version for this entry - + std::string query; std::string typed_part; int line; @@ -57,7 +57,7 @@ protected: Sql_editor::Ref _sql_editor; GrtVersionRef _version; - GMutex *_connection_mutex; + GMutex _connection_mutex; sql::Dbc_connection_handler::Ref _conn; AutoCompleteCache *_cache; int version; @@ -70,19 +70,14 @@ TEST_DATA_CONSTRUCTOR(sql_editor_be_autocomplete_tests) // Auto completion needs a cache for object name look up, so we have to set up one // with all bells and whistles. - _connection_mutex = g_mutex_new(); - - cache_mutex = g_mutex_new(); - cache_condition = g_cond_new(); + g_mutex_init(&_connection_mutex); } TEST_DATA_DESTRUCTOR(sql_editor_be_autocomplete_tests) { _cache->shutdown(); delete _cache; - g_mutex_free(_connection_mutex); - g_mutex_free(cache_mutex); - g_cond_free(cache_condition); + g_mutex_clear(&_connection_mutex); } base::GMutexLock get_connection(sql::Dbc_connection_handler::Ref &conn) @@ -252,9 +247,9 @@ void cache_callback(bool working) { if (!working) { - g_mutex_lock(cache_mutex); - g_cond_signal(cache_condition); - g_mutex_unlock(cache_mutex); + g_mutex_lock(&cache_mutex); + g_cond_signal(&cache_condition); + g_mutex_unlock(&cache_mutex); } } @@ -311,12 +306,12 @@ TEST_FUNCTION(5) // The loops are not necessary, but there can be spurious condition signals, // as the glib docs say. while (!_cache->is_schema_list_fetch_done()) - g_cond_wait(cache_condition, cache_mutex); + g_cond_wait(&cache_condition, &cache_mutex); _cache->get_matching_table_names("sakila"); // Cache all tables and columns. while (!_cache->is_schema_table_columns_fetch_done("sakila", "store")) - g_cond_wait(cache_condition, cache_mutex); + g_cond_wait(&cache_condition, &cache_mutex); } /** diff --git a/frontend/linux/workbench/sqlide_form.cpp b/frontend/linux/workbench/sqlide_form.cpp index a1cb807..4cf6e08 100644 --- a/frontend/linux/workbench/sqlide_form.cpp +++ b/frontend/linux/workbench/sqlide_form.cpp @@ -132,7 +132,7 @@ DbSqlEditorView::DbSqlEditorView(SqlEditorForm::Ref editor_be) _be->recordset_list_changed.connect(sigc::mem_fun(this, &DbSqlEditorView::recordset_list_changed)); _be->output_text_slot= sigc::mem_fun(this, &DbSqlEditorView::output_text); - _update_resultset_slots_lock = g_mutex_new(); + g_mutex_init(&_update_resultset_slots_lock); _dispatch_rset_update_conn = _dispatch_rset_update.connect(sigc::mem_fun(this, &DbSqlEditorView::update_resultsets_from_main)); _editor_note->signal_switch_page().connect(sigc::mem_fun(this, &DbSqlEditorView::editor_page_switched)); @@ -233,11 +233,10 @@ DbSqlEditorView::~DbSqlEditorView() dispose(); - while (!g_mutex_trylock(_update_resultset_slots_lock)); // maybe add sleep here + while (!g_mutex_trylock(&_update_resultset_slots_lock)); // maybe add sleep here - g_mutex_unlock(_update_resultset_slots_lock); - g_mutex_free(_update_resultset_slots_lock); - _update_resultset_slots_lock = 0; + g_mutex_unlock(&_update_resultset_slots_lock); + g_mutex_clear(&_update_resultset_slots_lock); } //------------------------------------------------------------------------------ @@ -767,7 +766,7 @@ void DbSqlEditorView::update_resultsets_from_main() std::deque > slots; { - base::GMutexLock lock(_update_resultset_slots_lock); + base::GMutexLock lock(&_update_resultset_slots_lock); slots = _update_resultset_slots; _update_resultset_slots.clear(); } @@ -794,7 +793,7 @@ void DbSqlEditorView::recordset_list_changed(int editor_index, Recordset::Ref rs sigc::slot update_resultset_slot = sigc::bind(sigc::mem_fun(this, &DbSqlEditorView::update_resultsets), editor_index, rset, added); { - base::GMutexLock lock(_update_resultset_slots_lock); + base::GMutexLock lock(&_update_resultset_slots_lock); _update_resultset_slots.push_back(update_resultset_slot); } diff --git a/frontend/linux/workbench/sqlide_form.h b/frontend/linux/workbench/sqlide_form.h index 3c2f0d5..2028889 100644 --- a/frontend/linux/workbench/sqlide_form.h +++ b/frontend/linux/workbench/sqlide_form.h @@ -87,8 +87,8 @@ class DbSqlEditorView : public Gtk::VBox, public FormViewBase void update_resultsets(int editor_index, Recordset::Ref rset, bool added); void update_resultsets_from_main(); - std::deque > _update_resultset_slots; // Slot will have editor index, resultset attached - GMutex *_update_resultset_slots_lock; + std::deque > _update_resultset_slots; // Slot will have editor index, resultset attached + GMutex _update_resultset_slots_lock; int add_editor_tab(int active_sql_editor_index); void editor_page_switched(GtkNotebookPage *page, guint index); diff --git a/library/base/base/threaded_timer.h b/library/base/base/threaded_timer.h index a7bac5d..259b5c0 100644 --- a/library/base/base/threaded_timer.h +++ b/library/base/base/threaded_timer.h @@ -67,7 +67,7 @@ public: static int add_task(TimerUnit unit, double value, bool single_shot, timer_function callback_, void* user_data); static void remove_task(int task_id); private: - GMutex* _timer_lock; // Synchronize access to the timer class. + GMutex _timer_lock; // Synchronize access to the timer class. GThreadPool* _pool; // A number of threads which trigger the callbacks (to make them independant of each other). int _wait_time; // The time the timer thread has to wait until looking for new tasks to execute. bool _terminate; // Set to true when shutting down the timer. diff --git a/library/base/threaded_timer.cpp b/library/base/threaded_timer.cpp index a81db73..68149d9 100644 --- a/library/base/threaded_timer.cpp +++ b/library/base/threaded_timer.cpp @@ -105,14 +105,14 @@ int ThreadedTimer::add_task(TimerUnit unit, double value, bool single_shot, time if (task.wait_time > 0) { ThreadedTimer* timer= ThreadedTimer::get(); - g_mutex_lock(timer->_timer_lock); + g_mutex_lock(&timer->_timer_lock); // We have the lock acquired so it is save to increment the id counter. task.task_id= timer->_next_id++; task.user_data= user_data; timer->_tasks.push_back(task); - g_mutex_unlock(timer->_timer_lock); + g_mutex_unlock(&timer->_timer_lock); return task.task_id; } @@ -139,7 +139,7 @@ ThreadedTimer::ThreadedTimer(int base_frequency): _terminate(false), _next_id(1) { // Wait time in microseconds. _wait_time= 1000 * 1000 / base_frequency; - _timer_lock= g_mutex_new(); + g_mutex_init(&_timer_lock); _thread= g_thread_create(start, this, TRUE, NULL); _pool= g_thread_pool_new((GFunc) pool_function, this, WORKER_THREAD_COUNT, FALSE, NULL); } @@ -162,7 +162,7 @@ ThreadedTimer::~ThreadedTimer() g_thread_join(_thread); g_thread_pool_free(_pool, TRUE, TRUE); - g_mutex_free(_timer_lock); + g_mutex_clear(&_timer_lock); log_debug2("Threaded timer shutdown done\n"); } @@ -193,29 +193,29 @@ gpointer ThreadedTimer::pool_function(gpointer data, gpointer user_data) { bool do_stop= task->callback(task->task_id, task->user_data); - g_mutex_lock(timer->_timer_lock); + g_mutex_lock(&timer->_timer_lock); task->stop= do_stop || task->single_shot; task->scheduled= false; - g_mutex_unlock(timer->_timer_lock); + g_mutex_unlock(&timer->_timer_lock); } catch (std::exception& e) { // In the case of an exception we remove the task silently. - g_mutex_lock(timer->_timer_lock); + g_mutex_lock(&timer->_timer_lock); task->stop= true; task->scheduled= false; log_warning("Threaded timer: exception in pool function: %s\n", e.what()); - g_mutex_unlock(timer->_timer_lock); + g_mutex_unlock(&timer->_timer_lock); } catch (...) { // Most exceptions should be caught by the part above. Just to be on the safe side // do this extra branch. - g_mutex_lock(timer->_timer_lock); + g_mutex_lock(&timer->_timer_lock); task->stop= true; task->scheduled= false; log_warning("Threaded timer: unknown exception in pool function\n"); - g_mutex_unlock(timer->_timer_lock); + g_mutex_unlock(&timer->_timer_lock); } return NULL; @@ -247,7 +247,7 @@ void ThreadedTimer::main_loop() break; // 1. Compute next execution time for new tasks. - g_mutex_lock(_timer_lock); + g_mutex_lock(&_timer_lock); for (std::list::iterator iterator= _tasks.begin(); iterator != _tasks.end(); iterator++) { if (iterator->next_time == 0) @@ -277,7 +277,7 @@ void ThreadedTimer::main_loop() // 3. Remove stopped task. _tasks.remove_if(IsStopped()); - g_mutex_unlock(_timer_lock); + g_mutex_unlock(&_timer_lock); } // printf("timer thread ended\n"); g_timer_destroy(clock); @@ -290,7 +290,7 @@ void ThreadedTimer::main_loop() */ void ThreadedTimer::remove(int task_id) { - g_mutex_lock(_timer_lock); + g_mutex_lock(&_timer_lock); for (std::list::iterator iterator= _tasks.begin(); iterator != _tasks.end(); iterator++) { if (iterator->task_id == task_id) @@ -299,7 +299,7 @@ void ThreadedTimer::remove(int task_id) break; } } - g_mutex_unlock(_timer_lock); + g_mutex_unlock(&_timer_lock); } //-------------------------------------------------------------------------------------------------- diff --git a/library/forms/utilities.cpp b/library/forms/utilities.cpp index 603cbba..2e573af 100644 --- a/library/forms/utilities.cpp +++ b/library/forms/utilities.cpp @@ -190,6 +190,15 @@ static void mutex_free(GMutex *m) g_mutex_free(m); } +static GMutex * mutex_new() +{ + GMutex *mutex; + mutex = g_slice_new(GMutex); + g_mutex_init(mutex); + + return mutex; +} + bool Utilities::run_cancelable_task(const std::string &title, const std::string &text, const boost::function &task, const boost::function &cancel_task, @@ -200,7 +209,7 @@ bool Utilities::run_cancelable_task(const std::string &title, const std::string CancellableTaskData *data = new CancellableTaskData(); // this is freed by the thread boost::shared_ptr finished(new bool(false)); boost::shared_ptr result(new void*((void*)-1)); - boost::shared_ptr lock(g_mutex_new(), mutex_free); + boost::shared_ptr lock(mutex_new(), mutex_free); data->mutex = lock; data->task = task; diff --git a/modules/db.mysql.query/src/dbquery.cpp b/modules/db.mysql.query/src/dbquery.cpp index c997615..64b26d6 100644 --- a/modules/db.mysql.query/src/dbquery.cpp +++ b/modules/db.mysql.query/src/dbquery.cpp @@ -43,12 +43,12 @@ public: : grt::ModuleImplBase(loader), _last_error_code(0), _connection_id(0), _resultset_id(0), _tunnel_id(0) { - _mutex = g_mutex_new(); + g_mutex_init(&_mutex); } virtual ~DbMySQLQueryImpl() { - g_mutex_free(_mutex); + g_mutex_clear(&_mutex); } DEFINE_INIT_MODULE_DOC("1.0", "Oracle", DOC_DbMySQLQueryImpl, grt::ModuleImplBase, @@ -241,7 +241,7 @@ private: long long last_update_count; }; - GMutex *_mutex; + GMutex _mutex; std::map _connections; std::map _resultsets; std::map > _tunnels; @@ -296,7 +296,7 @@ int DbMySQLQueryImpl::openConnectionP(const db_mgmt_ConnectionRef &info, const g try { { - Lock lock(_mutex); + Lock lock(&_mutex); new_connection_id = ++_connection_id; } sql::ConnectionWrapper conn; @@ -310,14 +310,14 @@ int DbMySQLQueryImpl::openConnectionP(const db_mgmt_ConnectionRef &info, const g else conn = dm->getConnection(info); - Lock lock(_mutex); + Lock lock(&_mutex); _connections[new_connection_id] = ConnectionInfo::Ref(new ConnectionInfo(conn)); } catch (sql::SQLException &exc) { _last_error = exc.what(); _last_error_code = exc.getErrorCode(); - Lock lock(_mutex); + Lock lock(&_mutex); if (_connections.find(new_connection_id) != _connections.end()) _connections.erase(new_connection_id); return -1; @@ -326,7 +326,7 @@ int DbMySQLQueryImpl::openConnectionP(const db_mgmt_ConnectionRef &info, const g catch (std::exception &exc) { _last_error = exc.what(); - Lock lock(_mutex); + Lock lock(&_mutex); if (_connections.find(new_connection_id) != _connections.end()) _connections.erase(new_connection_id); return -1; @@ -340,7 +340,7 @@ int DbMySQLQueryImpl::closeConnection(int conn) { CLEAR_ERROR(); - Lock lock(_mutex); + Lock lock(&_mutex); if (_connections.find(conn) == _connections.end()) throw std::invalid_argument("Invalid connection"); _connections.erase(conn); @@ -368,7 +368,7 @@ int DbMySQLQueryImpl::execute(int conn, const std::string &query) ConnectionInfo::Ref cinfo; sql::Connection *con= 0; { - Lock lock(_mutex); + Lock lock(&_mutex); if (_connections.find(conn) == _connections.end()) throw std::invalid_argument("Invalid connection"); cinfo = _connections[conn]; @@ -408,7 +408,7 @@ int DbMySQLQueryImpl::executeQuery(int conn, const std::string &query) ConnectionInfo::Ref cinfo; sql::Connection *con= 0; { - Lock lock(_mutex); + Lock lock(&_mutex); if (_connections.find(conn) == _connections.end()) throw std::invalid_argument("Invalid connection"); cinfo = _connections[conn]; @@ -446,7 +446,7 @@ int DbMySQLQueryImpl::executeQuery(int conn, const std::string &query) long DbMySQLQueryImpl::lastUpdateCount(int conn) { - Lock lock(_mutex); + Lock lock(&_mutex); if (_connections.find(conn) == _connections.end()) throw std::invalid_argument("Invalid connection"); return (long)_connections[conn]->last_update_count; @@ -455,7 +455,7 @@ long DbMySQLQueryImpl::lastUpdateCount(int conn) int DbMySQLQueryImpl::lastConnectionErrorCode(int conn) { - Lock lock(_mutex); + Lock lock(&_mutex); if (_connections.find(conn) == _connections.end()) throw std::invalid_argument("Invalid connection"); return _connections[conn]->last_error_code; @@ -464,7 +464,7 @@ int DbMySQLQueryImpl::lastConnectionErrorCode(int conn) std::string DbMySQLQueryImpl::lastConnectionError(int conn) { - Lock lock(_mutex); + Lock lock(&_mutex); if (_connections.find(conn) == _connections.end()) throw std::invalid_argument("Invalid connection"); return _connections[conn]->last_error; @@ -473,7 +473,7 @@ std::string DbMySQLQueryImpl::lastConnectionError(int conn) long DbMySQLQueryImpl::resultNumRows(int result) { - Lock lock(_mutex); + Lock lock(&_mutex); if (_resultsets.find(result) == _resultsets.end()) throw std::invalid_argument("Invalid resultset"); sql::ResultSet *res = _resultsets[result]; @@ -484,7 +484,7 @@ long DbMySQLQueryImpl::resultNumRows(int result) int DbMySQLQueryImpl::resultNumFields(int result) { - Lock lock(_mutex); + Lock lock(&_mutex); if (_resultsets.find(result) == _resultsets.end()) throw std::invalid_argument("Invalid resultset"); sql::ResultSet *res = _resultsets[result]; @@ -495,7 +495,7 @@ int DbMySQLQueryImpl::resultNumFields(int result) std::string DbMySQLQueryImpl::resultFieldType(int result, int field) { - Lock lock(_mutex); + Lock lock(&_mutex); if (_resultsets.find(result) == _resultsets.end()) throw std::invalid_argument("Invalid resultset"); sql::ResultSet *res = _resultsets[result]; @@ -506,7 +506,7 @@ std::string DbMySQLQueryImpl::resultFieldType(int result, int field) std::string DbMySQLQueryImpl::resultFieldName(int result, int field) { - Lock lock(_mutex); + Lock lock(&_mutex); if (_resultsets.find(result) == _resultsets.end()) throw std::invalid_argument("Invalid resultset"); sql::ResultSet *res = _resultsets[result]; @@ -517,7 +517,7 @@ std::string DbMySQLQueryImpl::resultFieldName(int result, int field) int DbMySQLQueryImpl::resultFirstRow(int result) { - Lock lock(_mutex); + Lock lock(&_mutex); if (_resultsets.find(result) == _resultsets.end()) throw std::invalid_argument("Invalid resultset"); sql::ResultSet *res = _resultsets[result]; @@ -527,7 +527,7 @@ int DbMySQLQueryImpl::resultFirstRow(int result) int DbMySQLQueryImpl::resultNextRow(int result) { - Lock lock(_mutex); + Lock lock(&_mutex); if (_resultsets.find(result) == _resultsets.end()) throw std::invalid_argument("Invalid resultset"); sql::ResultSet *res = _resultsets[result]; @@ -537,7 +537,7 @@ int DbMySQLQueryImpl::resultNextRow(int result) grt::IntegerRef DbMySQLQueryImpl::resultFieldIntValue(int result, int field) { - Lock lock(_mutex); + Lock lock(&_mutex); if (_resultsets.find(result) == _resultsets.end()) throw std::invalid_argument("Invalid resultset"); sql::ResultSet *res = _resultsets[result]; @@ -551,7 +551,7 @@ grt::IntegerRef DbMySQLQueryImpl::resultFieldIntValue(int result, int field) double DbMySQLQueryImpl::resultFieldDoubleValue(int result, int field) { - Lock lock(_mutex); + Lock lock(&_mutex); if (_resultsets.find(result) == _resultsets.end()) throw std::invalid_argument("Invalid resultset"); sql::ResultSet *res = _resultsets[result]; @@ -562,7 +562,7 @@ double DbMySQLQueryImpl::resultFieldDoubleValue(int result, int field) grt::StringRef DbMySQLQueryImpl::resultFieldStringValue(int result, int field) { - Lock lock(_mutex); + Lock lock(&_mutex); if (_resultsets.find(result) == _resultsets.end()) throw std::invalid_argument("Invalid resultset"); sql::ResultSet *res = _resultsets[result]; @@ -576,7 +576,7 @@ grt::StringRef DbMySQLQueryImpl::resultFieldStringValue(int result, int field) grt::IntegerRef DbMySQLQueryImpl::resultFieldIntValueByName(int result, const std::string &field) { - Lock lock(_mutex); + Lock lock(&_mutex); if (_resultsets.find(result) == _resultsets.end()) throw std::invalid_argument("Invalid resultset"); sql::ResultSet *res = _resultsets[result]; @@ -590,7 +590,7 @@ grt::IntegerRef DbMySQLQueryImpl::resultFieldIntValueByName(int result, const s double DbMySQLQueryImpl::resultFieldDoubleValueByName(int result, const std::string &field) { - Lock lock(_mutex); + Lock lock(&_mutex); if (_resultsets.find(result) == _resultsets.end()) throw std::invalid_argument("Invalid resultset"); sql::ResultSet *res = _resultsets[result]; @@ -601,7 +601,7 @@ double DbMySQLQueryImpl::resultFieldDoubleValueByName(int result, const std::str grt::StringRef DbMySQLQueryImpl::resultFieldStringValueByName(int result, const std::string &field) { - Lock lock(_mutex); + Lock lock(&_mutex); if (_resultsets.find(result) == _resultsets.end()) throw std::invalid_argument("Invalid resultset"); sql::ResultSet *res = _resultsets[result]; @@ -615,7 +615,7 @@ grt::StringRef DbMySQLQueryImpl::resultFieldStringValueByName(int result, const int DbMySQLQueryImpl::closeResult(int result) { - Lock lock(_mutex); + Lock lock(&_mutex); if (_resultsets.find(result) == _resultsets.end()) return -1; sql::ResultSet *res = _resultsets[result]; @@ -632,7 +632,7 @@ int DbMySQLQueryImpl::loadSchemata(int conn, grt::StringListRef schemata) ConnectionInfo::Ref cinfo; sql::Connection *con = 0; { - Lock lock(_mutex); + Lock lock(&_mutex); if (_connections.find(conn) == _connections.end()) throw std::invalid_argument("Invalid connection"); cinfo = _connections[conn]; @@ -678,7 +678,7 @@ grt::DictRef DbMySQLQueryImpl::getServerVariables(int conn) ConnectionInfo::Ref cinfo; sql::Connection *con = 0; { - Lock lock(_mutex); + Lock lock(&_mutex); if (_connections.find(conn) == _connections.end()) throw std::invalid_argument("Invalid connection"); cinfo = _connections[conn]; @@ -730,7 +730,7 @@ int DbMySQLQueryImpl::loadSchemaObjects(int conn, grt::StringRef schema, grt::St ConnectionInfo::Ref cinfo; sql::Connection *con = 0; { - Lock lock(_mutex); + Lock lock(&_mutex); if (_connections.find(conn) == _connections.end()) throw std::invalid_argument("Invalid connection"); cinfo = _connections[conn]; diff --git a/plugins/db.search/DbSearchPanel.cpp b/plugins/db.search/DbSearchPanel.cpp index 5955039..a6c9834 100644 --- a/plugins/db.search/DbSearchPanel.cpp +++ b/plugins/db.search/DbSearchPanel.cpp @@ -108,8 +108,8 @@ private: int _matched_rows; std::string _cast_to; int _search_data_type; - GMutex* _search_result_mutex; - GMutex* _pause_mutex; + GMutex _search_result_mutex; + GMutex _pause_mutex; protected: typedef boost::function&, const std::list&, const std::string&, const bool match_PK)> select_func_t; @@ -120,8 +120,8 @@ public: /* DBSearch():_working(false), _stop(false) { - _pause_mutex = g_mutex_new(); - _search_result_mutex = g_mutex_new(); + g_mutex_init(&_pause_mutex); + g_mutex_init(&_search_result_mutex); }; */ DBSearch(sql::ConnectionWrapper connection, const std::string& search_keyword, const grt::StringListRef& filter_list, @@ -133,15 +133,15 @@ public: _searched_tables(0), _matched_rows(0), _cast_to(cast_to), _search_data_type(search_data_type) { - _pause_mutex = g_mutex_new(); - _search_result_mutex = g_mutex_new(); + g_mutex_init(&_pause_mutex); + g_mutex_init(&_search_result_mutex); } ~DBSearch() { stop(); - g_mutex_free(_pause_mutex); - g_mutex_free(_search_result_mutex); + g_mutex_clear(&_pause_mutex); + g_mutex_clear(&_search_result_mutex); }; std::string get_keyword() { return _search_keyword;} @@ -152,22 +152,22 @@ public: { _paused = !_paused; if(_paused) - g_mutex_lock(_pause_mutex); + g_mutex_lock(&_pause_mutex); else - g_mutex_unlock(_pause_mutex); + g_mutex_unlock(&_pause_mutex); } void wait_if_paused() { if (is_paused()) { - base::GMutexLock lock(_pause_mutex);//Wait for unlock + base::GMutexLock lock(&_pause_mutex);//Wait for unlock }; }; bool is_paused() const {return _paused;} float get_progress() const {return _progress;} std::string get_state() const {return _state;} const std::vector& search_results() const {return _search_result;} - GMutex* get_search_result_mutex() {return _search_result_mutex;}; + GMutex* get_search_result_mutex() {return &_search_result_mutex;}; int searched_table_count() { return _searched_tables; } int matched_rows() { return _matched_rows; } bool is_working() const {return _working;} @@ -295,7 +295,7 @@ void DBSearch::count_data(const std::string& schema_name, const std::string& tab _matched_rows += rs->getInt(1); result.data.push_back(data); } - base::GMutexLock lock(_search_result_mutex); + base::GMutexLock lock(&_search_result_mutex); _search_result.push_back(result); }; @@ -326,7 +326,7 @@ void DBSearch::select_data(const std::string& schema_name, const std::string& ta _matched_rows += result.data.size(); if (!result.data.empty()) { - base::GMutexLock lock(_search_result_mutex); + base::GMutexLock lock(&_search_result_mutex); _search_result.push_back(result); } }; diff --git a/plugins/migration/copytable/copytable.cpp b/plugins/migration/copytable/copytable.cpp index 886b7a8..0fd38ae 100644 --- a/plugins/migration/copytable/copytable.cpp +++ b/plugins/migration/copytable/copytable.cpp @@ -2361,28 +2361,28 @@ void MySQLCopyDataTarget::restore_triggers(std::set &schemas) TaskQueue::TaskQueue() { - _task_mutex = g_mutex_new(); + g_mutex_init(&_task_mutex); } TaskQueue::~TaskQueue() { - g_mutex_free(_task_mutex); + g_mutex_clear(&_task_mutex); } void TaskQueue::add_task(const TableParam& task) { - g_mutex_lock(_task_mutex); + g_mutex_lock(&_task_mutex); _tasks.push_back(task); - g_mutex_unlock(_task_mutex); + g_mutex_unlock(&_task_mutex); } bool TaskQueue::get_task(TableParam& task) { bool ret_val = false; - g_mutex_lock(_task_mutex); + g_mutex_lock(&_task_mutex); if (_tasks.size() > 0 ) { @@ -2391,7 +2391,7 @@ bool TaskQueue::get_task(TableParam& task) _tasks.erase(_tasks.begin()); } - g_mutex_unlock(_task_mutex); + g_mutex_unlock(&_task_mutex); return ret_val; } diff --git a/plugins/migration/copytable/copytable.h b/plugins/migration/copytable/copytable.h index 3613633..e6e4037 100644 --- a/plugins/migration/copytable/copytable.h +++ b/plugins/migration/copytable/copytable.h @@ -341,7 +341,7 @@ class TaskQueue { private: std::vector _tasks; - GMutex *_task_mutex; + GMutex _task_mutex; public: TaskQueue(); ~TaskQueue(); -- 1.8.4.3 0008-Replace-GStaticMutex-with-GMutex.patch0000644000175000017500000005412112242030400016344 0ustar hhhhFrom 69eea4d46dc3dd8ecf3bc81242a58f96984aa85a Mon Sep 17 00:00:00 2001 From: "H.Habighorst" Date: Sun, 17 Nov 2013 00:11:01 +0100 Subject: [PATCH 08/15] Replace GStaticMutex with GMutex. And delete the corresponding RAII class in base. --- backend/wbprivate/workbench/wb_context.cpp | 8 ++++---- backend/wbprivate/workbench/wmi.cpp | 12 ++++++------ backend/wbpublic/grt/grt_manager.cpp | 8 ++++---- backend/wbpublic/grt/grt_shell.cpp | 18 +++++++++--------- backend/wbpublic/grt/grt_shell.h | 2 +- frontend/linux/linux_utilities/image_cache.cpp | 2 +- frontend/linux/linux_utilities/image_cache.h | 6 +++--- library/base/base/threading.h | 8 -------- library/base/drawing.cpp | 8 ++++---- library/base/threading.cpp | 13 ------------- library/forms/mforms/widgets.h | 2 +- library/forms/utilities.cpp | 2 +- library/forms/widgets.cpp | 22 +++++++++++----------- library/forms/winforms/src/wf_utilities.cpp | 14 +++++++------- library/grt/src/grtpp_value.cpp | 10 +++++----- .../db.mysql.sqlparser/src/mysql_sql_parser_fe.cpp | 9 ++++----- 16 files changed, 61 insertions(+), 83 deletions(-) diff --git a/backend/wbprivate/workbench/wb_context.cpp b/backend/wbprivate/workbench/wb_context.cpp index 98bd76a..ec23e80 100644 --- a/backend/wbprivate/workbench/wb_context.cpp +++ b/backend/wbprivate/workbench/wb_context.cpp @@ -158,9 +158,9 @@ static void log_func(const gchar *log_domain, static grt::ValueRef get_app_option(const std::string &option, WBContext *wb) { - static GStaticMutex mutex = G_STATIC_MUTEX_INIT; + static GMutex mutex; - GStaticMutexLock lock(mutex); + GMutexLock lock(&mutex); if (option.empty()) return wb->get_wb_options(); @@ -179,9 +179,9 @@ static grt::ValueRef get_app_option(const std::string &option, WBContext *wb) static void set_app_option(const std::string &option, grt::ValueRef value, WBContext *wb) { - static GStaticMutex mutex = G_STATIC_MUTEX_INIT; + static GMutex mutex; - GStaticMutexLock lock(mutex); + GMutexLock lock(&mutex); if (wb->get_document().is_valid() && wb->get_document()->physicalModels().is_valid() && wb->get_document()->physicalModels().count() > 0) { diff --git a/backend/wbprivate/workbench/wmi.cpp b/backend/wbprivate/workbench/wmi.cpp index 288b381..4eba720 100644 --- a/backend/wbprivate/workbench/wmi.cpp +++ b/backend/wbprivate/workbench/wmi.cpp @@ -332,7 +332,7 @@ std::string WmiMonitor::readValue() //----------------- WmiServices -------------------------------------------------------------------- -static GStaticMutex _locator_mutex = G_STATIC_MUTEX_INIT; +static GMutex _locator_mutex; static IWbemLocator* _locator = NULL; static int _locator_refcount = 0; @@ -419,7 +419,7 @@ void WmiServices::allocate_locator() { log_debug("Allocating wbem locator\n"); - base::GStaticMutexLock lock(_locator_mutex); + base::GMutexLock lock(&_locator_mutex); if (_locator_refcount == 0) { HRESULT hr = CoCreateInstance(CLSID_WbemLocator, NULL, CLSCTX_INPROC_SERVER, IID_IWbemLocator, @@ -442,7 +442,7 @@ void WmiServices::deallocate_locator() { log_debug("Deallocating wbem locator\n"); - base::GStaticMutexLock lock(_locator_mutex); + base::GMutexLock lock(&_locator_mutex); if (_locator_refcount > 0) { _locator_refcount--; @@ -474,7 +474,7 @@ grt::DictListRef WmiServices::query(grt::GRT* grt, const std::string& query) // Making this function explicitly thread-safe might be unnecessary as we don't have // any data which is allocated/deallocated concurrently. But since we know we will be called // from different threads we play safe here, as it does not harm either. - base::GStaticMutexLock lock(_locator_mutex); + base::GMutexLock lock(&_locator_mutex); grt::DictListRef queryResult(grt); @@ -570,7 +570,7 @@ std::string WmiServices::serviceControl(const std::string& service, const std::s { log_debug3("Running wmi service control query for service: %s (action: %s)\n", service.c_str(), action.c_str()); - base::GStaticMutexLock lock(_locator_mutex); + base::GMutexLock lock(&_locator_mutex); CComBSTR instancePath = string2Bstr("Win32_Service.Name='" + service + "'"); @@ -770,7 +770,7 @@ std::string WmiServices::systemStat(const std::string& what) { log_debug3("Running wmi system stat call (what: %s)\n", what.c_str()); - base::GStaticMutexLock lock(_locator_mutex); + base::GMutexLock lock(&_locator_mutex); CComBSTR instancePath = string2Bstr("Win32_OperatingSystem"); diff --git a/backend/wbpublic/grt/grt_manager.cpp b/backend/wbpublic/grt/grt_manager.cpp index 64caa4e..0bf49bd 100644 --- a/backend/wbpublic/grt/grt_manager.cpp +++ b/backend/wbpublic/grt/grt_manager.cpp @@ -46,7 +46,7 @@ static GThread *main_thread= 0; std::map GRTManager::_instances; -GStaticMutex _instance_mutex = G_STATIC_MUTEX_INIT; +static GMutex _instance_mutex; GRTManager *create_grt_manager(bool threaded, bool verbose = false) @@ -82,7 +82,7 @@ GRTManager::GRTManager(bool threaded, bool verbose) // add self to the mgr instances table asap, because the other objects // may need to call get_instance_for() { - GStaticMutexLock _lock(_instance_mutex); + GMutexLock _lock(&_instance_mutex); _instances[_grt]= this; } @@ -125,7 +125,7 @@ bool GRTManager::is_globals_tree_locked() GRTManager *GRTManager::get_instance_for(GRT *grt) { - GStaticMutexLock _lock(_instance_mutex); + GMutexLock _lock(&_instance_mutex); std::map::iterator iter= _instances.find(grt); if (iter != _instances.end()) return iter->second; @@ -201,7 +201,7 @@ bool GRTManager::in_main_thread() GRTManager::~GRTManager() { { - GStaticMutexLock _lock(_instance_mutex); + GMutexLock _lock(&_instance_mutex); _instances.erase(_grt); } diff --git a/backend/wbpublic/grt/grt_shell.cpp b/backend/wbpublic/grt/grt_shell.cpp index 3502044..26460e9 100644 --- a/backend/wbpublic/grt/grt_shell.cpp +++ b/backend/wbpublic/grt/grt_shell.cpp @@ -47,7 +47,7 @@ ShellBE::ShellBE(GRTManager *grtm, GRTDispatcher *dispatcher) _save_history_size= 0; _skip_history = 0; - g_static_mutex_init(&_text_queue_mutex); + g_mutex_init(&_text_queue_mutex); _history_ptr= _history.begin(); } @@ -332,9 +332,9 @@ void ShellBE::writef(const char *fmt, ...) // Flush this queue when we have an output slot and are running in the main thread currently. if (_grtm->is_threaded()) { - g_static_mutex_lock(&_text_queue_mutex); + g_mutex_lock(&_text_queue_mutex); _text_queue.push_back(line); - g_static_mutex_unlock(&_text_queue_mutex); + g_mutex_unlock(&_text_queue_mutex); // if we're in the main thread, flush the message queue if (_grtm->in_main_thread() && _output_slot) @@ -348,9 +348,9 @@ void ShellBE::writef(const char *fmt, ...) _output_slot(line); else { - g_static_mutex_lock(&_text_queue_mutex); + g_mutex_lock(&_text_queue_mutex); _text_queue.push_back(line); - g_static_mutex_unlock(&_text_queue_mutex); + g_mutex_unlock(&_text_queue_mutex); } } } @@ -375,19 +375,19 @@ void ShellBE::flush_shell_output() std::string line; - g_static_mutex_lock(&_text_queue_mutex); + g_mutex_lock(&_text_queue_mutex); while (!_text_queue.empty()) { line= _text_queue.front(); _text_queue.pop_front(); - g_static_mutex_unlock(&_text_queue_mutex); + g_mutex_unlock(&_text_queue_mutex); _output_slot(line); - g_static_mutex_lock(&_text_queue_mutex); + g_mutex_lock(&_text_queue_mutex); } - g_static_mutex_unlock(&_text_queue_mutex); + g_mutex_unlock(&_text_queue_mutex); } diff --git a/backend/wbpublic/grt/grt_shell.h b/backend/wbpublic/grt/grt_shell.h index a0847a1..e186653 100644 --- a/backend/wbpublic/grt/grt_shell.h +++ b/backend/wbpublic/grt/grt_shell.h @@ -99,7 +99,7 @@ protected: boost::function _output_slot; - GStaticMutex _text_queue_mutex; + GMutex _text_queue_mutex; std::list _text_queue; int _save_history_size; diff --git a/frontend/linux/linux_utilities/image_cache.cpp b/frontend/linux/linux_utilities/image_cache.cpp index 6ec8b8b..dfb69b2 100644 --- a/frontend/linux/linux_utilities/image_cache.cpp +++ b/frontend/linux/linux_utilities/image_cache.cpp @@ -22,7 +22,7 @@ Glib::RefPtr ImageCache::image_from_path(const std::string &path, b if (!path.empty()) { - base::GStaticMutexLock lock(_sync); + base::GMutexLock lock(&_sync); ImageMap::iterator it = _images.find(path); if ( _images.end() != it ) im = it->second; diff --git a/frontend/linux/linux_utilities/image_cache.h b/frontend/linux/linux_utilities/image_cache.h index 5cabfe3..e2f6046 100644 --- a/frontend/linux/linux_utilities/image_cache.h +++ b/frontend/linux/linux_utilities/image_cache.h @@ -13,12 +13,12 @@ class ImageCache public: ImageCache() { - g_static_mutex_init(&_sync); + g_mutex_init(&_sync); } ~ImageCache() { - g_static_mutex_free(&_sync); + g_mutex_clear(&_sync); } Glib::RefPtr image_from_path(const std::string& name, bool cache= true); @@ -32,7 +32,7 @@ class ImageCache typedef std::map > ImageMap; ImageMap _images; - GStaticMutex _sync; + GMutex _sync; }; //------------------------------------------------------------------------------ diff --git a/library/base/base/threading.h b/library/base/base/threading.h index 0101ca5..291225d 100644 --- a/library/base/base/threading.h +++ b/library/base/base/threading.h @@ -84,14 +84,6 @@ public: } }; -//! \brief RAII style GStaticMutex locker/unlocker -class BASELIBRARY_PUBLIC_FUNC GStaticMutexLock // Note: must compile with strict-aliasing disabled (-fno-strict-aliasing in gcc) -{ - GStaticMutex &mutex; -public: - GStaticMutexLock(GStaticMutex& mtx); - ~GStaticMutexLock(); -}; class BASELIBRARY_PUBLIC_FUNC GStaticRecMutexLock // Note: must compile with strict-aliasing disabled (-fno-strict-aliasing in gcc) { diff --git a/library/base/drawing.cpp b/library/base/drawing.cpp index 42a0ea1..8868008 100644 --- a/library/base/drawing.cpp +++ b/library/base/drawing.cpp @@ -372,7 +372,7 @@ HSVColor::HSVColor(const Color &rgb) //-------------------------------------------------------------------------------------------------- -static GStaticMutex color_mutex = G_STATIC_MUTEX_INIT; +static GMutex color_mutex; static ColorScheme active_scheme = ColorSchemeStandard; // Only set when loading the application or by a preferences change. static std::pair custom_colors[] = @@ -441,7 +441,7 @@ std::string Color::get_application_color_as_string(ApplicationColor color, bool std::make_pair("#679bd3", "#404040"), }; - GStaticMutexLock lock(color_mutex); + GMutexLock lock(&color_mutex); switch (active_scheme) { @@ -485,7 +485,7 @@ Color Color::get_application_color(ApplicationColor color, bool foreground) void Color::set_active_scheme(ColorScheme scheme) { - GStaticMutexLock lock(color_mutex); + GMutexLock lock(&color_mutex); active_scheme = scheme; @@ -512,7 +512,7 @@ void Color::set_active_scheme(ColorScheme scheme) base::ColorScheme base::Color::get_active_scheme() { - GStaticMutexLock lock(color_mutex); + GMutexLock lock(&color_mutex); return active_scheme; } diff --git a/library/base/threading.cpp b/library/base/threading.cpp index 661cb16..05abb7b 100644 --- a/library/base/threading.cpp +++ b/library/base/threading.cpp @@ -22,19 +22,6 @@ using namespace base; - -GStaticMutexLock::GStaticMutexLock(GStaticMutex& mtx) -: mutex(mtx) -{ - g_static_mutex_lock(&mutex); -} - -GStaticMutexLock::~GStaticMutexLock() -{ - g_static_mutex_unlock(&mutex); -} - - GStaticRecMutexLock::GStaticRecMutexLock(GStaticRecMutex& mtx) : mutex(mtx) { diff --git a/library/forms/mforms/widgets.h b/library/forms/mforms/widgets.h index 0c66c08..855ea1c 100644 --- a/library/forms/mforms/widgets.h +++ b/library/forms/mforms/widgets.h @@ -82,7 +82,7 @@ namespace mforms { bool compute_scale(double min, double max); virtual void get_minmax_values(double* min, double* max); private: - GStaticMutex _lock; + GMutex _lock; double _lower_limit; double _upper_limit; ThresholdList _lower_thresholds; diff --git a/library/forms/utilities.cpp b/library/forms/utilities.cpp index 2e573af..924a5f0 100644 --- a/library/forms/utilities.cpp +++ b/library/forms/utilities.cpp @@ -187,7 +187,7 @@ static void real_mutex_unlock(boost::shared_ptr m) static void mutex_free(GMutex *m) { - g_mutex_free(m); + g_mutex_clear(m); } static GMutex * mutex_new() diff --git a/library/forms/widgets.cpp b/library/forms/widgets.cpp index 2f064df..37c7479 100644 --- a/library/forms/widgets.cpp +++ b/library/forms/widgets.cpp @@ -28,7 +28,7 @@ using namespace base; // Animation timer. One timer for all widget animations. static int animation_timer_refcount= 0; -static GStaticMutex animation_timer_mutex = G_STATIC_MUTEX_INIT; +static GMutex animation_timer_mutex; static int animation_timer_id; static vector animated_widgets; @@ -71,12 +71,12 @@ static vector animated_widgets; */ static bool on_timer(int task_id, void* owner) { - g_static_mutex_lock(&animation_timer_mutex); + g_mutex_lock(&animation_timer_mutex); for (vector::const_iterator iterator= animated_widgets.begin(); iterator != animated_widgets.end(); iterator++) (*iterator)->step(); - g_static_mutex_unlock(&animation_timer_mutex); + g_mutex_unlock(&animation_timer_mutex); return false; } @@ -89,14 +89,14 @@ static bool on_timer(int task_id, void* owner) */ static void start_animation_timer_for(BaseWidget* widget) { - g_static_mutex_lock(&animation_timer_mutex); + g_mutex_lock(&animation_timer_mutex); animated_widgets.push_back(widget); if (animation_timer_refcount == 0) animation_timer_id= ThreadedTimer::add_task(TimerFrequency, 30, false, on_timer, NULL); animation_timer_refcount++; - g_static_mutex_unlock(&animation_timer_mutex); + g_mutex_unlock(&animation_timer_mutex); } //-------------------------------------------------------------------------------------------------- @@ -106,7 +106,7 @@ static void start_animation_timer_for(BaseWidget* widget) */ static void stop_animation_timer_for(BaseWidget* widget) { - g_static_mutex_lock(&animation_timer_mutex); + g_mutex_lock(&animation_timer_mutex); for (vector::iterator iterator= animated_widgets.begin(); iterator != animated_widgets.end(); iterator++) if (*iterator == widget) @@ -121,14 +121,14 @@ static void stop_animation_timer_for(BaseWidget* widget) if (animation_timer_refcount <= 0) ThreadedTimer::remove_task(animation_timer_id); - g_static_mutex_unlock(&animation_timer_mutex); + g_mutex_unlock(&animation_timer_mutex); } //-------------------------------------------------------------------------------------------------- BaseWidget::BaseWidget() { - g_static_mutex_init(&_lock); + g_mutex_init(&_lock); _background = NULL; _lower_limit= 0; @@ -152,21 +152,21 @@ BaseWidget::BaseWidget() BaseWidget::~BaseWidget() { destroy_background(); - g_static_mutex_free(&_lock); + g_mutex_clear(&_lock); } //-------------------------------------------------------------------------------------------------- void BaseWidget::lock() { - g_static_mutex_lock(&_lock); + g_mutex_lock(&_lock); } //-------------------------------------------------------------------------------------------------- void BaseWidget::unlock() { - g_static_mutex_unlock(&_lock); + g_mutex_unlock(&_lock); } //-------------------------------------------------------------------------------------------------- diff --git a/library/forms/winforms/src/wf_utilities.cpp b/library/forms/winforms/src/wf_utilities.cpp index d6934f5..594538f 100644 --- a/library/forms/winforms/src/wf_utilities.cpp +++ b/library/forms/winforms/src/wf_utilities.cpp @@ -988,7 +988,7 @@ void MySQL::Forms::UtilitiesImpl::reveal_file(const std::string &path) //-------------------------------------------------------------------------------------------------- // The password cache is a temporary storage and only used for a short time frame when looking up a password. -static GStaticMutex password_mutex = G_STATIC_MUTEX_INIT; +static GMutex password_mutex; static std::map password_cache; typedef std::map::iterator PasswordIterator; @@ -1130,7 +1130,7 @@ void UtilitiesImpl::unload_passwords(bool store) */ void UtilitiesImpl::store_password(const std::string &service, const std::string &account, const std::string &password) { - g_static_mutex_lock(&password_mutex); + g_mutex_lock(&password_mutex); try { @@ -1143,7 +1143,7 @@ void UtilitiesImpl::store_password(const std::string &service, const std::string } finally { - g_static_mutex_unlock(&password_mutex); + g_mutex_unlock(&password_mutex); } } @@ -1156,7 +1156,7 @@ bool UtilitiesImpl::find_password(const std::string &service, const std::string { log_debug("Looking up password for service: %s, account: %s\n", service.c_str(), account.c_str()); - g_static_mutex_lock(&password_mutex); + g_mutex_lock(&password_mutex); try { @@ -1174,7 +1174,7 @@ bool UtilitiesImpl::find_password(const std::string &service, const std::string } finally { - g_static_mutex_unlock(&password_mutex); + g_mutex_unlock(&password_mutex); } } @@ -1185,7 +1185,7 @@ bool UtilitiesImpl::find_password(const std::string &service, const std::string */ void UtilitiesImpl::forget_password(const std::string &service, const std::string &account) { - g_static_mutex_lock(&password_mutex); + g_mutex_lock(&password_mutex); try { @@ -1202,7 +1202,7 @@ void UtilitiesImpl::forget_password(const std::string &service, const std::strin } finally { - g_static_mutex_unlock(&password_mutex); + g_mutex_unlock(&password_mutex); } } diff --git a/library/grt/src/grtpp_value.cpp b/library/grt/src/grtpp_value.cpp index eeaf69c..8d96344 100644 --- a/library/grt/src/grtpp_value.cpp +++ b/library/grt/src/grtpp_value.cpp @@ -1693,7 +1693,7 @@ struct SmallStringBlock static const int smallstrings_buffer_size = 10240; SmallStringBlock smallstrings[smallstrings_buffer_size]; mutable std::vector small_strings_stack; -static GStaticMutex _allocation_mutex; +static GMutex _allocation_mutex; public: ShortStringTypeHandler() @@ -1705,12 +1705,12 @@ public: ~ShortStringTypeHandler() { - g_static_mutex_free(&_allocation_mutex); + g_mutex_clean(&_allocation_mutex); } StringRef::storage_type allocate(const char* srcstring, const size_t len) { - base::GStaticMutexLock lock(_allocation_mutex); + base::GMutexLock lock(&_allocation_mutex); if((len >= small_string_size) || small_strings_stack.empty()) return NULL; @@ -1731,7 +1731,7 @@ public: ptr->refcounter--; if(ptr->refcounter <= 0) { - base::GStaticMutexLock lock(_allocation_mutex); + base::GMutexLock lock(&_allocation_mutex); small_strings_stack.push_back(reinterpret_cast(ptr)); } }; @@ -1748,7 +1748,7 @@ public: }; -GStaticMutex ShortStringTypeHandler::_allocation_mutex = G_STATIC_MUTEX_INIT; +static GMutex ShortStringTypeHandler::_allocation_mutex; ShortStringTypeHandler short_string_handler; diff --git a/modules/db.mysql.sqlparser/src/mysql_sql_parser_fe.cpp b/modules/db.mysql.sqlparser/src/mysql_sql_parser_fe.cpp index 734f491..1c52f89 100644 --- a/modules/db.mysql.sqlparser/src/mysql_sql_parser_fe.cpp +++ b/modules/db.mysql.sqlparser/src/mysql_sql_parser_fe.cpp @@ -334,8 +334,7 @@ max_err_count(-1) } -GStaticMutex _parser_fe_critical_section= G_STATIC_MUTEX_INIT; - +static GMutex _parser_fe_critical_section; void Mysql_sql_parser_fe::reset() { @@ -365,7 +364,7 @@ void Mysql_sql_parser_fe::parse_sql_mode(const std::string &sql_mode_string) int Mysql_sql_parser_fe::parse_sql_script(const char* sql, fe_process_sql_statement_callback cb, void *user_data) { - base::GStaticMutexLock parser_fe_critical_section(_parser_fe_critical_section); + base::GMutexLock parser_fe_critical_section(&_parser_fe_critical_section); reset(); Context context= {this, cb, user_data, 0, ignore_dml, is_ast_generation_enabled, max_insert_statement_size, processing_create_statements, processing_alter_statements, processing_drop_statements, sql_mode}; myx_process_sql_statements(sql, Lex_helper::charset(), &process_sql_statement_cb, &context, MYX_SPM_NORMAL_MODE); @@ -375,7 +374,7 @@ int Mysql_sql_parser_fe::parse_sql_script(const char* sql, fe_process_sql_statem int Mysql_sql_parser_fe::parse_sql_script_file(const std::string &filename, fe_process_sql_statement_callback cb, void *user_data) { - base::GStaticMutexLock parser_fe_critical_section(_parser_fe_critical_section); + base::GMutexLock parser_fe_critical_section(&_parser_fe_critical_section); reset(); Context context= {this, cb, user_data, 0, ignore_dml, is_ast_generation_enabled, max_insert_statement_size, processing_create_statements, processing_alter_statements, processing_drop_statements, sql_mode}; myx_process_sql_statements_from_file(filename.c_str(), Lex_helper::charset(), &process_sql_statement_cb, &context, MYX_SPM_NORMAL_MODE/*MYX_SPM_DELIMS_REQUIRED*/); @@ -632,7 +631,7 @@ void Mysql_sql_parser_fe::determine_token_position(const SqlAstNode *item, const std::string Mysql_sql_parser_fe::get_first_sql_token(const std::string &sql, const std::string &versioning_comment_subst_token) { - base::GStaticMutexLock parser_fe_critical_section(_parser_fe_critical_section); + base::GMutexLock parser_fe_critical_section(&_parser_fe_critical_section); reset(); static Mysql_sql_parser_fe::SqlMode sql_mode; -- 1.8.4.3 0009-replace-GStaticRecMutex-with-GRecMutex.patch0000644000175000017500000006317012242030400017475 0ustar hhhhFrom d2116f64d90731fc8d34befbc23b4d2a9fed0a8e Mon Sep 17 00:00:00 2001 From: "H.Habighorst" Date: Sun, 17 Nov 2013 01:00:23 +0100 Subject: [PATCH 09/15] replace GStaticRecMutex with GRecMutex --- .../wbprivate/sqlide/db_sql_editor_history_be.cpp | 8 ++--- backend/wbprivate/sqlide/db_sql_editor_log.cpp | 6 ++-- backend/wbprivate/workbench/wb_model_file.cpp | 10 +++--- backend/wbprivate/workbench/wb_model_file.h | 2 +- backend/wbpublic/grt/grt_dispatcher.cpp | 10 +++--- backend/wbpublic/sqlide/recordset_be.cpp | 10 +++--- backend/wbpublic/sqlide/var_grid_model_be.cpp | 24 +++++++------- backend/wbpublic/sqlide/var_grid_model_be.h | 2 +- frontend/linux/workbench/main.cpp | 6 ++-- library/base/base/threading.h | 8 ++--- library/base/threading.cpp | 8 ++--- library/canvas/src/mdc_canvas_view.cpp | 8 ++--- library/canvas/src/mdc_canvas_view.h | 2 +- library/canvas/src/mdc_selection.cpp | 8 ++--- library/canvas/src/mdc_selection.h | 2 +- library/grt/src/grtpp.h | 4 +-- library/grt/src/grtpp_grt.cpp | 38 +++++++++++----------- library/grt/src/grtpp_undo_manager.cpp | 8 ++--- library/grt/src/grtpp_undo_manager.h | 2 +- 19 files changed, 83 insertions(+), 83 deletions(-) diff --git a/backend/wbprivate/sqlide/db_sql_editor_history_be.cpp b/backend/wbprivate/sqlide/db_sql_editor_history_be.cpp index 427afde..0dca6a5 100644 --- a/backend/wbprivate/sqlide/db_sql_editor_history_be.cpp +++ b/backend/wbprivate/sqlide/db_sql_editor_history_be.cpp @@ -235,7 +235,7 @@ bool DbSqlEditorHistory::EntriesModel::insert_entry(const std::tm &t) std::string date= format_time(t, "%Y-%m-%d"); if (date != newest_date) { - GStaticRecMutexLock data_mutex(_data_mutex); + GRecMutexLock data_mutex(_data_mutex); _data.insert(_data.begin(), date); ++_row_count; ++_data_frame_end; @@ -391,7 +391,7 @@ void DbSqlEditorHistory::DetailsModel::load(const std::string &storage_file_path if (history_xml.is_open()) { - GStaticRecMutexLock data_mutex(_data_mutex); + GRecMutexLock data_mutex(_data_mutex); _data.clear(); _data.reserve(_data.size() + _column_count); @@ -502,7 +502,7 @@ void DbSqlEditorHistory::DetailsModel::save() } { - GStaticRecMutexLock data_mutex(_data_mutex); + GRecMutexLock data_mutex(_data_mutex); std::string last_saved_timestamp; std::string last_saved_statement; get_field(NodeId(_last_loaded_row), 0, last_saved_timestamp); @@ -541,7 +541,7 @@ void DbSqlEditorHistory::DetailsModel::add_entries(const std::list return; { - GStaticRecMutexLock data_mutex(_data_mutex); + GRecMutexLock data_mutex(_data_mutex); _data.reserve(_data.size() + _column_count); diff --git a/backend/wbprivate/sqlide/db_sql_editor_log.cpp b/backend/wbprivate/sqlide/db_sql_editor_log.cpp index 451c0a2..9250faa 100644 --- a/backend/wbprivate/sqlide/db_sql_editor_log.cpp +++ b/backend/wbprivate/sqlide/db_sql_editor_log.cpp @@ -171,7 +171,7 @@ void DbSqlEditorLog::reset() VarGridModel::reset(); { - base::GStaticRecMutexLock data_mutex(_data_mutex); + base::GRecMutexLock data_mutex(_data_mutex); _data.clear(); _next_id = 1; } @@ -307,7 +307,7 @@ RowId DbSqlEditorLog::add_message(int msg_type, const std::string &context, cons } { - base::GStaticRecMutexLock data_mutex(_data_mutex); + base::GRecMutexLock data_mutex(_data_mutex); // Remove oldest messages if there are more than the maximum allowed number. if (_max_entry_count > -1 && _max_entry_count - 1 < (int)_row_count) @@ -332,7 +332,7 @@ void DbSqlEditorLog::set_message(RowId row, int msg_type, const std::string &con fprintf(fp, "[%u, %s] %s: %s\n", (unsigned)row, time.c_str(), context.c_str(), msg.c_str()); } - base::GStaticRecMutexLock data_mutex(_data_mutex); + base::GRecMutexLock data_mutex(_data_mutex); // Scan backwards for the given row id to find the right message entry. // Usually this will find the actual entry quickly, since normally add_message and set_message diff --git a/backend/wbprivate/workbench/wb_model_file.cpp b/backend/wbprivate/workbench/wb_model_file.cpp index 075e22c..8bd914f 100644 --- a/backend/wbprivate/workbench/wb_model_file.cpp +++ b/backend/wbprivate/workbench/wb_model_file.cpp @@ -202,9 +202,9 @@ std::string ModelFile::create_document_dir(const std::string &dir, const std::st struct AutoLock { - GStaticRecMutex *mx; - AutoLock(GStaticRecMutex &mutex) : mx(&mutex) { g_static_rec_mutex_lock(mx); } - ~AutoLock() { g_static_rec_mutex_unlock(mx); } + GRecMutex *mx; + AutoLock(GRecMutex &mutex) : mx(&mutex) { g_rec_mutex_lock(mx); } + ~AutoLock() { g_rec_mutex_unlock(mx); } }; @@ -213,14 +213,14 @@ ModelFile::ModelFile(const std::string &tmpdir) { _temp_dir= tmpdir; - g_static_rec_mutex_init(&_mutex); + g_rec_mutex_init(&_mutex); } ModelFile::~ModelFile() { cleanup(); - g_static_rec_mutex_free(&_mutex); + g_rec_mutex_clear(&_mutex); } diff --git a/backend/wbprivate/workbench/wb_model_file.h b/backend/wbprivate/workbench/wb_model_file.h index 08b8824..a85f38d 100644 --- a/backend/wbprivate/workbench/wb_model_file.h +++ b/backend/wbprivate/workbench/wb_model_file.h @@ -103,7 +103,7 @@ namespace wb { private: base::LockFile *_temp_dir_lock; - GStaticRecMutex _mutex; + GRecMutex _mutex; std::string _temp_dir; //< temporary files directory std::string _content_dir; //< path for directory where document contents are stored in disk std::list _delete_queue; //< files marked for deletion diff --git a/backend/wbpublic/grt/grt_dispatcher.cpp b/backend/wbpublic/grt/grt_dispatcher.cpp index 2ce49c8..7401e42 100644 --- a/backend/wbpublic/grt/grt_dispatcher.cpp +++ b/backend/wbpublic/grt/grt_dispatcher.cpp @@ -28,7 +28,7 @@ using namespace bec; static bool debug_dispatcher= false; -static GStaticRecMutex retain_mutex = G_STATIC_REC_MUTEX_INIT; +static GRecMutex retain_mutex; DEFAULT_LOG_DOMAIN("GRTDispatcher"); @@ -119,20 +119,20 @@ void GRTTaskBase::cancel() void GRTTaskBase::retain() { - g_static_rec_mutex_lock(&retain_mutex); + g_rec_mutex_lock(&retain_mutex); _refcount++; - g_static_rec_mutex_unlock(&retain_mutex); + g_rec_mutex_unlock(&retain_mutex); } void GRTTaskBase::release() { bool do_delete = false; - g_static_rec_mutex_lock(&retain_mutex); + g_rec_mutex_lock(&retain_mutex); --_refcount; if (_refcount == 0) do_delete = true; // delete can cause a side-effect with recursion, which would deadlock - g_static_rec_mutex_unlock(&retain_mutex); + g_rec_mutex_unlock(&retain_mutex); if (do_delete) delete this; } diff --git a/backend/wbpublic/sqlide/recordset_be.cpp b/backend/wbpublic/sqlide/recordset_be.cpp index d2b5ffb..c0707b8 100644 --- a/backend/wbpublic/sqlide/recordset_be.cpp +++ b/backend/wbpublic/sqlide/recordset_be.cpp @@ -363,7 +363,7 @@ void Recordset::after_set_field(const NodeId &node, int column, const sqlite::va void Recordset::mark_dirty(RowId row, ColumnId column, const sqlite::variant_t &new_value) { - GStaticRecMutexLock data_mutex(_data_mutex); + GRecMutexLock data_mutex(_data_mutex); RowId rowid; NodeId node(row); @@ -412,7 +412,7 @@ bool Recordset::delete_node(const bec::NodeId &node) bool Recordset::delete_nodes(std::vector &nodes) { { - GStaticRecMutexLock data_mutex(_data_mutex); + GRecMutexLock data_mutex(_data_mutex); { std::sort(nodes.begin(), nodes.end()); @@ -884,7 +884,7 @@ void Recordset::reset_data_search_string() void Recordset::rebuild_data_index(sqlite::connection *data_swap_db, bool do_cache_data_frame, bool do_refresh_ui) { { - GStaticRecMutexLock data_mutex(_data_mutex); + GRecMutexLock data_mutex(_data_mutex); std::string where_clause; { @@ -1590,7 +1590,7 @@ public: }; void Recordset::open_field_data_editor(RowId row, ColumnId column) { - GStaticRecMutexLock data_mutex(_data_mutex); + GRecMutexLock data_mutex(_data_mutex); bool res= true; try @@ -1725,7 +1725,7 @@ public: void Recordset::save_to_file(const bec::NodeId &node, int column, const std::string &file) { - GStaticRecMutexLock data_mutex(_data_mutex); + GRecMutexLock data_mutex(_data_mutex); sqlite::variant_t blob_value; sqlite::variant_t *value; diff --git a/backend/wbpublic/sqlide/var_grid_model_be.cpp b/backend/wbpublic/sqlide/var_grid_model_be.cpp index a9d0fd3..29375dd 100644 --- a/backend/wbpublic/sqlide/var_grid_model_be.cpp +++ b/backend/wbpublic/sqlide/var_grid_model_be.cpp @@ -72,7 +72,7 @@ _is_field_value_truncation_enabled(false), _edited_field_row(-1), _edited_field_col(-1) { - g_static_rec_mutex_init(&_data_mutex); + g_rec_mutex_init(&_data_mutex); { grt::DictRef options= DictRef::cast_from(_grtm->get_grt()->get("/wb/options/options")); @@ -85,7 +85,7 @@ VarGridModel::~VarGridModel() { _refresh_connection.disconnect(); - g_static_rec_mutex_free(&_data_mutex); + g_rec_mutex_clear(&_data_mutex); _data_swap_db.reset(); // clean temporary file to prevent crowding of files @@ -112,7 +112,7 @@ void VarGridModel::reset() } { - GStaticRecMutexLock data_mutex UNUSED (_data_mutex); + GRecMutexLock data_mutex UNUSED (_data_mutex); reinit(_data); } reinit(_column_names); @@ -242,7 +242,7 @@ bool VarGridModel::get_cell(VarGridModel::Cell &cell, const NodeId &node, Column bool VarGridModel::is_field_null(const NodeId &node, int column) { - GStaticRecMutexLock data_mutex UNUSED (_data_mutex); + GRecMutexLock data_mutex UNUSED (_data_mutex); // returns true for out of the range addresses Cell cell; @@ -268,7 +268,7 @@ bool VarGridModel::set_field_null(const bec::NodeId &node, int column) IconId VarGridModel::get_field_icon(const NodeId &node, int column, IconSize size) { - GStaticRecMutexLock data_mutex UNUSED (_data_mutex); + GRecMutexLock data_mutex UNUSED (_data_mutex); Cell cell; static const sqlite::variant_t null_value= sqlite::null_t(); @@ -281,7 +281,7 @@ IconId VarGridModel::get_field_icon(const NodeId &node, int column, IconSize siz bool VarGridModel::get_field(const NodeId &node, int column, std::string &value) { - GStaticRecMutexLock data_mutex UNUSED (_data_mutex); + GRecMutexLock data_mutex UNUSED (_data_mutex); return get_field_(node, column, value); } @@ -298,7 +298,7 @@ bool VarGridModel::get_field_(const NodeId &node, int column, std::string &value bool VarGridModel::get_field_repr(const NodeId &node, int column, std::string &value) { - GStaticRecMutexLock data_mutex UNUSED (_data_mutex); + GRecMutexLock data_mutex UNUSED (_data_mutex); return get_field_repr_(node, column, value); } @@ -330,7 +330,7 @@ bool VarGridModel::get_field_repr_(const NodeId &node, int column, std::string & bool VarGridModel::get_field(const NodeId &node, int column, sqlite::variant_t &value) { - GStaticRecMutexLock data_mutex UNUSED (_data_mutex); + GRecMutexLock data_mutex UNUSED (_data_mutex); return get_field_(node, column, value); } @@ -347,7 +347,7 @@ bool VarGridModel::get_field_(const NodeId &node, int column, sqlite::variant_t bool VarGridModel::get_field(const NodeId &node, int column, int &value) { - GStaticRecMutexLock data_mutex UNUSED (_data_mutex); + GRecMutexLock data_mutex UNUSED (_data_mutex); return get_field_(node, column, value); } @@ -364,7 +364,7 @@ bool VarGridModel::get_field_(const NodeId &node, int column, int &value) bool VarGridModel::get_field(const NodeId &node, int column, long long &value) { - GStaticRecMutexLock data_mutex UNUSED (_data_mutex); + GRecMutexLock data_mutex UNUSED (_data_mutex); return get_field_(node, column, value); } @@ -381,7 +381,7 @@ bool VarGridModel::get_field_(const NodeId &node, int column, long long &value) bool VarGridModel::get_field(const NodeId &node, int column, double &value) { - GStaticRecMutexLock data_mutex UNUSED (_data_mutex); + GRecMutexLock data_mutex UNUSED (_data_mutex); return get_field_(node, column, value); } @@ -411,7 +411,7 @@ bool VarGridModel::set_field(const NodeId &node, int column, const sqlite::varia bool res= false; { - GStaticRecMutexLock data_mutex UNUSED (_data_mutex); + GRecMutexLock data_mutex UNUSED (_data_mutex); Cell cell; res= get_cell(cell, node, column, true); diff --git a/backend/wbpublic/sqlide/var_grid_model_be.h b/backend/wbpublic/sqlide/var_grid_model_be.h index 61a3f4b..5756e11 100644 --- a/backend/wbpublic/sqlide/var_grid_model_be.h +++ b/backend/wbpublic/sqlide/var_grid_model_be.h @@ -140,7 +140,7 @@ protected: Column_quoting _column_quoting; // stored whether column values are quoted or not (ie numbers vs strings. special values like functions need extra handling) //XXX maybe _real_column_types and _column_quoting can be merged somehow --alfredo - GStaticRecMutex _data_mutex; + GRecMutex _data_mutex; protected: boost::shared_ptr data_swap_db() const; diff --git a/frontend/linux/workbench/main.cpp b/frontend/linux/workbench/main.cpp index 79a7bb5..df401a9 100644 --- a/frontend/linux/workbench/main.cpp +++ b/frontend/linux/workbench/main.cpp @@ -18,16 +18,16 @@ using base::strfmt; // We need recursive mutex to lock gtk main loop. For that we supply enter/leave // callbacks to glib via gdk_threads_set_lock_functions(). Out lock/unlock // functions operate on static rec mutex. -static GStaticRecMutex custom_gdk_rec_mutex = G_STATIC_REC_MUTEX_INIT; +static GRecMutex custom_gdk_rec_mutex; static void custom_gdk_threads_enter() { - g_static_rec_mutex_lock(&custom_gdk_rec_mutex); + g_rec_mutex_lock(&custom_gdk_rec_mutex); } static void custom_gdk_threads_leave() { - g_static_rec_mutex_unlock(&custom_gdk_rec_mutex); + g_rec_mutex_unlock(&custom_gdk_rec_mutex); } inline void init_gdk_thread_callbacks() diff --git a/library/base/base/threading.h b/library/base/base/threading.h index 291225d..573ee66 100644 --- a/library/base/base/threading.h +++ b/library/base/base/threading.h @@ -85,12 +85,12 @@ public: }; -class BASELIBRARY_PUBLIC_FUNC GStaticRecMutexLock // Note: must compile with strict-aliasing disabled (-fno-strict-aliasing in gcc) +class BASELIBRARY_PUBLIC_FUNC GRecMutexLock // Note: must compile with strict-aliasing disabled (-fno-strict-aliasing in gcc) { - GStaticRecMutex &mutex; + GRecMutex &mutex; public: - GStaticRecMutexLock(GStaticRecMutex& mtx); - ~GStaticRecMutexLock(); + GRecMutexLock(GRecMutex& mtx); + ~GRecMutexLock(); }; }; diff --git a/library/base/threading.cpp b/library/base/threading.cpp index 05abb7b..6859996 100644 --- a/library/base/threading.cpp +++ b/library/base/threading.cpp @@ -22,13 +22,13 @@ using namespace base; -GStaticRecMutexLock::GStaticRecMutexLock(GStaticRecMutex& mtx) +GRecMutexLock::GRecMutexLock(GRecMutex& mtx) : mutex(mtx) { - g_static_rec_mutex_lock(&mutex); + g_rec_mutex_lock(&mutex); } -GStaticRecMutexLock::~GStaticRecMutexLock() +GRecMutexLock::~GRecMutexLock() { - g_static_rec_mutex_unlock(&mutex); + g_rec_mutex_unlock(&mutex); } \ No newline at end of file diff --git a/library/canvas/src/mdc_canvas_view.cpp b/library/canvas/src/mdc_canvas_view.cpp index ead2932..7ec6b4d 100644 --- a/library/canvas/src/mdc_canvas_view.cpp +++ b/library/canvas/src/mdc_canvas_view.cpp @@ -61,7 +61,7 @@ struct CanvasAutoLock CanvasView::CanvasView(int width, int height) : _fps(0), _total_item_cache_mem(0), _last_click_info(3) { - g_static_rec_mutex_init(&_lock); + g_rec_mutex_init(&_lock); _page_size= Size(2000, 1500); _x_page_num= 1; @@ -134,7 +134,7 @@ CanvasView::~CanvasView() if (_crsurface) cairo_surface_destroy(_crsurface); - g_static_rec_mutex_free(&_lock); + g_rec_mutex_clear(&_lock); } @@ -203,13 +203,13 @@ void CanvasView::unlock_ui() void CanvasView::lock() { - g_static_rec_mutex_lock(&_lock); + g_rec_mutex_lock(&_lock); } void CanvasView::unlock() { - g_static_rec_mutex_unlock(&_lock); + g_rec_mutex_unlock(&_lock); } diff --git a/library/canvas/src/mdc_canvas_view.h b/library/canvas/src/mdc_canvas_view.h index abc1c8e..b5ed873 100644 --- a/library/canvas/src/mdc_canvas_view.h +++ b/library/canvas/src/mdc_canvas_view.h @@ -292,7 +292,7 @@ private: std::vector _last_click_info; base::Point _last_mouse_pos; - GStaticRecMutex _lock; + GRecMutex _lock; static void *canvas_item_destroyed(void *data); void set_last_click_item(CanvasItem *item); diff --git a/library/canvas/src/mdc_selection.cpp b/library/canvas/src/mdc_selection.cpp index e5c5f5a..f1b8168 100644 --- a/library/canvas/src/mdc_selection.cpp +++ b/library/canvas/src/mdc_selection.cpp @@ -37,26 +37,26 @@ Selection::Selection(CanvasView *view) // _view->get_interaction_layer()->signal_custom_repaint().connect(boost::bind(&Selection::render_drag_images, this)); - g_static_rec_mutex_init(&_mutex); + g_rec_mutex_init(&_mutex); } Selection::~Selection() { - g_static_rec_mutex_free(&_mutex); + g_rec_mutex_clear(&_mutex); // clear(); } void Selection::lock() { - g_static_rec_mutex_lock(&_mutex); + g_rec_mutex_lock(&_mutex); } void Selection::unlock() { - g_static_rec_mutex_unlock(&_mutex); + g_rec_mutex_unlock(&_mutex); } diff --git a/library/canvas/src/mdc_selection.h b/library/canvas/src/mdc_selection.h index b3c64df..dd7d4f6 100644 --- a/library/canvas/src/mdc_selection.h +++ b/library/canvas/src/mdc_selection.h @@ -110,7 +110,7 @@ private: boost::signals2::signal _signal_end_drag; std::map _drag_data; - GStaticRecMutex _mutex; + GRecMutex _mutex; CanvasView *_view; void lock(); diff --git a/library/grt/src/grtpp.h b/library/grt/src/grtpp.h index 89edc15..4b264f5 100644 --- a/library/grt/src/grtpp.h +++ b/library/grt/src/grtpp.h @@ -2778,7 +2778,7 @@ namespace grt { std::vector > _progress_step_stack; - GStaticRecMutex _message_mutex; + GRecMutex _message_mutex; std::list _loaders; std::vector _modules; @@ -2791,7 +2791,7 @@ namespace grt { //std::list _loaders; - // GStaticRecMutex _global_mutex; + // GRecMutex _global_mutex; // GStaticRWLock _global_tree_lock; void add_metaclass(MetaClass *stru); diff --git a/library/grt/src/grtpp_grt.cpp b/library/grt/src/grtpp_grt.cpp index 3d2e66f..c865762 100644 --- a/library/grt/src/grtpp_grt.cpp +++ b/library/grt/src/grtpp_grt.cpp @@ -188,7 +188,7 @@ GRT::GRT() add_module_loader(new CPPModuleLoader(this)); - g_static_rec_mutex_init(&_message_mutex); + g_rec_mutex_init(&_message_mutex); // register metaclass for base class add_metaclass(MetaClass::create_base_class(this)); @@ -227,7 +227,7 @@ GRT::~GRT() delete iter->second; _metaclasses.clear(); - g_static_rec_mutex_free(&_message_mutex); + g_rec_mutex_clear(&_message_mutex); } void GRT::push_undo_manager(UndoManager *um) @@ -1006,14 +1006,14 @@ Shell *GRT::get_shell() void GRT::push_message_handler(const MessageSlot &slot) { - GStaticRecMutexLock lock(_message_mutex); + GRecMutexLock lock(_message_mutex); _message_slot_stack.push_back(slot); } void GRT::pop_message_handler() { - GStaticRecMutexLock lock(_message_mutex); + GRecMutexLock lock(_message_mutex); if (_message_slot_stack.empty()) log_error("pop_message_handler() called on empty handler stack"); else @@ -1032,7 +1032,7 @@ bool GRT::handle_message(const Message &msg, void *sender) for (;;) { { - GStaticRecMutexLock lock(_message_mutex); + GRecMutexLock lock(_message_mutex); if ((int)_message_slot_stack.size() - i - 1 >= 0) { slot = _message_slot_stack[_message_slot_stack.size() - i - 1]; @@ -1073,7 +1073,7 @@ bool GRT::query_status() void GRT::make_output_visible(void *sender) { - g_static_rec_mutex_lock(&_message_mutex); + g_rec_mutex_lock(&_message_mutex); Message msg; msg.type= ControlMsg; msg.text= "show"; @@ -1081,13 +1081,13 @@ void GRT::make_output_visible(void *sender) msg.timestamp= time(NULL); msg.progress= 0.0; handle_message(msg, sender); - g_static_rec_mutex_unlock(&_message_mutex); + g_rec_mutex_unlock(&_message_mutex); } // XXX: these handlers should go and be replaced by pure log_* calls. void GRT::send_error(const std::string &message, const std::string &details, void *sender) { - g_static_rec_mutex_lock(&_message_mutex); + g_rec_mutex_lock(&_message_mutex); Message msg; msg.type= ErrorMsg; msg.text= message; @@ -1095,7 +1095,7 @@ void GRT::send_error(const std::string &message, const std::string &details, voi msg.timestamp= time(NULL); msg.progress= 0.0; handle_message(msg, sender); - g_static_rec_mutex_unlock(&_message_mutex); + g_rec_mutex_unlock(&_message_mutex); log_error("%s\t%s\n", message.c_str(), details.c_str()); } @@ -1103,7 +1103,7 @@ void GRT::send_error(const std::string &message, const std::string &details, voi void GRT::send_warning(const std::string &message, const std::string &details, void *sender) { - g_static_rec_mutex_lock(&_message_mutex); + g_rec_mutex_lock(&_message_mutex); Message msg; msg.type= WarningMsg; msg.text= message; @@ -1111,7 +1111,7 @@ void GRT::send_warning(const std::string &message, const std::string &details, v msg.timestamp= time(NULL); msg.progress= 0.0; handle_message(msg, sender); - g_static_rec_mutex_unlock(&_message_mutex); + g_rec_mutex_unlock(&_message_mutex); log_warning("%s\t%s", message.c_str(), details.c_str()); } @@ -1119,7 +1119,7 @@ void GRT::send_warning(const std::string &message, const std::string &details, v void GRT::send_info(const std::string &message, const std::string &details, void *sender) { - g_static_rec_mutex_lock(&_message_mutex); + g_rec_mutex_lock(&_message_mutex); Message msg; msg.type= InfoMsg; msg.text= message; @@ -1127,7 +1127,7 @@ void GRT::send_info(const std::string &message, const std::string &details, void msg.timestamp= time(NULL); msg.progress= 0.0; handle_message(msg, sender); - g_static_rec_mutex_unlock(&_message_mutex); + g_rec_mutex_unlock(&_message_mutex); log_info("%s\t%s\n", message.c_str(), details.c_str()); } @@ -1165,7 +1165,7 @@ void GRT::end_progress_step() void GRT::send_progress(float percentage, const std::string &message, const std::string &details, void *sender) { - g_static_rec_mutex_lock(&_message_mutex); + g_rec_mutex_lock(&_message_mutex); Message msg; msg.type= ProgressMsg; msg.text= message; @@ -1182,7 +1182,7 @@ void GRT::send_progress(float percentage, const std::string &message, const std: } msg.progress= percentage; handle_message(msg, sender); - g_static_rec_mutex_unlock(&_message_mutex); + g_rec_mutex_unlock(&_message_mutex); // Progress messages are often sent without a real message, just to trigger some actions. // Don't log empty lines. @@ -1193,7 +1193,7 @@ void GRT::send_progress(float percentage, const std::string &message, const std: void GRT::send_verbose(const std::string &message, void *sender) { - g_static_rec_mutex_lock(&_message_mutex); + g_rec_mutex_lock(&_message_mutex); Message msg; msg.type= VerboseMsg; msg.text= message; @@ -1201,7 +1201,7 @@ void GRT::send_verbose(const std::string &message, void *sender) msg.timestamp= time(NULL); msg.progress= 0.0; handle_message(msg, sender); - g_static_rec_mutex_unlock(&_message_mutex); + g_rec_mutex_unlock(&_message_mutex); log_debug2("%s", message.c_str()); } @@ -1209,7 +1209,7 @@ void GRT::send_verbose(const std::string &message, void *sender) void GRT::send_output(const std::string &message, void *sender) { - g_static_rec_mutex_lock(&_message_mutex); + g_rec_mutex_lock(&_message_mutex); Message msg; msg.type= OutputMsg; msg.text= message; @@ -1217,7 +1217,7 @@ void GRT::send_output(const std::string &message, void *sender) msg.timestamp= time(NULL); msg.progress= 0.0; handle_message(msg, sender); - g_static_rec_mutex_unlock(&_message_mutex); + g_rec_mutex_unlock(&_message_mutex); // Log send_output only when verbose is on to avoid duplicate prints to stdout, when logged text also goes to stderr/out // TODO: fix the actual cause for sending duplicates and remove _verbose (doesn't fit to our logging). diff --git a/library/grt/src/grtpp_undo_manager.cpp b/library/grt/src/grtpp_undo_manager.cpp index bfc3e8a..3b880cb 100644 --- a/library/grt/src/grtpp_undo_manager.cpp +++ b/library/grt/src/grtpp_undo_manager.cpp @@ -624,7 +624,7 @@ UndoManager::UndoManager(GRT *grt) _is_redoing= false; _undo_limit= 0; _blocks= 0; - g_static_rec_mutex_init(&_mutex); + g_rec_mutex_init(&_mutex); } @@ -632,7 +632,7 @@ UndoManager::~UndoManager() { _changed_signal.disconnect_all_slots(); // prevent emission in reset() reset(); - g_static_rec_mutex_free(&_mutex); + g_rec_mutex_clear(&_mutex); } @@ -656,13 +656,13 @@ void UndoManager::enable_logging_to(std::ostream *stream) void UndoManager::lock() const { - g_static_rec_mutex_lock(&_mutex); + g_rec_mutex_lock(&_mutex); } void UndoManager::unlock() const { - g_static_rec_mutex_unlock(&_mutex); + g_rec_mutex_unlock(&_mutex); } diff --git a/library/grt/src/grtpp_undo_manager.h b/library/grt/src/grtpp_undo_manager.h index e46f590..f39706e 100644 --- a/library/grt/src/grtpp_undo_manager.h +++ b/library/grt/src/grtpp_undo_manager.h @@ -275,7 +275,7 @@ public: void unlock() const; protected: GRT *_owner; - mutable GStaticRecMutex _mutex; + mutable GRecMutex _mutex; std::ostream *_undo_log; std::deque _undo_stack; -- 1.8.4.3 0010-Replace-g_strcasecmp-with-g_ascii_strcasecmp.patch0000644000175000017500000001527112242030400021042 0ustar hhhhFrom a83ee2963ab28ff48be05fedff003a35ae93f756 Mon Sep 17 00:00:00 2001 From: "H.Habighorst" Date: Sun, 17 Nov 2013 01:10:58 +0100 Subject: [PATCH 10/15] Replace g_strcasecmp with g_ascii_strcasecmp. --- backend/wbprivate/sqlide/wb_live_schema_tree.cpp | 4 +-- backend/wbpublic/grtdb/db_object_helpers.cpp | 42 +++++++++++----------- .../db.mysql.sqlparser/src/mysql_sql_parser.cpp | 4 +-- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/backend/wbprivate/sqlide/wb_live_schema_tree.cpp b/backend/wbprivate/sqlide/wb_live_schema_tree.cpp index dab2b9a..32f9a44 100644 --- a/backend/wbprivate/sqlide/wb_live_schema_tree.cpp +++ b/backend/wbprivate/sqlide/wb_live_schema_tree.cpp @@ -589,7 +589,7 @@ bool LiveSchemaTree::identifiers_equal(const std::string &a, const std::string & { if (_case_sensitive_identifiers) return a == b; - return g_strcasecmp(a.c_str(), b.c_str()) == 0; + return g_ascii_strcasecmp(a.c_str(), b.c_str()) == 0; } void LiveSchemaTree::setup_node(mforms::TreeNodeRef node, ObjectType type, mforms::TreeNodeData* pdata, bool ignore_null_data) @@ -2529,4 +2529,4 @@ void LiveSchemaTree::discard_object_data(mforms::TreeNodeRef& node, int data_mas parent_node = node->get_child(TABLE_FOREIGN_KEYS_NODE_INDEX); parent_node->remove_children(); } -} \ No newline at end of file +} diff --git a/backend/wbpublic/grtdb/db_object_helpers.cpp b/backend/wbpublic/grtdb/db_object_helpers.cpp index 85a6fd4..ee7a60d 100644 --- a/backend/wbpublic/grtdb/db_object_helpers.cpp +++ b/backend/wbpublic/grtdb/db_object_helpers.cpp @@ -78,11 +78,11 @@ db_SimpleDatatypeRef CatalogHelper::get_datatype(grt::ListRef { for (size_t c= types.count(), i= 0; i < c; i++) { - if (g_strcasecmp(types[i]->name().c_str(), name.c_str())==0) + if (g_ascii_strcasecmp(types[i]->name().c_str(), name.c_str())==0) return types[i]; //for (size_t d= types[i]->synonyms().count(), j= 0; j < d; j++) //{ - // if (g_strcasecmp(types[i]->synonyms().get(j).c_str(), name.c_str())==0) + // if (g_ascii_strcasecmp(types[i]->synonyms().get(j).c_str(), name.c_str())==0) // return types[i]; //} } @@ -1151,7 +1151,7 @@ ColumnTypeCompareResult ColumnHelper::compare_column_types(const db_ColumnRef &f void ColumnHelper::set_default_value(db_ColumnRef column, const std::string &value) { - column->defaultValueIsNull(g_strcasecmp(value.c_str(), "NULL") ? 0 : 1); + column->defaultValueIsNull(g_ascii_strcasecmp(value.c_str(), "NULL") ? 0 : 1); column->defaultValue(value.c_str()); // If a default value of NULL was set then the column can no longer be a not-null column. @@ -1168,37 +1168,37 @@ void ColumnHelper::set_default_value(db_ColumnRef column, const std::string &val // //static enum_field_types get_mysql_type_from_string(const char *type_name) //{ -// if(g_strcasecmp(type_name, "INT") == 0) +// if(g_ascii_strcasecmp(type_name, "INT") == 0) // return MYSQL_TYPE_LONG; -// if(g_strcasecmp(type_name, "TINYINT") == 0) +// if(g_ascii_strcasecmp(type_name, "TINYINT") == 0) // return MYSQL_TYPE_TINY; -// if(g_strcasecmp(type_name, "SMALLINT") == 0) +// if(g_ascii_strcasecmp(type_name, "SMALLINT") == 0) // return MYSQL_TYPE_SHORT; -// if(g_strcasecmp(type_name, "BIGINT") == 0) +// if(g_ascii_strcasecmp(type_name, "BIGINT") == 0) // return MYSQL_TYPE_LONGLONG; -// if(g_strcasecmp(type_name, "FLOAT") == 0) +// if(g_ascii_strcasecmp(type_name, "FLOAT") == 0) // return MYSQL_TYPE_FLOAT; -// if(g_strcasecmp(type_name, "DOUBLE") == 0) +// if(g_ascii_strcasecmp(type_name, "DOUBLE") == 0) // return MYSQL_TYPE_DOUBLE; -// if(g_strcasecmp(type_name, "TIME") == 0) +// if(g_ascii_strcasecmp(type_name, "TIME") == 0) // return MYSQL_TYPE_TIME; -// if(g_strcasecmp(type_name, "DATE") == 0) +// if(g_ascii_strcasecmp(type_name, "DATE") == 0) // return MYSQL_TYPE_DATE; -// if(g_strcasecmp(type_name, "DATETIME") == 0) +// if(g_ascii_strcasecmp(type_name, "DATETIME") == 0) // return MYSQL_TYPE_DATETIME; -// if(g_strcasecmp(type_name, "TIMESTAMP") == 0) +// if(g_ascii_strcasecmp(type_name, "TIMESTAMP") == 0) // return MYSQL_TYPE_TIMESTAMP; -// if(g_strcasecmp(type_name, "TEXT") == 0) +// if(g_ascii_strcasecmp(type_name, "TEXT") == 0) // return MYSQL_TYPE_STRING; -// if(g_strcasecmp(type_name, "CHAR") == 0) +// if(g_ascii_strcasecmp(type_name, "CHAR") == 0) // return MYSQL_TYPE_STRING; -// if(g_strcasecmp(type_name, "VARCHAR") == 0) +// if(g_ascii_strcasecmp(type_name, "VARCHAR") == 0) // return MYSQL_TYPE_STRING; -// if(g_strcasecmp(type_name, "BLOB") == 0) +// if(g_ascii_strcasecmp(type_name, "BLOB") == 0) // return MYSQL_TYPE_BLOB; -// if(g_strcasecmp(type_name, "BINARY") == 0) +// if(g_ascii_strcasecmp(type_name, "BINARY") == 0) // return MYSQL_TYPE_BLOB; -// if(g_strcasecmp(type_name, "VARBINARY") == 0) +// if(g_ascii_strcasecmp(type_name, "VARBINARY") == 0) // return MYSQL_TYPE_BLOB; // // return MYSQL_TYPE_NULL; @@ -1347,7 +1347,7 @@ static db_SimpleDatatypeRef findType(const grt::ListRef &type { for (size_t c= types.count(), i= 0; i < c; i++) { - if (g_strcasecmp(types[i]->name().c_str(), name.c_str())==0) + if (g_ascii_strcasecmp(types[i]->name().c_str(), name.c_str())==0) { if (!target_version.is_valid() || CatalogHelper::is_type_valid_for_version(types[i], target_version)) return types[i]; @@ -1559,7 +1559,7 @@ bool bec::parseType(const std::string &type, { db_UserDatatypeRef utype(user_types[i]); - if (g_strcasecmp(utype->name().c_str(), typeName.c_str()) == 0) + if (g_ascii_strcasecmp(utype->name().c_str(), typeName.c_str()) == 0) { userType= utype; break; diff --git a/modules/db.mysql.sqlparser/src/mysql_sql_parser.cpp b/modules/db.mysql.sqlparser/src/mysql_sql_parser.cpp index 8b0f220..02481d7 100644 --- a/modules/db.mysql.sqlparser/src/mysql_sql_parser.cpp +++ b/modules/db.mysql.sqlparser/src/mysql_sql_parser.cpp @@ -2684,7 +2684,7 @@ grt::Ref Mysql_sql_parser::create_or_find_named_routine(const grt::ListRef obj = item; break; } - else if (!case_sensitive && g_strcasecmp(item->name().c_str(), obj_name.c_str()) == 0) + else if (!case_sensitive && g_ascii_strcasecmp(item->name().c_str(), obj_name.c_str()) == 0) { obj = item; break; @@ -2707,4 +2707,4 @@ grt::Ref Mysql_sql_parser::create_or_find_named_routine(const grt::ListRef try { obj.set_member("lastChangeDate", StringRef(time)); } catch (std::exception&) {} return obj; -} \ No newline at end of file +} -- 1.8.4.3 0011-Replace-g_thread_create-with-g_thread_new-if-GError-.patch0000644000175000017500000001240312242030400022136 0ustar hhhhFrom 21d8382eb93e29176957e9688b345306617c25fe Mon Sep 17 00:00:00 2001 From: "H.Habighorst" Date: Sun, 17 Nov 2013 01:36:14 +0100 Subject: [PATCH 11/15] Replace g_thread_create with g_thread_new (if GError argument was not null, g_thread_try_new) --- backend/wbpublic/grt/common.cpp | 2 +- backend/wbpublic/grt/grt_dispatcher.cpp | 6 +++--- backend/wbpublic/sqlide/autocomplete_object_name_cache.cpp | 2 +- library/base/threaded_timer.cpp | 2 +- library/base/unit-tests/file_utilities_test.cpp | 2 +- library/forms/utilities.cpp | 2 +- plugins/migration/copytable/copytable.cpp | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/backend/wbpublic/grt/common.cpp b/backend/wbpublic/grt/common.cpp index 695c74c..aa314f9 100644 --- a/backend/wbpublic/grt/common.cpp +++ b/backend/wbpublic/grt/common.cpp @@ -310,7 +310,7 @@ namespace bec { TimerActionThread::TimerActionThread(const Action &action, gulong milliseconds) : _action(action), _microseconds(milliseconds * 1000) { g_mutex_init(&_action_mutex); - _thread= g_thread_create(start, this, FALSE, NULL); + _thread= g_thread_new("TimerActionThread", start, this); } TimerActionThread::~TimerActionThread() diff --git a/backend/wbpublic/grt/grt_dispatcher.cpp b/backend/wbpublic/grt/grt_dispatcher.cpp index 7401e42..351a5b0 100644 --- a/backend/wbpublic/grt/grt_dispatcher.cpp +++ b/backend/wbpublic/grt/grt_dispatcher.cpp @@ -383,10 +383,10 @@ void GRTDispatcher::start(boost::shared_ptr self) if (!_threading_disabled) { DPRINT("starting worker thread"); - _thread= g_thread_create(worker_thread, this, FALSE, NULL); - if (_thread == 0) + _thread= g_thread_try_new("GRT worker thread", worker_thread, this, NULL); + if (!_thread) { - log_error("g_thread_create failed to create the GRT worker thread. Falling back into non-threaded mode.\n"); + log_error("g_thread_new failed to create the GRT worker thread. Falling back into non-threaded mode.\n"); _threading_disabled = true; } } diff --git a/backend/wbpublic/sqlide/autocomplete_object_name_cache.cpp b/backend/wbpublic/sqlide/autocomplete_object_name_cache.cpp index 6b2e6de..4a49137 100644 --- a/backend/wbpublic/sqlide/autocomplete_object_name_cache.cpp +++ b/backend/wbpublic/sqlide/autocomplete_object_name_cache.cpp @@ -945,7 +945,7 @@ void AutoCompleteCache::create_worker_thread() { GError *error = NULL; log_debug3("creating worker thread\n"); - _refresh_thread = g_thread_create(&AutoCompleteCache::_refresh_cache_thread, this, 1, &error); + _refresh_thread = g_thread_try_new("AutoComplete worker thread", &AutoCompleteCache::_refresh_cache_thread, this, &error); if (!_refresh_thread) { log_error("Error creating autocompletion worker thread: %s\n", error ? error->message : "out of mem?"); diff --git a/library/base/threaded_timer.cpp b/library/base/threaded_timer.cpp index 68149d9..10f9388 100644 --- a/library/base/threaded_timer.cpp +++ b/library/base/threaded_timer.cpp @@ -140,7 +140,7 @@ ThreadedTimer::ThreadedTimer(int base_frequency): _terminate(false), _next_id(1) // Wait time in microseconds. _wait_time= 1000 * 1000 / base_frequency; g_mutex_init(&_timer_lock); - _thread= g_thread_create(start, this, TRUE, NULL); + _thread= g_thread_new("ThreadTimer Thread", start, this); _pool= g_thread_pool_new((GFunc) pool_function, this, WORKER_THREAD_COUNT, FALSE, NULL); } diff --git a/library/base/unit-tests/file_utilities_test.cpp b/library/base/unit-tests/file_utilities_test.cpp index 752affa..e0f7108 100755 --- a/library/base/unit-tests/file_utilities_test.cpp +++ b/library/base/unit-tests/file_utilities_test.cpp @@ -2546,7 +2546,7 @@ TEST_FUNCTION(70) } // Kick off the child thread - _child_thread = g_thread_create(_child_thread_func, this, TRUE, NULL); + _child_thread = g_thread_new("File Utility Test Thread", _child_thread_func, this); // Wait for _main_thread to finish g_thread_join(_child_thread); } diff --git a/library/forms/utilities.cpp b/library/forms/utilities.cpp index 924a5f0..a105453 100644 --- a/library/forms/utilities.cpp +++ b/library/forms/utilities.cpp @@ -223,7 +223,7 @@ bool Utilities::run_cancelable_task(const std::string &title, const std::string g_mutex_lock(lock.get()); // start a thread that will run the task - thread = g_thread_create((void*(*)(void*))cancellable_task_thread, data, 0, &error); + thread = g_thread_try_new("Cancelable task thread", (void*(*)(void*))cancellable_task_thread, data, &error); if (!thread) { g_mutex_unlock(lock.get()); diff --git a/plugins/migration/copytable/copytable.cpp b/plugins/migration/copytable/copytable.cpp index 0fd38ae..a0725ad 100644 --- a/plugins/migration/copytable/copytable.cpp +++ b/plugins/migration/copytable/copytable.cpp @@ -2404,7 +2404,7 @@ _target(ptarget) _tasks = ptasks; _show_progress = show_progress; - _thread = g_thread_create(&CopyDataTask::thread_func, this, TRUE, NULL); + _thread = g_thread_new("CopyDataTask Worker", &CopyDataTask::thread_func, this); } gpointer CopyDataTask::thread_func(gpointer data) -- 1.8.4.3 0012-Replace-g_async_queue_timed_pop-with-g_async_queue_t.patch0000644000175000017500000000242412242030400022605 0ustar hhhhFrom fc13626f2a45f0a7a5097de22ff844df9ff6d72a Mon Sep 17 00:00:00 2001 From: "H.Habighorst" Date: Sun, 17 Nov 2013 01:45:42 +0100 Subject: [PATCH 12/15] Replace g_async_queue_timed_pop with g_async_queue_timeout_pop. --- backend/wbpublic/grt/grt_dispatcher.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/backend/wbpublic/grt/grt_dispatcher.cpp b/backend/wbpublic/grt/grt_dispatcher.cpp index 351a5b0..4dd77f4 100644 --- a/backend/wbpublic/grt/grt_dispatcher.cpp +++ b/backend/wbpublic/grt/grt_dispatcher.cpp @@ -480,7 +480,7 @@ gpointer GRTDispatcher::worker_thread(gpointer data) while (!self->_worker_shutdown) { GRTTaskBase *task; - GTimeVal timeout; + self->_busy= false; self->worker_thread_iteration(); @@ -488,9 +488,8 @@ gpointer GRTDispatcher::worker_thread(gpointer data) DPRINT("worker: waiting task..."); // pop next task pushed to queue by the main thread - g_get_current_time(&timeout); - timeout.tv_sec+= 1; - task= static_cast(g_async_queue_timed_pop(task_queue, &timeout)); + // wait 1000000 microseconds / 1 second + task= static_cast(g_async_queue_timeout_pop(task_queue, 1000000)); if (!task) continue; -- 1.8.4.3 0013-Replace-g_atomic_int_exchange_and_add-with-g_atomic_.patch0000644000175000017500000000174012242030400022416 0ustar hhhhFrom e6531f530cce8c14aa6fcb80146ea94dfd29b8b7 Mon Sep 17 00:00:00 2001 From: "H.Habighorst" Date: Sun, 17 Nov 2013 01:00:23 +0100 Subject: [PATCH 13/15] Replace g_atomic_int_exchange_and_add with g_atomic_int_add. --- backend/wbpublic/grt/grt_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/wbpublic/grt/grt_manager.cpp b/backend/wbpublic/grt/grt_manager.cpp index 0bf49bd..a116f8d 100644 --- a/backend/wbpublic/grt/grt_manager.cpp +++ b/backend/wbpublic/grt/grt_manager.cpp @@ -99,7 +99,7 @@ GRTManager::GRTManager(bool threaded, bool verbose) bool GRTManager::try_soft_lock_globals_tree() { // returns true if lock count was 0 and then lock it - if (g_atomic_int_exchange_and_add(&_globals_tree_soft_lock_count, 1) == 0) + if (g_atomic_int_add(&_globals_tree_soft_lock_count, 1) == 0) return true; // lock failed, decrement it back g_atomic_int_add(&_globals_tree_soft_lock_count, -1); -- 1.8.4.3 0014-Fix-pragma-ignore-Wtype-limit-to-Wtype-limits.patch0000644000175000017500000000622012242030401020750 0ustar hhhhFrom da66da581a6cef9ba8e3329962e051560f6e248d Mon Sep 17 00:00:00 2001 From: "H.Habighorst" Date: Sun, 17 Nov 2013 01:57:14 +0100 Subject: [PATCH 14/15] Fix pragma ignore "Wtype-limit" to "Wtype-limits". --- library/mysql-parser/MySQLLexer.c | 2 +- library/mysql-parser/MySQLLexer.h | 2 +- library/mysql-parser/MySQLParser.c | 2 +- library/mysql-parser/MySQLParser.h | 2 +- library/mysql-parser/grammar/MySQL.g | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/library/mysql-parser/MySQLLexer.c b/library/mysql-parser/MySQLLexer.c index e0774b5..b9f05c0 100644 --- a/library/mysql-parser/MySQLLexer.c +++ b/library/mysql-parser/MySQLLexer.c @@ -56,7 +56,7 @@ // Comparison of unsigned expression >= 0 is always true. #pragma GCC diagnostic ignored "-Wtautological-compare" #else -#pragma GCC diagnostic ignored "-Wtype-limit" +#pragma GCC diagnostic ignored "-Wtype-limits" #endif #endif diff --git a/library/mysql-parser/MySQLLexer.h b/library/mysql-parser/MySQLLexer.h index b58a3a4..8ca9ce0 100644 --- a/library/mysql-parser/MySQLLexer.h +++ b/library/mysql-parser/MySQLLexer.h @@ -2290,7 +2290,7 @@ typedef struct MySQLLexer_Ctx_struct MySQLLexer, * pMySQLLexer; // Comparison of unsigned expression >= 0 is always true. #pragma GCC diagnostic ignored "-Wtautological-compare" #else -#pragma GCC diagnostic ignored "-Wtype-limit" +#pragma GCC diagnostic ignored "-Wtype-limits" #endif #endif diff --git a/library/mysql-parser/MySQLParser.c b/library/mysql-parser/MySQLParser.c index 747819f..448828b 100644 --- a/library/mysql-parser/MySQLParser.c +++ b/library/mysql-parser/MySQLParser.c @@ -54,7 +54,7 @@ // Comparison of unsigned expression >= 0 is always true. #pragma GCC diagnostic ignored "-Wtautological-compare" #else -#pragma GCC diagnostic ignored "-Wtype-limit" +#pragma GCC diagnostic ignored "-Wtype-limits" #endif #endif diff --git a/library/mysql-parser/MySQLParser.h b/library/mysql-parser/MySQLParser.h index d81c44e..d1d543c 100644 --- a/library/mysql-parser/MySQLParser.h +++ b/library/mysql-parser/MySQLParser.h @@ -1258,7 +1258,7 @@ typedef struct MySQLParser_Ctx_struct MySQLParser, * pMySQLParser; // Comparison of unsigned expression >= 0 is always true. #pragma GCC diagnostic ignored "-Wtautological-compare" #else -#pragma GCC diagnostic ignored "-Wtype-limit" +#pragma GCC diagnostic ignored "-Wtype-limits" #endif #endif diff --git a/library/mysql-parser/grammar/MySQL.g b/library/mysql-parser/grammar/MySQL.g index 215d2b9..f2054fd 100644 --- a/library/mysql-parser/grammar/MySQL.g +++ b/library/mysql-parser/grammar/MySQL.g @@ -137,7 +137,7 @@ typedef struct { // Comparison of unsigned expression >= 0 is always true. #pragma GCC diagnostic ignored "-Wtautological-compare" #else -#pragma GCC diagnostic ignored "-Wtype-limit" +#pragma GCC diagnostic ignored "-Wtype-limits" #endif #endif @@ -153,7 +153,7 @@ typedef struct { // Comparison of unsigned expression >= 0 is always true. #pragma GCC diagnostic ignored "-Wtautological-compare" #else -#pragma GCC diagnostic ignored "-Wtype-limit" +#pragma GCC diagnostic ignored "-Wtype-limits" #endif #endif -- 1.8.4.3 0015-CMakelists-Set-required-version-of-glib-to-2.32.0-or.patch0000644000175000017500000000145712242030401021421 0ustar hhhhFrom 4a4582f59aa7cb209b37d9f96e2ce58a35b790b5 Mon Sep 17 00:00:00 2001 From: "H.Habighorst" Date: Sun, 17 Nov 2013 03:34:29 +0100 Subject: [PATCH 15/15] CMakelists: Set required version of glib to 2.32.0 or higher --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 650e776..3c5ede4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,7 +25,7 @@ list(REMOVE_DUPLICATES GTK2_INCLUDE_DIRS) set(GTK2_LIBRARIES ${GTK2_LIBRARIES} ${GTHREAD_LIBRARIES} ${GMODULE_LIBRARIES}) list(REMOVE_DUPLICATES GTK2_LIBRARIES) -pkg_check_modules(GLIB REQUIRED glib-2.0) +pkg_check_modules(GLIB REQUIRED glib-2.0>=2.32.0) if (USE_BUNDLED_MYSQLDUMP) set(USE_BUNDLED_MYSQLDUMP -DHAVE_BUNDLED_MYSQLDUMP=1) -- 1.8.4.3