gui: Speed up initial file load with many columns
authorBen Pfaff <blp@cs.stanford.edu>
Sat, 12 Nov 2011 23:06:23 +0000 (15:06 -0800)
committerBen Pfaff <blp@cs.stanford.edu>
Tue, 26 Jun 2012 03:27:09 +0000 (20:27 -0700)
This makes a huge difference in startup time when there are hundreds of
columns, by setting up the data sheet before showing the window that
contains it.

Files opened from File|Open were already opened this way.  I was a little
surprised that File|Open was so much faster than specifying a file on the
command line until I figured out the difference.

src/ui/gui/psppire.c

index be095248a940cdbb6b37befc651f88ec19158b22..8bd6b6fe5e737368ea02191a6088dc3a1dd3d148 100644 (file)
@@ -1,5 +1,5 @@
 /* PSPPIRE - a graphical user interface for PSPP.
-   Copyright (C) 2004, 2005, 2006, 2009, 2010, 2011  Free Software Foundation
+   Copyright (C) 2004, 2005, 2006, 2009, 2010, 2011, 2012  Free Software Foundation
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -74,8 +74,6 @@ static gchar *local_to_filename_encoding (const char *fn);
 void
 initialize (const char *data_file)
 {
-  PsppireDataWindow *data_window;
-
   i18n_init ();
 
   preregister_widgets ();
@@ -100,8 +98,6 @@ initialize (const char *data_file)
   psppire_selector_set_default_selection_func (PSPPIRE_VAR_VIEW_TYPE, insert_source_row_into_tree_view);
   psppire_selector_set_default_selection_func (GTK_TYPE_TREE_VIEW, insert_source_row_into_tree_view);
 
-  data_window = psppire_default_data_window ();
-
   if (data_file)
     {
       gchar *filename = local_to_filename_encoding (data_file);
@@ -109,12 +105,17 @@ initialize (const char *data_file)
       /* Check to see if the file is a .sav or a .por file.  If not
          assume that it is a syntax file */
       if ( any_reader_may_open (filename))
-        psppire_window_load (PSPPIRE_WINDOW (data_window), filename);
+        open_data_window (NULL, filename);
       else
-        open_syntax_window (filename, NULL);
+        {
+          create_data_window ();
+          open_syntax_window (filename, NULL);
+        }
 
       g_free (filename);
     }
+  else
+    create_data_window ();
 }