Gitweb links:

...log 
http://git.netsurf-browser.org/netsurf.git/shortlog/9aecf47408f22f4f0a01e41648f25e1a7307b332
...commit 
http://git.netsurf-browser.org/netsurf.git/commit/9aecf47408f22f4f0a01e41648f25e1a7307b332
...tree 
http://git.netsurf-browser.org/netsurf.git/tree/9aecf47408f22f4f0a01e41648f25e1a7307b332

The branch, master has been updated
       via  9aecf47408f22f4f0a01e41648f25e1a7307b332 (commit)
      from  b63443b243bec435c1650aef2068299674b2a209 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commitdiff 
http://git.netsurf-browser.org/netsurf.git/commit/?id=9aecf47408f22f4f0a01e41648f25e1a7307b332
commit 9aecf47408f22f4f0a01e41648f25e1a7307b332
Author: Michael Drake <[email protected]>
Commit: Michael Drake <[email protected]>

    Treeview: Rationalise initialisation and finalisation.
    
    Previously the expected behaviour for front ends using the correct
    API for hotlist, global history, cookie manager, and ssl cert
    viewer was that the front end would initialise the treeview module
    on startup and finalise it on application exit.
    
    However, this meant that the front ends had to include the core
    treeview header, which they didn't otherwise need.
    
    Since the tree module provided access to the new treeview utilities
    through the old tree API, and was used by front ends with no changes
    for the new treeview API, the tree layer refcounted initialisations
    of treeview-based widgets, and only called the underlying treeview
    init/fini functions when needed.
    
    This change moves that refcounting into the treeview module.  Now
    the hotlist, global history, cookie manager, and ssl cert viewer
    widgets call call treeview init/fini as part of their own
    initialisation and finalisation.  This means that front ends
    using the correct APIs for treeview-based widgets don't need to
    know anything about the underlying treeview, and the tree module
    compatibility layer has had its treeview refcounting removed.
    
    Finally, the treeview_init function took a font size parameter.
    Now it does not and lit gets font size from config.  We probably
    want to add a new `treeview_font_size` option to nsoptions, and
    have differnent defaults on different platforms. 12pt on RISC OS,
    and 11pt elsewhere, most likely.

