[gnome-builder] libide: make API more amenable to ABI enforcement



commit 7c0bc1c43f376486d6777b493f1787ec4c26d0af
Author: Christian Hergert <chergert redhat com>
Date:   Thu Mar 22 03:10:21 2018 -0700

    libide: make API more amenable to ABI enforcement
    
    This gets things going so we can compile with visibility
    hidden by default. We still need to fix the visibility of the
    register types plugins in libide before we can enable it.

 src/libide/application/ide-application-tests.h     |  3 ++
 src/libide/application/ide-application.c           | 15 ++++++---
 src/libide/application/ide-application.h           |  2 +-
 src/libide/buffers/ide-buffer-private.h            |  1 -
 src/libide/buffers/ide-buffer.c                    |  2 +-
 src/libide/buffers/ide-buffer.h                    |  2 ++
 .../editor/ide-editor-layout-stack-controls.c      |  2 +-
 src/libide/editor/ide-editor-view.c                |  2 +-
 .../editorconfig/ide-editorconfig-file-settings.h  | 11 +++----
 src/libide/ide.h                                   |  1 +
 src/libide/snippets/ide-source-snippet-parser.c    |  4 +++
 src/libide/snippets/ide-source-snippet-parser.h    |  9 ++++--
 src/libide/sourceview/ide-source-iter.c            |  2 ++
 src/libide/sourceview/ide-source-iter.h            | 35 ++++++++++----------
 src/libide/sourceview/ide-source-view.c            |  8 ++---
 src/libide/sourceview/ide-text-iter.h              | 21 ++++++++++++
 src/libide/sourceview/meson.build                  |  6 ++--
 src/libide/threading/ide-task.c                    |  7 ++++
 src/libide/threading/ide-thread-pool.c             | 37 +++++++++++++---------
 src/main.c                                         |  4 +--
 src/plugins/xml-pack/ide-xml-service.c             |  4 +--
 src/tests/test-ide-buffer-manager.c                |  2 +-
 src/tests/test-ide-buffer.c                        |  2 +-
 src/tests/test-ide-build-pipeline.c                |  2 +-
 src/tests/test-ide-context.c                       |  2 +-
 src/tests/test-ide-file-settings.c                 |  2 +-
 src/tests/test-ide-indenter.c                      |  2 +-
 src/tests/test-ide-runtime.c                       |  2 +-
 src/tests/test-ide-task.c                          |  4 ---
 src/tests/test-snippet.c                           |  2 +-
 src/tests/test-vim.c                               |  2 +-
 31 files changed, 125 insertions(+), 75 deletions(-)
---
diff --git a/src/libide/application/ide-application-tests.h b/src/libide/application/ide-application-tests.h
index 32e6a1ac9..565b17e56 100644
--- a/src/libide/application/ide-application-tests.h
+++ b/src/libide/application/ide-application-tests.h
@@ -18,6 +18,8 @@
 
 #pragma once
 
+#include "ide-version-macros.h"
+
 #include "application/ide-application.h"
 
 G_BEGIN_DECLS