diff --git a/desktop/cookie_manager.c b/desktop/cookie_manager.c
index 082a14a..b0c48a7 100644
--- a/desktop/cookie_manager.c
+++ b/desktop/cookie_manager.c
@@ -756,6 +756,11 @@ nserror cookie_manager_init(struct 
core_window_callback_table *cw_t,
 {
        nserror err;
 
+       err = treeview_init();
+       if (err != NSERROR_OK) {
+               return err;
+       }
+
        LOG("Generating cookie manager data");
 
        /* Init. cookie manager treeview entry fields */
@@ -822,6 +827,11 @@ nserror cookie_manager_fini(void)
                if (cm_ctx.values[i].value != NULL)
                        free((void *) cm_ctx.values[i].value);
 
+       err = treeview_fini();
+       if (err != NSERROR_OK) {
+               return err;
+       }
+
        LOG("Finalised cookie manager");
 
        return err;
diff --git a/desktop/global_history.c b/desktop/global_history.c
index d60874c..b6f4882 100644
--- a/desktop/global_history.c
+++ b/desktop/global_history.c
@@ -724,6 +724,11 @@ nserror global_history_init(struct 
core_window_callback_table *cw_t,
 {
        nserror err;
 
+       err = treeview_init();
+       if (err != NSERROR_OK) {
+               return err;
+       }
+
        LOG("Loading global history");
 
        /* Init. global history treeview time */
@@ -804,6 +809,11 @@ nserror global_history_fini(void)
                if (gh_ctx.fields[i].field != NULL)
                        lwc_string_unref(gh_ctx.fields[i].field);
 
+       err = treeview_fini();
+       if (err != NSERROR_OK) {
+               return err;
+       }
+
        LOG("Finalised global history");
 
        return err;
diff --git a/desktop/hotlist.c b/desktop/hotlist.c
index cce69be..e344b3b 100644
--- a/desktop/hotlist.c
+++ b/desktop/hotlist.c
@@ -1232,6 +1232,11 @@ nserror hotlist_init(struct core_window_callback_table 
*cw_t,
 {
        nserror err;
 
+       err = treeview_init();
+       if (err != NSERROR_OK) {
+               return err;
+       }
+
        LOG("Loading hotlist");
 
        hl_ctx.tree = NULL;
@@ -1298,6 +1303,11 @@ nserror hotlist_fini(const char *path)
                if (hl_ctx.fields[i].field != NULL)
                        lwc_string_unref(hl_ctx.fields[i].field);
 
+       err = treeview_fini();
+       if (err != NSERROR_OK) {
+               return err;
+       }
+
        LOG("Finalised hotlist");
 
        return err;
diff --git a/desktop/sslcert_viewer.c b/desktop/sslcert_viewer.c
index 93d6919..09a281c 100644
--- a/desktop/sslcert_viewer.c
+++ b/desktop/sslcert_viewer.c
@@ -353,6 +353,11 @@ nserror sslcert_viewer_init(struct 
core_window_callback_table *cw_t,
 
        assert(ssl_d != NULL);
 
+       err = treeview_init();
+       if (err != NSERROR_OK) {
+               return err;
+       }
+
        LOG("Building certificate viewer");
 
        /* Init. certificate chain treeview entry fields */
@@ -427,6 +432,11 @@ nserror sslcert_viewer_fini(struct sslcert_session_data 
*ssl_d)
        /* Destroy the sslcert_session_data */
        sslcert_cleanup_session(ssl_d);
 
+       err = treeview_fini();
+       if (err != NSERROR_OK) {
+               return err;
+       }
+
        LOG("Finalised ssl certificate viewer");
 
        return err;
diff --git a/desktop/tree.c b/desktop/tree.c
index bfe8e98..a5c97c3 100644
--- a/desktop/tree.c
+++ b/desktop/tree.c
@@ -55,7 +55,6 @@ struct tree {
 
 struct sslcert_session_data *ssl_current_session = NULL;
 const char *tree_hotlist_path = NULL;
-int treeview_inits;
 
 static void treeview_test_redraw_request(struct core_window *cw,
                const struct rect *r)
@@ -128,11 +127,6 @@ static bool treeview_test_init(struct tree *tree)
 {
        nserror err;
 
-       treeview_inits++;
-
-       if (treeview_inits == 1)
-               treeview_init(0);
-
        switch (tree->flags) {
        case TREE_COOKIES:
                assert(ssl_current_session == NULL &&
@@ -195,10 +189,6 @@ static bool treeview_test_fini(struct tree *tree)
                break;
        }
 
-       if (treeview_inits == 1)
-               treeview_fini();
-       treeview_inits--;
-
        return true;
 }
 
diff --git a/desktop/treeview.c b/desktop/treeview.c
index f2af5e8..5e4ceed 100644
--- a/desktop/treeview.c
+++ b/desktop/treeview.c
@@ -24,6 +24,7 @@
 
 #include "utils/log.h"
 #include "utils/nsurl.h"
+#include "utils/nsoption.h"
 #include "netsurf/bitmap.h"
 #include "netsurf/content.h"
 #include "netsurf/plotters.h"
@@ -44,7 +45,7 @@
 #define REDRAW_MAX 8000
 
 struct treeview_globals {
-       bool initialised;
+       unsigned initialised;
        int line_height;
        int furniture_width;
        int step_width;
@@ -3588,7 +3589,7 @@ static void treeview_init_plot_styles(int font_pt_size)
 
        /* Text colour */
        plot_style_even.text.family = PLOT_FONT_FAMILY_SANS_SERIF;
-       plot_style_even.text.size = font_pt_size * FONT_SIZE_SCALE;
+       plot_style_even.text.size = font_pt_size;
        plot_style_even.text.weight = 400;
        plot_style_even.text.flags = FONTF_NONE;
        plot_style_even.text.foreground = ns_system_colour_char("WindowText");
@@ -3948,23 +3949,33 @@ static nserror treeview_init_furniture(void)
 
 
 /* Exported interface, documented in treeview.h */
-nserror treeview_init(int font_pt_size)
+nserror treeview_init(void)
 {
-       int font_px_size;
+       long long font_px_size;
+       long long font_pt_size;
        nserror err;
 
-       if (tree_g.initialised == true)
+       if (tree_g.initialised > 0) {
+               tree_g.initialised++;
                return NSERROR_OK;
+       }
 
        LOG("Initialising treeview module");
 
-       if (font_pt_size <= 0)
-               font_pt_size = 11;
+       /* TODO: Should we add an extra `treeview_font_size` option for
+        *       treeviews instead of reusing the html rendering default
+        *       font size?
+        */
+       font_pt_size = nsoption_int(font_size);
+       if (font_pt_size <= 0) {
+               font_pt_size = 11 * 10;
+       }
 
-       font_px_size = (font_pt_size * FIXTOINT(nscss_screen_dpi) + 36) / 72;
+       font_px_size = (font_pt_size * FIXTOINT(nscss_screen_dpi) /
+                       10 + 36) / 72;
        tree_g.line_height = (font_px_size * 8 + 3) / 6;
 
-       treeview_init_plot_styles(font_pt_size);
+       treeview_init_plot_styles(font_pt_size * FONT_SIZE_SCALE / 10);
        treeview_init_resources();
        err = treeview_init_furniture();
        if (err != NSERROR_OK)
@@ -3976,7 +3987,7 @@ nserror treeview_init(int font_pt_size)
        tree_g.icon_step = 23;
        tree_g.move_offset = 18;
 
-       tree_g.initialised = true;
+       tree_g.initialised++;
 
        LOG("Initialised treeview module");
 
@@ -3989,6 +4000,15 @@ nserror treeview_fini(void)
 {
        int i;
 
+       if (tree_g.initialised > 1) {
+               tree_g.initialised--;
+               return NSERROR_OK;
+
+       } else if (tree_g.initialised == 0) {
+               LOG("Warning: tried to finalise uninitialised treeview module");
+               return NSERROR_OK;
+       }
+
        LOG("Finalising treeview module");
 
        for (i = 0; i < TREE_RES_LAST; i++) {
@@ -4004,7 +4024,7 @@ nserror treeview_fini(void)
        guit->bitmap->destroy(plot_style_even.furn[TREE_FURN_CONTRACT].bmp);
        guit->bitmap->destroy(plot_style_even.furn[TREE_FURN_CONTRACT].sel);
 
-       tree_g.initialised = false;
+       tree_g.initialised--;
 
        LOG("Finalised treeview module");
 
diff --git a/desktop/treeview.h b/desktop/treeview.h
index 25349ad..abe0e56 100644
--- a/desktop/treeview.h
+++ b/desktop/treeview.h
@@ -112,10 +112,9 @@ struct treeview_callback_table {
 /**
  * Prepare treeview module for treeview usage
  *
- * \param font_pt_size Treeview text size in pt.  Set to <= 0 for default.
  * \return NSERROR_OK on success, appropriate error otherwise
  */
-nserror treeview_init(int font_pt_size);
+nserror treeview_init(void);
 
 /**
  * Finalise the treeview module (all treeviews must have been destroyed first)
diff --git a/frontends/atari/gui.c b/frontends/atari/gui.c
index eb15777..1cf51d3 100644
--- a/frontends/atari/gui.c
+++ b/frontends/atari/gui.c
@@ -40,7 +40,6 @@
 #include "netsurf/cookie_db.h"
 #include "netsurf/url_db.h"
 #include "content/backing_store.h"
-#include "desktop/treeview.h"
 
 #include "atari/gemtk/gemtk.h"
 #include "atari/gui.h"
@@ -828,9 +827,6 @@ static void gui_quit(void)
     atari_hotlist_destroy();
     atari_cookie_manager_destroy();
 
-    /* shutdown netsurf treeview framework: */
-    treeview_fini();
-
     /* shutdown the toolbar framework: */
     toolbar_exit();
 
@@ -1037,9 +1033,6 @@ static void gui_init(int argc, char** argv)
     }
     gemtk_wm_init();
 
-    /* Initialize the netsurf treeview framework with default font size: */
-    treeview_init(0);
-
     /* Initialize the specific treeview windows: */
     atari_global_history_init();
     atari_hotlist_init();
diff --git a/frontends/gtk/cookies.c b/frontends/gtk/cookies.c
index 3c5d93a..d0fae97 100644
--- a/frontends/gtk/cookies.c
+++ b/frontends/gtk/cookies.c
@@ -29,7 +29,6 @@
 #include "netsurf/keypress.h"
 #include "netsurf/plotters.h"
 #include "desktop/cookie_manager.h"
-#include "desktop/treeview.h"
 
 #include "gtk/cookies.h"
 #include "gtk/plotters.h"
@@ -247,11 +246,6 @@ static nserror nsgtk_cookies_init(void)
                return NSERROR_OK;
        }
 
-       res = treeview_init(0);
-       if (res != NSERROR_OK) {
-               return res;
-       }
-
        ncwin = malloc(sizeof(struct nsgtk_cookie_window));
        if (ncwin == NULL) {
                return NSERROR_NOMEM;
diff --git a/frontends/gtk/global_history.c b/frontends/gtk/global_history.c
index b41d06e..7d64705 100644
--- a/frontends/gtk/global_history.c
+++ b/frontends/gtk/global_history.c
@@ -30,7 +30,6 @@
 #include "netsurf/keypress.h"
 #include "netsurf/plotters.h"
 #include "desktop/global_history.h"
-#include "desktop/treeview.h"
 
 #include "gtk/compat.h"
 #include "gtk/plotters.h"
@@ -300,11 +299,6 @@ static nserror nsgtk_global_history_init(void)
                return NSERROR_OK;
        }
 
-       res = treeview_init(0);
-       if (res != NSERROR_OK) {
-               return res;
-       }
-
        ncwin = malloc(sizeof(struct nsgtk_global_history_window));
        if (ncwin == NULL) {
                return NSERROR_NOMEM;
diff --git a/frontends/gtk/hotlist.c b/frontends/gtk/hotlist.c
index 2d0641f..c47d1da 100644
--- a/frontends/gtk/hotlist.c
+++ b/frontends/gtk/hotlist.c
@@ -31,7 +31,6 @@
 #include "netsurf/keypress.h"
 #include "netsurf/plotters.h"
 #include "desktop/hotlist.h"
-#include "desktop/treeview.h"
 
 #include "gtk/compat.h"
 #include "gtk/plotters.h"
@@ -318,11 +317,6 @@ static nserror nsgtk_hotlist_init(void)
                return NSERROR_OK;
        }
 
-       res = treeview_init(0);
-       if (res != NSERROR_OK) {
-               return res;
-       }
-
        ncwin = malloc(sizeof(struct nsgtk_hotlist_window));
        if (ncwin == NULL) {
                return NSERROR_NOMEM;
diff --git a/frontends/gtk/ssl_cert.c b/frontends/gtk/ssl_cert.c
index 1cf0beb..8270b15 100644
--- a/frontends/gtk/ssl_cert.c
+++ b/frontends/gtk/ssl_cert.c
@@ -29,7 +29,6 @@
 #include "netsurf/keypress.h"
 #include "netsurf/plotters.h"
 #include "desktop/sslcert_viewer.h"
-#include "desktop/treeview.h"
 
 #include "gtk/plotters.h"
 #include "gtk/scaffolding.h"
@@ -177,11 +176,6 @@ nserror gtk_cert_verify(struct nsurl *url,
        struct nsgtk_crtvrfy_window *ncwin;
        nserror res;
 
-       res = treeview_init(0);
-       if (res != NSERROR_OK) {
-               return res;
-       }
-
        ncwin = malloc(sizeof(struct nsgtk_crtvrfy_window));
        if (ncwin == NULL) {
                return NSERROR_NOMEM;
diff --git a/frontends/riscos/gui.c b/frontends/riscos/gui.c
index 7c52164..9d5f6bb 100644
--- a/frontends/riscos/gui.c
+++ b/frontends/riscos/gui.c
@@ -55,7 +55,6 @@
 #include "netsurf/cookie_db.h"
 #include "netsurf/url_db.h"
 #include "desktop/save_complete.h"
-#include "desktop/treeview.h"
 #include "content/backing_store.h"
 
 #include "riscos/gui.h"
@@ -1227,11 +1226,6 @@ static nserror gui_init(int argc, char** argv)
                die(error->errmess);
        }
 
-       ret = treeview_init(12);
-       if (ret != NSERROR_OK) {
-               die("Failed to initialise treeview");
-       }
-
        /* Initialise themes before dialogs */
        ro_gui_theme_initialise();
 


-----------------------------------------------------------------------

Summary of changes:
 desktop/cookie_manager.c       |   10 ++++++++++
 desktop/global_history.c       |   10 ++++++++++
 desktop/hotlist.c              |   10 ++++++++++
 desktop/sslcert_viewer.c       |   10 ++++++++++
 desktop/tree.c                 |   10 ----------
 desktop/treeview.c             |   42 +++++++++++++++++++++++++++++-----------
 desktop/treeview.h             |    3 +--
 frontends/atari/gui.c          |    7 -------
 frontends/gtk/cookies.c        |    6 ------
 frontends/gtk/global_history.c |    6 ------
 frontends/gtk/hotlist.c        |    6 ------
 frontends/gtk/ssl_cert.c       |    6 ------
 frontends/riscos/gui.c         |    6 ------
 13 files changed, 72 insertions(+), 60 deletions(-)

diff --git a/desktop/cookie_manager.c b/desktop/cookie_manager.c
index 082a14a..b0c48a7 100644
--- a/desktop/cookie_manager.c
+++ b/desktop/cookie_manager.c
@@ -756,6 +756,11 @@ nserror cookie_manager_init(struct 
core_window_callback_table *cw_t,
 {
        nserror err;
 
+       err = treeview_init();
+       if (err != NSERROR_OK) {
+               return err;
+       }
+
        LOG("Generating cookie manager data");
 
        /* Init. cookie manager treeview entry fields */
@@ -822,6 +827,11 @@ nserror cookie_manager_fini(void)
                if (cm_ctx.values[i].value != NULL)
                        free((void *) cm_ctx.values[i].value);
 
+       err = treeview_fini();
+       if (err != NSERROR_OK) {
+               return err;
+       }
+
        LOG("Finalised cookie manager");
 
        return err;
diff --git a/desktop/global_history.c b/desktop/global_history.c
index d60874c..b6f4882 100644
--- a/desktop/global_history.c
+++ b/desktop/global_history.c
@@ -724,6 +724,11 @@ nserror global_history_init(struct 
core_window_callback_table *cw_t,
 {
        nserror err;
 
+       err = treeview_init();
+       if (err != NSERROR_OK) {
+               return err;
+       }
+
        LOG("Loading global history");
 
        /* Init. global history treeview time */
@@ -804,6 +809,11 @@ nserror global_history_fini(void)
                if (gh_ctx.fields[i].field != NULL)
                        lwc_string_unref(gh_ctx.fields[i].field);
 
+       err = treeview_fini();
+       if (err != NSERROR_OK) {
+               return err;
+       }
+
        LOG("Finalised global history");
 
        return err;
diff --git a/desktop/hotlist.c b/desktop/hotlist.c
index cce69be..e344b3b 100644
--- a/desktop/hotlist.c
+++ b/desktop/hotlist.c
@@ -1232,6 +1232,11 @@ nserror hotlist_init(struct core_window_callback_table 
*cw_t,
 {
        nserror err;
 
+       err = treeview_init();
+       if (err != NSERROR_OK) {
+               return err;
+       }
+
        LOG("Loading hotlist");
 
        hl_ctx.tree = NULL;
@@ -1298,6 +1303,11 @@ nserror hotlist_fini(const char *path)
                if (hl_ctx.fields[i].field != NULL)
                        lwc_string_unref(hl_ctx.fields[i].field);
 
+       err = treeview_fini();
+       if (err != NSERROR_OK) {
+               return err;
+       }
+
        LOG("Finalised hotlist");
 
        return err;
diff --git a/desktop/sslcert_viewer.c b/desktop/sslcert_viewer.c
index 93d6919..09a281c 100644
--- a/desktop/sslcert_viewer.c
+++ b/desktop/sslcert_viewer.c
@@ -353,6 +353,11 @@ nserror sslcert_viewer_init(struct 
core_window_callback_table *cw_t,
 
        assert(ssl_d != NULL);
 
+       err = treeview_init();
+       if (err != NSERROR_OK) {
+               return err;
+       }
+
        LOG("Building certificate viewer");
 
        /* Init. certificate chain treeview entry fields */
@@ -427,6 +432,11 @@ nserror sslcert_viewer_fini(struct sslcert_session_data 
*ssl_d)
        /* Destroy the sslcert_session_data */
        sslcert_cleanup_session(ssl_d);
 
+       err = treeview_fini();
+       if (err != NSERROR_OK) {
+               return err;
+       }
+
        LOG("Finalised ssl certificate viewer");
 
        return err;
diff --git a/desktop/tree.c b/desktop/tree.c
index bfe8e98..a5c97c3 100644
--- a/desktop/tree.c
+++ b/desktop/tree.c
@@ -55,7 +55,6 @@ struct tree {
 
 struct sslcert_session_data *ssl_current_session = NULL;
 const char *tree_hotlist_path = NULL;
-int treeview_inits;
 
 static void treeview_test_redraw_request(struct core_window *cw,
                const struct rect *r)
@@ -128,11 +127,6 @@ static bool treeview_test_init(struct tree *tree)
 {
        nserror err;
 
-       treeview_inits++;
-
-       if (treeview_inits == 1)
-               treeview_init(0);
-
        switch (tree->flags) {
        case TREE_COOKIES:
                assert(ssl_current_session == NULL &&
@@ -195,10 +189,6 @@ static bool treeview_test_fini(struct tree *tree)
                break;
        }
 
-       if (treeview_inits == 1)
-               treeview_fini();
-       treeview_inits--;
-
        return true;
 }
 
diff --git a/desktop/treeview.c b/desktop/treeview.c
index f2af5e8..5e4ceed 100644
--- a/desktop/treeview.c
+++ b/desktop/treeview.c
@@ -24,6 +24,7 @@
 
 #include "utils/log.h"
 #include "utils/nsurl.h"
+#include "utils/nsoption.h"
 #include "netsurf/bitmap.h"
 #include "netsurf/content.h"
 #include "netsurf/plotters.h"
@@ -44,7 +45,7 @@
 #define REDRAW_MAX 8000
 
 struct treeview_globals {
-       bool initialised;
+       unsigned initialised;
        int line_height;
        int furniture_width;
        int step_width;
@@ -3588,7 +3589,7 @@ static void treeview_init_plot_styles(int font_pt_size)
 
        /* Text colour */
        plot_style_even.text.family = PLOT_FONT_FAMILY_SANS_SERIF;
-       plot_style_even.text.size = font_pt_size * FONT_SIZE_SCALE;
+       plot_style_even.text.size = font_pt_size;
        plot_style_even.text.weight = 400;
        plot_style_even.text.flags = FONTF_NONE;
        plot_style_even.text.foreground = ns_system_colour_char("WindowText");
@@ -3948,23 +3949,33 @@ static nserror treeview_init_furniture(void)
 
 
 /* Exported interface, documented in treeview.h */
-nserror treeview_init(int font_pt_size)
+nserror treeview_init(void)
 {
-       int font_px_size;
+       long long font_px_size;
+       long long font_pt_size;
        nserror err;
 
-       if (tree_g.initialised == true)
+       if (tree_g.initialised > 0) {
+               tree_g.initialised++;
                return NSERROR_OK;
+       }
 
        LOG("Initialising treeview module");
 
-       if (font_pt_size <= 0)
-               font_pt_size = 11;
+       /* TODO: Should we add an extra `treeview_font_size` option for
+        *       treeviews instead of reusing the html rendering default
+        *       font size?
+        */
+       font_pt_size = nsoption_int(font_size);
+       if (font_pt_size <= 0) {
+               font_pt_size = 11 * 10;
+       }
 
-       font_px_size = (font_pt_size * FIXTOINT(nscss_screen_dpi) + 36) / 72;
+       font_px_size = (font_pt_size * FIXTOINT(nscss_screen_dpi) /
+                       10 + 36) / 72;
        tree_g.line_height = (font_px_size * 8 + 3) / 6;
 
-       treeview_init_plot_styles(font_pt_size);
+       treeview_init_plot_styles(font_pt_size * FONT_SIZE_SCALE / 10);
        treeview_init_resources();
        err = treeview_init_furniture();
        if (err != NSERROR_OK)
@@ -3976,7 +3987,7 @@ nserror treeview_init(int font_pt_size)
        tree_g.icon_step = 23;
        tree_g.move_offset = 18;
 
-       tree_g.initialised = true;
+       tree_g.initialised++;
 
        LOG("Initialised treeview module");
 
@@ -3989,6 +4000,15 @@ nserror treeview_fini(void)
 {
        int i;
 
+       if (tree_g.initialised > 1) {
+               tree_g.initialised--;
+               return NSERROR_OK;
+
+       } else if (tree_g.initialised == 0) {
+               LOG("Warning: tried to finalise uninitialised treeview module");
+               return NSERROR_OK;
+       }
+
        LOG("Finalising treeview module");
 
        for (i = 0; i < TREE_RES_LAST; i++) {
@@ -4004,7 +4024,7 @@ nserror treeview_fini(void)
        guit->bitmap->destroy(plot_style_even.furn[TREE_FURN_CONTRACT].bmp);
        guit->bitmap->destroy(plot_style_even.furn[TREE_FURN_CONTRACT].sel);
 
-       tree_g.initialised = false;
+       tree_g.initialised--;
 
        LOG("Finalised treeview module");
 
diff --git a/desktop/treeview.h b/desktop/treeview.h
index 25349ad..abe0e56 100644
--- a/desktop/treeview.h
+++ b/desktop/treeview.h
@@ -112,10 +112,9 @@ struct treeview_callback_table {
 /**
  * Prepare treeview module for treeview usage
  *
- * \param font_pt_size Treeview text size in pt.  Set to <= 0 for default.
  * \return NSERROR_OK on success, appropriate error otherwise
  */
-nserror treeview_init(int font_pt_size);
+nserror treeview_init(void);
 
 /**
  * Finalise the treeview module (all treeviews must have been destroyed first)
diff --git a/frontends/atari/gui.c b/frontends/atari/gui.c
index eb15777..1cf51d3 100644
--- a/frontends/atari/gui.c
+++ b/frontends/atari/gui.c
@@ -40,7 +40,6 @@
 #include "netsurf/cookie_db.h"
 #include "netsurf/url_db.h"
 #include "content/backing_store.h"
-#include "desktop/treeview.h"
 
 #include "atari/gemtk/gemtk.h"
 #include "atari/gui.h"
@@ -828,9 +827,6 @@ static void gui_quit(void)
     atari_hotlist_destroy();
     atari_cookie_manager_destroy();
 
-    /* shutdown netsurf treeview framework: */
-    treeview_fini();
-
     /* shutdown the toolbar framework: */
     toolbar_exit();
 
@@ -1037,9 +1033,6 @@ static void gui_init(int argc, char** argv)
     }
     gemtk_wm_init();
 
-    /* Initialize the netsurf treeview framework with default font size: */
-    treeview_init(0);
-
     /* Initialize the specific treeview windows: */
     atari_global_history_init();
     atari_hotlist_init();
diff --git a/frontends/gtk/cookies.c b/frontends/gtk/cookies.c
index 3c5d93a..d0fae97 100644
--- a/frontends/gtk/cookies.c
+++ b/frontends/gtk/cookies.c
@@ -29,7 +29,6 @@
 #include "netsurf/keypress.h"
 #include "netsurf/plotters.h"
 #include "desktop/cookie_manager.h"
-#include "desktop/treeview.h"
 
 #include "gtk/cookies.h"
 #include "gtk/plotters.h"
@@ -247,11 +246,6 @@ static nserror nsgtk_cookies_init(void)
                return NSERROR_OK;
        }
 
-       res = treeview_init(0);
-       if (res != NSERROR_OK) {
-               return res;
-       }
-
        ncwin = malloc(sizeof(struct nsgtk_cookie_window));
        if (ncwin == NULL) {
                return NSERROR_NOMEM;
diff --git a/frontends/gtk/global_history.c b/frontends/gtk/global_history.c
index b41d06e..7d64705 100644
--- a/frontends/gtk/global_history.c
+++ b/frontends/gtk/global_history.c
@@ -30,7 +30,6 @@
 #include "netsurf/keypress.h"
 #include "netsurf/plotters.h"
 #include "desktop/global_history.h"
-#include "desktop/treeview.h"
 
 #include "gtk/compat.h"
 #include "gtk/plotters.h"
@@ -300,11 +299,6 @@ static nserror nsgtk_global_history_init(void)
                return NSERROR_OK;
        }
 
-       res = treeview_init(0);
-       if (res != NSERROR_OK) {
-               return res;
-       }
-
        ncwin = malloc(sizeof(struct nsgtk_global_history_window));
        if (ncwin == NULL) {
                return NSERROR_NOMEM;
diff --git a/frontends/gtk/hotlist.c b/frontends/gtk/hotlist.c
index 2d0641f..c47d1da 100644
--- a/frontends/gtk/hotlist.c
+++ b/frontends/gtk/hotlist.c
@@ -31,7 +31,6 @@
 #include "netsurf/keypress.h"
 #include "netsurf/plotters.h"
 #include "desktop/hotlist.h"
-#include "desktop/treeview.h"
 
 #include "gtk/compat.h"
 #include "gtk/plotters.h"
@@ -318,11 +317,6 @@ static nserror nsgtk_hotlist_init(void)
                return NSERROR_OK;
        }
 
-       res = treeview_init(0);
-       if (res != NSERROR_OK) {
-               return res;
-       }
-
        ncwin = malloc(sizeof(struct nsgtk_hotlist_window));
        if (ncwin == NULL) {
                return NSERROR_NOMEM;
diff --git a/frontends/gtk/ssl_cert.c b/frontends/gtk/ssl_cert.c
index 1cf0beb..8270b15 100644
--- a/frontends/gtk/ssl_cert.c
+++ b/frontends/gtk/ssl_cert.c
@@ -29,7 +29,6 @@
 #include "netsurf/keypress.h"
 #include "netsurf/plotters.h"
 #include "desktop/sslcert_viewer.h"
-#include "desktop/treeview.h"
 
 #include "gtk/plotters.h"
 #include "gtk/scaffolding.h"
@@ -177,11 +176,6 @@ nserror gtk_cert_verify(struct nsurl *url,
        struct nsgtk_crtvrfy_window *ncwin;
        nserror res;
 
-       res = treeview_init(0);
-       if (res != NSERROR_OK) {
-               return res;
-       }
-
        ncwin = malloc(sizeof(struct nsgtk_crtvrfy_window));
        if (ncwin == NULL) {
                return NSERROR_NOMEM;
diff --git a/frontends/riscos/gui.c b/frontends/riscos/gui.c
index 7c52164..9d5f6bb 100644
--- a/frontends/riscos/gui.c
+++ b/frontends/riscos/gui.c
@@ -55,7 +55,6 @@
 #include "netsurf/cookie_db.h"
 #include "netsurf/url_db.h"
 #include "desktop/save_complete.h"
-#include "desktop/treeview.h"
 #include "content/backing_store.h"
 
 #include "riscos/gui.h"
@@ -1227,11 +1226,6 @@ static nserror gui_init(int argc, char** argv)
                die(error->errmess);
        }
 
-       ret = treeview_init(12);
-       if (ret != NSERROR_OK) {
-               die("Failed to initialise treeview");
-       }
-
        /* Initialise themes before dialogs */
        ro_gui_theme_initialise();
 


-- 
NetSurf Browser

_______________________________________________
netsurf-commits mailing list
[email protected]
http://listmaster.pepperfish.net/cgi-bin/mailman/listinfo/netsurf-commits-netsurf-browser.org

Reply via email to