@@ -28,6 +30,7 @@ typedef void     (*IdeApplicationTest)           (GCancellable         *cancella
 typedef gboolean (*IdeApplicationTestCompletion) (GAsyncResult         *result,
                                                   GError              **error);
 
+IDE_AVAILABLE_IN_ALL
 void ide_application_add_test (IdeApplication               *self,
                                const gchar                  *test_name,
                                IdeApplicationTest            test_func,
diff --git a/src/libide/application/ide-application.c b/src/libide/application/ide-application.c
index f236280cc..e8d4fe4ba 100644
--- a/src/libide/application/ide-application.c
+++ b/src/libide/application/ide-application.c
@@ -699,12 +699,17 @@ ide_application_init (IdeApplication *self)
  * Since: 3.22
  */
 IdeApplication *
-ide_application_new (void)
+ide_application_new (IdeApplicationMode mode)
 {
-  return g_object_new (IDE_TYPE_APPLICATION,
-                       "application-id", "org.gnome.Builder",
-                       "flags", G_APPLICATION_HANDLES_OPEN,
-                       NULL);
+  IdeApplication *app;
+
+  app = g_object_new (IDE_TYPE_APPLICATION,
+                      "application-id", "org.gnome.Builder",
+                      "flags", G_APPLICATION_HANDLES_OPEN,
+                      NULL);
+  _ide_application_set_mode (app, mode);
+
+  return app;
 }
 
 /**
diff --git a/src/libide/application/ide-application.h b/src/libide/application/ide-application.h
index 100abbed6..4877a7031 100644
--- a/src/libide/application/ide-application.h
+++ b/src/libide/application/ide-application.h
@@ -48,7 +48,7 @@ GThread            *ide_application_get_main_thread        (void);
 IDE_AVAILABLE_IN_ALL
 IdeApplicationMode  ide_application_get_mode               (IdeApplication       *self);
 IDE_AVAILABLE_IN_ALL
-IdeApplication     *ide_application_new                    (void);
+IdeApplication     *ide_application_new                    (IdeApplicationMode    mode);
 IDE_AVAILABLE_IN_ALL
 GDateTime          *ide_application_get_started_at         (IdeApplication       *self);
 IDE_AVAILABLE_IN_3_28
diff --git a/src/libide/buffers/ide-buffer-private.h b/src/libide/buffers/ide-buffer-private.h
index 55c6164de..d2c500681 100644
--- a/src/libide/buffers/ide-buffer-private.h
+++ b/src/libide/buffers/ide-buffer-private.h
@@ -30,7 +30,6 @@ G_BEGIN_DECLS
 PeasExtensionSet *_ide_buffer_get_addins            (IdeBuffer        *self);
 void              _ide_buffer_set_changed_on_volume (IdeBuffer        *self,
                                                      gboolean          changed_on_volume);
-gboolean          _ide_buffer_get_loading           (IdeBuffer        *self);
 void              _ide_buffer_set_loading           (IdeBuffer        *self,
                                                      gboolean          loading);
 void              _ide_buffer_cancel_cursor_restore (IdeBuffer        *self);
diff --git a/src/libide/buffers/ide-buffer.c b/src/libide/buffers/ide-buffer.c
index e81e78749..1d17e142f 100644
--- a/src/libide/buffers/ide-buffer.c
+++ b/src/libide/buffers/ide-buffer.c
@@ -2453,7 +2453,7 @@ ide_buffer_set_style_scheme_name (IdeBuffer   *self,
 }
 
 gboolean
-_ide_buffer_get_loading (IdeBuffer *self)
+ide_buffer_get_loading (IdeBuffer *self)
 {
   IdeBufferPrivate *priv = ide_buffer_get_instance_private (self);
 
diff --git a/src/libide/buffers/ide-buffer.h b/src/libide/buffers/ide-buffer.h
index 75cfc9bca..679bcd6c7 100644
--- a/src/libide/buffers/ide-buffer.h
+++ b/src/libide/buffers/ide-buffer.h
@@ -93,6 +93,8 @@ IDE_AVAILABLE_IN_ALL
 gboolean                  ide_buffer_get_spell_checking            (IdeBuffer            *self);
 IDE_AVAILABLE_IN_ALL
 gboolean                  ide_buffer_get_highlight_diagnostics     (IdeBuffer            *self);
+IDE_AVAILABLE_IN_3_30
+gboolean                  ide_buffer_get_loading                   (IdeBuffer            *self);
 IDE_AVAILABLE_IN_ALL
 const gchar              *ide_buffer_get_style_scheme_name         (IdeBuffer            *self);
 IDE_AVAILABLE_IN_ALL
diff --git a/src/libide/editor/ide-editor-layout-stack-controls.c 
b/src/libide/editor/ide-editor-layout-stack-controls.c
index 98f6c5ad4..2de3e519f 100644
--- a/src/libide/editor/ide-editor-layout-stack-controls.c
+++ b/src/libide/editor/ide-editor-layout-stack-controls.c
@@ -48,7 +48,7 @@ document_cursor_moved (IdeEditorLayoutStackControls *self,
   if (self->view == NULL)
     return;
 
-  if (_ide_buffer_get_loading (IDE_BUFFER (buffer)))
+  if (ide_buffer_get_loading (IDE_BUFFER (buffer)))
     return;
 
   source_view = ide_editor_view_get_view (self->view);
diff --git a/src/libide/editor/ide-editor-view.c b/src/libide/editor/ide-editor-view.c
index 9f71b0e8a..32498fdc6 100644
--- a/src/libide/editor/ide-editor-view.c
+++ b/src/libide/editor/ide-editor-view.c
@@ -172,7 +172,7 @@ ide_editor_view_buffer_modified_changed (IdeEditorView *self,
   g_assert (IDE_IS_EDITOR_VIEW (self));
   g_assert (IDE_IS_BUFFER (buffer));
 
-  if (!_ide_buffer_get_loading (buffer))
+  if (!ide_buffer_get_loading (buffer))
     modified = gtk_text_buffer_get_modified (GTK_TEXT_BUFFER (buffer));
 
   ide_layout_view_set_modified (IDE_LAYOUT_VIEW (self), modified);
diff --git a/src/libide/editorconfig/ide-editorconfig-file-settings.h 
b/src/libide/editorconfig/ide-editorconfig-file-settings.h
index 5682f096c..8a1d85f32 100644
--- a/src/libide/editorconfig/ide-editorconfig-file-settings.h
+++ b/src/libide/editorconfig/ide-editorconfig-file-settings.h
@@ -18,16 +18,15 @@
 
 #pragma once
 
+#include "ide-version-macros.h"
+
 #include "files/ide-file-settings.h"
 
 G_BEGIN_DECLS
 
-#define IDE_TYPE_EDITORCONFIG_FILE_SETTINGS \
-  (ide_editorconfig_file_settings_get_type())
+#define IDE_TYPE_EDITORCONFIG_FILE_SETTINGS (ide_editorconfig_file_settings_get_type())
 
-G_DECLARE_FINAL_TYPE (IdeEditorconfigFileSettings,
-                      ide_editorconfig_file_settings,
-                      IDE, EDITORCONFIG_FILE_SETTINGS,
-                      IdeFileSettings)
+IDE_AVAILABLE_IN_ALL
+G_DECLARE_FINAL_TYPE (IdeEditorconfigFileSettings, ide_editorconfig_file_settings, IDE, 
EDITORCONFIG_FILE_SETTINGS, IdeFileSettings)
 
 G_END_DECLS
diff --git a/src/libide/ide.h b/src/libide/ide.h
index 3d2686913..d06c1c8cd 100644
--- a/src/libide/ide.h
+++ b/src/libide/ide.h
@@ -150,6 +150,7 @@ G_BEGIN_DECLS
 #include "search/ide-tagged-entry.h"
 #include "snippets/ide-source-snippet-chunk.h"
 #include "snippets/ide-source-snippet-context.h"
+#include "snippets/ide-source-snippet-parser.h"
 #include "snippets/ide-source-snippet.h"
 #include "snippets/ide-source-snippets-manager.h"
 #include "snippets/ide-source-snippets.h"
diff --git a/src/libide/snippets/ide-source-snippet-parser.c b/src/libide/snippets/ide-source-snippet-parser.c
index 83d726477..d75a52f42 100644
--- a/src/libide/snippets/ide-source-snippet-parser.c
+++ b/src/libide/snippets/ide-source-snippet-parser.c
@@ -16,6 +16,10 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+#define G_LOG_DOMAIN "ide-source-snippet-parser"
+
+#include "config.h"
+
 #include <errno.h>
 #include <glib/gi18n.h>
 #include <stdlib.h>
diff --git a/src/libide/snippets/ide-source-snippet-parser.h b/src/libide/snippets/ide-source-snippet-parser.h
index b22155f5d..ecad46307 100644
--- a/src/libide/snippets/ide-source-snippet-parser.h
+++ b/src/libide/snippets/ide-source-snippet-parser.h
@@ -20,17 +20,22 @@
 
 #include <gio/gio.h>
 
+#include "ide-version-macros.h"
+
 G_BEGIN_DECLS
 
 #define IDE_TYPE_SOURCE_SNIPPET_PARSER (ide_source_snippet_parser_get_type())
 
-G_DECLARE_FINAL_TYPE (IdeSourceSnippetParser, ide_source_snippet_parser,
-                      IDE, SOURCE_SNIPPET_PARSER, GObject)
+IDE_AVAILABLE_IN_ALL
+G_DECLARE_FINAL_TYPE (IdeSourceSnippetParser, ide_source_snippet_parser, IDE, SOURCE_SNIPPET_PARSER, GObject)
 
+IDE_AVAILABLE_IN_ALL
 IdeSourceSnippetParser *ide_source_snippet_parser_new            (void);
+IDE_AVAILABLE_IN_ALL
 gboolean                ide_source_snippet_parser_load_from_file (IdeSourceSnippetParser  *parser,
                                                                   GFile                   *file,
                                                                   GError                 **error);
+IDE_AVAILABLE_IN_ALL
 GList                  *ide_source_snippet_parser_get_snippets   (IdeSourceSnippetParser  *parser);
 
 G_END_DECLS
diff --git a/src/libide/sourceview/ide-source-iter.c b/src/libide/sourceview/ide-source-iter.c
index f90254acb..f2ca9475a 100644
--- a/src/libide/sourceview/ide-source-iter.c
+++ b/src/libide/sourceview/ide-source-iter.c
@@ -32,6 +32,8 @@
  * https://bugzilla.gnome.org/show_bug.cgi?id=111503
  */
 
+#include "config.h"
+
 /*
  * TODO: Once this is made public api, switch to using that instead of a copy.
  */
diff --git a/src/libide/sourceview/ide-source-iter.h b/src/libide/sourceview/ide-source-iter.h
index 89b145b3a..5f082cf97 100644
--- a/src/libide/sourceview/ide-source-iter.h
+++ b/src/libide/sourceview/ide-source-iter.h
@@ -24,61 +24,62 @@
 
 #include <gtk/gtk.h>
 
+#include "ide-version-macros.h"
+
 G_BEGIN_DECLS
 
 /* Semi-public functions. */
 
-G_GNUC_INTERNAL
+IDE_AVAILABLE_IN_ALL
 gboolean       _ide_source_iter_forward_visible_word_end               (GtkTextIter *iter);
 
-G_GNUC_INTERNAL
+IDE_AVAILABLE_IN_ALL
 gboolean       _ide_source_iter_forward_visible_word_ends              (GtkTextIter *iter,
                                                                         gint         count);
 
+IDE_AVAILABLE_IN_ALL
 gboolean       _ide_source_iter_backward_visible_word_start            (GtkTextIter *iter);
 
-G_GNUC_INTERNAL
+IDE_AVAILABLE_IN_ALL
 gboolean       _ide_source_iter_backward_visible_word_starts           (GtkTextIter *iter,
                                                                         gint         count);
 
-G_GNUC_INTERNAL
+IDE_AVAILABLE_IN_ALL
 void           _ide_source_iter_extend_selection_word                  (const GtkTextIter *location,
                                                                         GtkTextIter       *start,
                                                                         GtkTextIter       *end);
 
-/* Internal functions, in the header for unit tests. */
-
-G_GNUC_INTERNAL
+IDE_AVAILABLE_IN_ALL
 void           _ide_source_iter_forward_full_word_end                  (GtkTextIter *iter);
 
-G_GNUC_INTERNAL
+IDE_AVAILABLE_IN_ALL
 void           _ide_source_iter_backward_full_word_start               (GtkTextIter *iter);
 
-G_GNUC_INTERNAL
+IDE_AVAILABLE_IN_ALL
 gboolean       _ide_source_iter_starts_full_word                       (const GtkTextIter *iter);
 
-G_GNUC_INTERNAL
+IDE_AVAILABLE_IN_ALL
 gboolean       _ide_source_iter_ends_full_word                         (const GtkTextIter *iter);
 
-G_GNUC_INTERNAL
+IDE_AVAILABLE_IN_ALL
 void           _ide_source_iter_forward_extra_natural_word_end         (GtkTextIter *iter);
 
-G_GNUC_INTERNAL
+IDE_AVAILABLE_IN_ALL
 void           _ide_source_iter_backward_extra_natural_word_start      (GtkTextIter *iter);
 
-G_GNUC_INTERNAL
+IDE_AVAILABLE_IN_ALL
 gboolean       _ide_source_iter_starts_extra_natural_word              (const GtkTextIter *iter);
 
-G_GNUC_INTERNAL
+IDE_AVAILABLE_IN_ALL
 gboolean       _ide_source_iter_ends_extra_natural_word                (const GtkTextIter *iter);
 
-G_GNUC_INTERNAL
+IDE_AVAILABLE_IN_ALL
 gboolean       _ide_source_iter_starts_word                            (const GtkTextIter *iter);
 
-G_GNUC_INTERNAL
+IDE_AVAILABLE_IN_ALL
 gboolean       _ide_source_iter_ends_word                              (const GtkTextIter *iter);
 
-G_GNUC_INTERNAL
+IDE_AVAILABLE_IN_ALL
 gboolean       _ide_source_iter_inside_word                            (const GtkTextIter *iter);
 
 G_END_DECLS
diff --git a/src/libide/sourceview/ide-source-view.c b/src/libide/sourceview/ide-source-view.c
index 4768ccfc4..a20afe7a2 100644
--- a/src/libide/sourceview/ide-source-view.c
+++ b/src/libide/sourceview/ide-source-view.c
@@ -1033,7 +1033,7 @@ ide_source_view__buffer_insert_text_cb (IdeSourceView *self,
   g_assert (text != NULL);
   g_assert (IDE_IS_BUFFER (buffer));
 
-  if (_ide_buffer_get_loading (IDE_BUFFER (buffer)))
+  if (ide_buffer_get_loading (IDE_BUFFER (buffer)))
     return;
 
   gtk_text_buffer_begin_user_action (buffer);
@@ -1062,7 +1062,7 @@ ide_source_view__buffer_insert_text_after_cb (IdeSourceView *self,
   g_assert (text != NULL);
   g_assert (IDE_IS_BUFFER (buffer));
 
-  if (_ide_buffer_get_loading (IDE_BUFFER (buffer)))
+  if (ide_buffer_get_loading (IDE_BUFFER (buffer)))
     return;
 
   if (NULL != (snippet = g_queue_peek_head (priv->snippets)))
@@ -1417,7 +1417,7 @@ ide_source_view_bind_buffer (IdeSourceView  *self,
 
   ide_buffer_hold (buffer);
 
-  if (_ide_buffer_get_loading (buffer))
+  if (ide_buffer_get_loading (buffer))
     {
       GtkSourceCompletion *completion;
 
@@ -7302,7 +7302,7 @@ ide_source_view_jump (IdeSourceView     *self,
   g_return_if_fail (IDE_IS_SOURCE_VIEW (self));
 
   if (priv->buffer != NULL &&
-      !_ide_buffer_get_loading (priv->buffer))
+      !ide_buffer_get_loading (priv->buffer))
     {
       GtkTextIter dummy_from;
       GtkTextIter dummy_to;
diff --git a/src/libide/sourceview/ide-text-iter.h b/src/libide/sourceview/ide-text-iter.h
index 951fbe1cf..8d48e1ccc 100644
--- a/src/libide/sourceview/ide-text-iter.h
+++ b/src/libide/sourceview/ide-text-iter.h
@@ -20,50 +20,71 @@
 
 #include <gtk/gtk.h>
 
+#include "ide-version-macros.h"
+
 G_BEGIN_DECLS
 
+/* Semi-public API */
+
 typedef gboolean (* IdeTextIterCharPredicate)    (GtkTextIter              *iter,
                                                   gunichar                  ch,
                                                   gpointer                  user_data);
 
+IDE_AVAILABLE_IN_ALL
 gboolean _ide_text_iter_forward_find_char        (GtkTextIter              *iter,
                                                   IdeTextIterCharPredicate  pred,
                                                   gpointer                  user_data,
                                                   const GtkTextIter        *limit);
+IDE_AVAILABLE_IN_ALL
 gboolean _ide_text_iter_backward_find_char       (GtkTextIter              *iter,
                                                   IdeTextIterCharPredicate  pred,
                                                   gpointer                  user_data,
                                                   const GtkTextIter        *limit);
+IDE_AVAILABLE_IN_ALL
 gboolean _ide_text_iter_forward_word_start       (GtkTextIter              *iter,
                                                   gboolean                  newline_stop);
+IDE_AVAILABLE_IN_ALL
 gboolean _ide_text_iter_forward_WORD_start       (GtkTextIter              *iter,
                                                   gboolean                  newline_stop);
+IDE_AVAILABLE_IN_ALL
 gboolean _ide_text_iter_forward_word_end         (GtkTextIter              *iter,
                                                   gboolean                  newline_stop);
+IDE_AVAILABLE_IN_ALL
 gboolean _ide_text_iter_forward_WORD_end         (GtkTextIter              *iter,
                                                   gboolean                  newline_stop);
+IDE_AVAILABLE_IN_ALL
 gboolean _ide_text_iter_backward_paragraph_start (GtkTextIter              *iter);
+IDE_AVAILABLE_IN_ALL
 gboolean _ide_text_iter_forward_paragraph_end    (GtkTextIter              *iter);
+IDE_AVAILABLE_IN_ALL
 gboolean _ide_text_iter_backward_sentence_start  (GtkTextIter              *iter);
+IDE_AVAILABLE_IN_ALL
 gboolean _ide_text_iter_forward_sentence_end     (GtkTextIter              *iter);
+IDE_AVAILABLE_IN_ALL
 gboolean _ide_text_iter_backward_WORD_start      (GtkTextIter              *iter,
                                                   gboolean                  newline_stop);
+IDE_AVAILABLE_IN_ALL
 gboolean _ide_text_iter_backward_word_start      (GtkTextIter              *iter,
                                                   gboolean                  newline_stop);
+IDE_AVAILABLE_IN_ALL
 gboolean _ide_text_iter_backward_WORD_end        (GtkTextIter              *iter,
                                                   gboolean                  newline_stop);
+IDE_AVAILABLE_IN_ALL
 gboolean _ide_text_iter_backward_word_end        (GtkTextIter              *iter,
                                                   gboolean                  newline_stop);
+IDE_AVAILABLE_IN_ALL
 gboolean _ide_text_iter_in_string                (GtkTextIter              *iter,
                                                   const gchar              *str,
                                                   GtkTextIter              *str_start,
                                                   GtkTextIter              *str_end,
                                                   gboolean                  include_str_bounds);
+IDE_AVAILABLE_IN_ALL
 gboolean _ide_text_iter_find_chars_backward      (GtkTextIter              *iter,
                                                   GtkTextIter              *limit,
                                                   GtkTextIter              *end,
                                                   const gchar              *str,
                                                   gboolean                  only_at_start);
+IDE_AVAILABLE_IN_ALL
 gboolean _ide_text_iter_find_chars_forward       (GtkTextIter              *iter,
                                                   GtkTextIter              *limit,
                                                   GtkTextIter              *end,
diff --git a/src/libide/sourceview/meson.build b/src/libide/sourceview/meson.build
index 4ece5600d..14dafff11 100644
--- a/src/libide/sourceview/meson.build
+++ b/src/libide/sourceview/meson.build
@@ -4,9 +4,11 @@ sourceview_headers = [
   'ide-completion-results.h',
   'ide-indenter.h',
   'ide-language.h',
+  'ide-source-iter.h',
   'ide-source-map.h',
   'ide-source-style-scheme.h',
   'ide-source-view.h',
+  'ide-text-iter.h',
 ]
 
 sourceview_sources = [
@@ -15,9 +17,11 @@ sourceview_sources = [
   'ide-completion-results.c',
   'ide-indenter.c',
   'ide-language.c',
+  'ide-source-iter.c',
   'ide-source-map.c',
   'ide-source-style-scheme.c',
   'ide-source-view.c',
+  'ide-text-iter.c',
 ]
 
 sourceview_private_sources = [
@@ -25,12 +29,10 @@ sourceview_private_sources = [
   'ide-cursor.c',
   'ide-omni-gutter-renderer.c',
   'ide-line-change-gutter-renderer.c',
-  'ide-source-iter.c',
   'ide-source-view-capture.c',
   'ide-source-view-mode.c',
   'ide-source-view-movements.c',
   'ide-source-view-shortcuts.c',
-  'ide-text-iter.c',
   'ide-text-util.c',
   'ide-word-completion-provider.c',
   'ide-word-completion-results.c',
diff --git a/src/libide/threading/ide-task.c b/src/libide/threading/ide-task.c
index f9f393230..ec469ea7a 100644
--- a/src/libide/threading/ide-task.c
+++ b/src/libide/threading/ide-task.c
@@ -25,6 +25,7 @@
 
 #include "threading/ide-task.h"
 #include "threading/ide-thread-pool.h"
+#include "threading/ide-thread-private.h"
 
 /**
  * SECTION:ide-task
@@ -642,6 +643,12 @@ ide_task_class_init (IdeTaskClass *klass)
                           G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
 
   g_object_class_install_properties (object_class, N_PROPS, properties);
+
+  /* This can be called multiple times, so we use this to allow
+   * unit tests to work without having to expose the function as
+   * public API.
+   */
+  _ide_thread_pool_init (FALSE);
 }
 
 static void
diff --git a/src/libide/threading/ide-thread-pool.c b/src/libide/threading/ide-thread-pool.c
index 5872161bc..c7f5e6f47 100644
--- a/src/libide/threading/ide-thread-pool.c
+++ b/src/libide/threading/ide-thread-pool.c
@@ -198,21 +198,28 @@ ide_thread_pool_worker (gpointer data,
 void
 _ide_thread_pool_init (gboolean is_worker)
 {
-  for (IdeThreadPoolKind kind = IDE_THREAD_POOL_DEFAULT;
-       kind < IDE_THREAD_POOL_LAST;
-       kind++)
+  static gsize initialized;
+
+  if (g_once_init_enter (&initialized))
     {
-      IdeThreadPool *p = &thread_pools[kind];
-      g_autoptr(GError) error = NULL;
-
-      p->pool = g_thread_pool_new (ide_thread_pool_worker,
-                                   NULL,
-                                   is_worker ? p->worker_max_threads : p->max_threads,
-                                   p->exclusive,
-                                   &error);
-
-      if (error != NULL)
-        g_error ("Failed to initialize thread pool %u: %s",
-                 p->kind, error->message);
+      for (IdeThreadPoolKind kind = IDE_THREAD_POOL_DEFAULT;
+           kind < IDE_THREAD_POOL_LAST;
+           kind++)
+        {
+          IdeThreadPool *p = &thread_pools[kind];
+          g_autoptr(GError) error = NULL;
+
+          p->pool = g_thread_pool_new (ide_thread_pool_worker,
+                                       NULL,
+                                       is_worker ? p->worker_max_threads : p->max_threads,
+                                       p->exclusive,
+                                       &error);
+
+          if (error != NULL)
+            g_error ("Failed to initialize thread pool %u: %s",
+                     p->kind, error->message);
+        }
+
+      g_once_init_leave (&initialized, TRUE);
     }
 }
diff --git a/src/main.c b/src/main.c
index f3bea6db7..338103384 100644
--- a/src/main.c
+++ b/src/main.c
@@ -23,7 +23,6 @@
 #include <gtksourceview/gtksource.h>
 #include <stdlib.h>
 
-#include "application/ide-application-private.h"
 #include "plugins/gnome-builder-plugins.h"
 
 #include "bug-buddy.h"
@@ -162,8 +161,7 @@ main (int   argc,
   g_type_ensure (G_TYPE_ZLIB_DECOMPRESSOR);
 
   /* Setup the application instance */
-  app = ide_application_new ();
-  _ide_application_set_mode (app, early_mode);
+  app = ide_application_new (early_mode);
 
   /* Ensure that our static plugins init routine is called.
    * This is necessary to ensure that -Wl,--as-needed does not
diff --git a/src/plugins/xml-pack/ide-xml-service.c b/src/plugins/xml-pack/ide-xml-service.c
index c4283e407..bdf2fad56 100644
--- a/src/plugins/xml-pack/ide-xml-service.c
+++ b/src/plugins/xml-pack/ide-xml-service.c
@@ -31,8 +31,6 @@
 #include "ide-xml-service.h"
 #include "ide-xml-tree-builder.h"
 
-gboolean _ide_buffer_get_loading (IdeBuffer *self);
-
 #define DEFAULT_EVICTION_MSEC (60 * 1000)
 
 struct _IdeXmlService
@@ -331,7 +329,7 @@ ide_xml_service_get_analysis_async (IdeXmlService       *self,
     {
       TaskState *state;
 
-      if (!_ide_buffer_get_loading (buffer))
+      if (!ide_buffer_get_loading (buffer))
         {
           g_task_return_new_error (task,
                                    G_IO_ERROR,
diff --git a/src/tests/test-ide-buffer-manager.c b/src/tests/test-ide-buffer-manager.c
index 4113837a0..9e6e19896 100644
--- a/src/tests/test-ide-buffer-manager.c
+++ b/src/tests/test-ide-buffer-manager.c
@@ -184,7 +184,7 @@ main (gint   argc,
   ide_log_init (TRUE, NULL);
   ide_log_set_verbosity (4);
 
-  app = ide_application_new ();
+  app = ide_application_new (IDE_APPLICATION_MODE_TESTS);
   ide_application_add_test (app, "/Ide/BufferManager/basic", test_buffer_manager_basic, NULL, 
required_plugins);
   gnome_builder_plugins_init ();
   ret = g_application_run (G_APPLICATION (app), argc, argv);
diff --git a/src/tests/test-ide-buffer.c b/src/tests/test-ide-buffer.c
index 65c780be8..59e2f049f 100644
--- a/src/tests/test-ide-buffer.c
+++ b/src/tests/test-ide-buffer.c
@@ -112,7 +112,7 @@ main (gint   argc,
   ide_log_init (TRUE, NULL);
   ide_log_set_verbosity (4);
 
-  app = ide_application_new ();
+  app = ide_application_new (IDE_APPLICATION_MODE_TESTS);
   ide_application_add_test (app, "/Ide/Buffer/basic", test_buffer_basic, NULL, required_plugins);
   gnome_builder_plugins_init ();
   ret = g_application_run (G_APPLICATION (app), argc, argv);
diff --git a/src/tests/test-ide-build-pipeline.c b/src/tests/test-ide-build-pipeline.c
index 5c54a2680..ff4a18670 100644
--- a/src/tests/test-ide-build-pipeline.c
+++ b/src/tests/test-ide-build-pipeline.c
@@ -114,7 +114,7 @@ main (gint   argc,
   ide_log_init (TRUE, NULL);
   ide_log_set_verbosity (4);
 
-  app = ide_application_new ();
+  app = ide_application_new (IDE_APPLICATION_MODE_TESTS);
   ide_application_add_test (app, "/Ide/BuildPipeline/basic", test_build_pipeline, NULL);
   gnome_builder_plugins_init ();
   ret = g_application_run (G_APPLICATION (app), argc, argv);
diff --git a/src/tests/test-ide-context.c b/src/tests/test-ide-context.c
index c15d31a6f..cc4928083 100644
--- a/src/tests/test-ide-context.c
+++ b/src/tests/test-ide-context.c
@@ -113,7 +113,7 @@ main (gint   argc,
   ide_log_init (TRUE, NULL);
   ide_log_set_verbosity (4);
 
-  app = ide_application_new ();
+  app = ide_application_new (IDE_APPLICATION_MODE_TESTS);
 
 #define ADD_TEST_FUNC(name) \
   ide_application_add_test (app, "/Ide/Context/"#name, test_##name, NULL, required_plugins);
diff --git a/src/tests/test-ide-file-settings.c b/src/tests/test-ide-file-settings.c
index f25b1f5b5..7d533bd60 100644
--- a/src/tests/test-ide-file-settings.c
+++ b/src/tests/test-ide-file-settings.c
@@ -175,7 +175,7 @@ main (gint argc,
   ide_log_init (TRUE, NULL);
   ide_log_set_verbosity (4);
 
-  app = ide_application_new ();
+  app = ide_application_new (IDE_APPLICATION_MODE_TESTS);
   ide_application_add_test (app, "/Ide/FileSettings/basic", test_filesettings, NULL, required_plugins);
   ide_application_add_test (app, "/Ide/EditorconfigFileSettings/basic", test_editorconfig, NULL, 
required_plugins);
   gnome_builder_plugins_init ();
diff --git a/src/tests/test-ide-indenter.c b/src/tests/test-ide-indenter.c
index d1285ab29..41ea3aa3d 100644
--- a/src/tests/test-ide-indenter.c
+++ b/src/tests/test-ide-indenter.c
@@ -173,7 +173,7 @@ main (gint argc,
   ide_log_init (TRUE, NULL);
   ide_log_set_verbosity (4);
 
-  app = ide_application_new ();
+  app = ide_application_new (IDE_APPLICATION_MODE_TESTS);
   ide_application_add_test (app, "/Ide/CIndenter/basic", test_cindenter_basic, NULL, required_plugins);
   gnome_builder_plugins_init ();
   ret = g_application_run (G_APPLICATION (app), argc, argv);
diff --git a/src/tests/test-ide-runtime.c b/src/tests/test-ide-runtime.c
index 68425bc7d..aa1e3ff62 100644
--- a/src/tests/test-ide-runtime.c
+++ b/src/tests/test-ide-runtime.c
@@ -88,7 +88,7 @@ main (gint   argc,
   ide_log_init (TRUE, NULL);
   ide_log_set_verbosity (4);
 
-  app = ide_application_new ();
+  app = ide_application_new (IDE_APPLICATION_MODE_TESTS);
   ide_application_add_test (app, "/Ide/Runtime/basic", test_runtime, NULL, required_plugins);
   gnome_builder_plugins_init ();
 
diff --git a/src/tests/test-ide-task.c b/src/tests/test-ide-task.c
index 08fe7febe..6f7412dfe 100644
--- a/src/tests/test-ide-task.c
+++ b/src/tests/test-ide-task.c
@@ -18,8 +18,6 @@
 
 #include <ide.h>
 
-#include "../libide/threading/ide-thread-private.h"
-
 static gboolean
 complete_int (gpointer data)
 {
@@ -676,8 +674,6 @@ gint
 main (gint   argc,
       gchar *argv[])
 {
-  _ide_thread_pool_init (FALSE);
-
   g_test_init (&argc, &argv, NULL);
 
   g_test_add_func ("/Ide/Task/typical", test_ide_task_typical);
diff --git a/src/tests/test-snippet.c b/src/tests/test-snippet.c
index ad402ede2..43d171ffc 100644
--- a/src/tests/test-snippet.c
+++ b/src/tests/test-snippet.c
@@ -314,7 +314,7 @@ main (gint   argc,
   ide_log_init (TRUE, NULL);
   ide_log_set_verbosity (4);
 
-  app = ide_application_new ();
+  app = ide_application_new (IDE_APPLICATION_MODE_TESTS);
   ide_application_add_test (app, "/Ide/Snippets/basic", test_snippets_basic, NULL);
   gnome_builder_plugins_init ();
   ret = g_application_run (G_APPLICATION (app), argc, argv);
diff --git a/src/tests/test-vim.c b/src/tests/test-vim.c
index 5500cd90c..bd5b4f112 100644
--- a/src/tests/test-vim.c
+++ b/src/tests/test-vim.c
@@ -186,7 +186,7 @@ main (gint   argc,
   ide_log_init (TRUE, NULL);
   ide_log_set_verbosity (4);
 
-  app = ide_application_new ();
+  app = ide_application_new (IDE_APPLICATION_MODE_TESTS);
   ide_application_add_test (app, "/Ide/Vim/basic", test_vim_basic, NULL, required_plugins);
   gnome_builder_plugins_init ();
   ret = g_application_run (G_APPLICATION (app), argc, argv);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]