|Please ignore the patch I submitted early. This is better.

Two years on since the bug was reported :-(
Is there anything else I might do to help progress this?

Regards,
Peter
|
Origin: Mateusz Balbus
Reviewed-by: Peter Blackman
Description: Fix crash (x86_64) when clicking in left hand results pain
Bug-Debian: http://bugs.debian.org/625643
Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/searchmonkey/+bug/178701
Last-Update: 2013-05-20
Index: src/savestate.c
===================================================================
--- searchmonkey-0.8.1.orig/src/savestate.c	
+++ searchmonkey-0.8.1.orig/src/savestate.c	
@@ -28,7 +28,7 @@
 extern GtkWidget *mainWindowApp; /* Holds pointer to the main searchmonkey GUI. Declared in main.c */
 extern GStaticMutex mutex_Data; /* Created in search.c to control access to search results data. */
 extern GStaticMutex mutex_Control; /* Created in search.c to control access to search controls. */
-
+extern gchar *gDirectory; /* Crated in main.c to store directory argument from command line */
 /**************************************************************
  *    Keyfile interface commands
  **************************************************************/
@@ -210,13 +210,21 @@
 
   tmpCombo = GTK_COMBO_BOX(lookup_widget(widget, "lookIn"));
   g_assert(tmpCombo != NULL);
-  if (gtk_tree_model_get_iter_first(gtk_combo_box_get_model(tmpCombo), &iter) == FALSE) {
+
+  // add row from command line
+  if (gDirectory != NULL) {
+      addUniqueRow(GTK_WIDGET(tmpCombo), gDirectory);
+  } else if (gtk_tree_model_get_iter_first(gtk_combo_box_get_model(tmpCombo), &iter) == FALSE) {
     addUniqueRow(GTK_WIDGET(tmpCombo), g_get_home_dir()); /* Set default look in folder */
   }
   
   tmpCombo = GTK_COMBO_BOX(lookup_widget(widget, "lookIn2"));
   g_assert(tmpCombo != NULL);
-  if (gtk_tree_model_get_iter_first(gtk_combo_box_get_model(tmpCombo), &iter) == FALSE) {
+
+  // add row from command line
+  if (gDirectory != NULL) {
+      addUniqueRow(GTK_WIDGET(tmpCombo), gDirectory);
+  } else if (gtk_tree_model_get_iter_first(gtk_combo_box_get_model(tmpCombo), &iter) == FALSE) {
     addUniqueRow(GTK_WIDGET(tmpCombo), g_get_home_dir()); /* Set default look in folder */
   }
   
@@ -1427,7 +1435,7 @@
   gchar *tmpString2;
   GtkTextIter txtIter, tmpIter;
   GtkTextIter start, end;
-  gsize count, tmpCount;
+  gsize count = 0, tmpCount;
   guint matchIndex;
   gint i = 0; 
   gint lineCount = 2; /* Heading, plus options (i.e. 2-lines) */
Index: src/main.c
===================================================================
--- searchmonkey-0.8.1.orig/src/main.c	
+++ searchmonkey-0.8.1.orig/src/main.c	
@@ -20,7 +20,14 @@
 
 GtkWidget *mainWindowApp = NULL; /* Holds pointer to the main window (global) */
 gchar *gConfigFile = NULL; /* created by main(), destroyed by destroyGKeyFile() */
+gchar *gDirectory = NULL; /* directory parameter from command line */
 
+/* Command line arguments */
+static GOptionEntry entries[] =
+{
+  { "directory", 'd', 0, G_OPTION_ARG_FILENAME, &gDirectory, "Path do search directory", "DIRECTORY" },
+  { NULL }
+};
 /*
  * Searchmonkey entry point
  */
@@ -28,12 +35,9 @@
 {
   GdkPixbuf* pixBuf;
   gchar *tmpStr;
+  GOptionContext *context;
+  GError *error = NULL;
   
-  /* Initiate threads */
-  g_thread_init (NULL);
-  gdk_threads_init ();
-  gdk_threads_enter ();
-  
 #ifdef ENABLE_NLS
   bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
   bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
@@ -42,8 +46,18 @@
 
   /* Handle GTK command line options and the locale settings */
   gtk_set_locale ();
-  gtk_init (&argc, &argv);
 
+  // parse arguments
+  context = g_option_context_new ("- search files using regular expressions aiming to replace find/grep tools\n");
+  g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
+  g_option_context_add_group (context, gtk_get_option_group (TRUE));
+  g_option_context_parse (context, &argc, &argv, &error);
+
+  /* Initiate threads */
+  g_thread_init (NULL);
+  gdk_threads_init ();
+  gdk_threads_enter ();
+
   /* Create main window, and load (create) ini config file */
   add_pixmap_directory (PACKAGE_DATA_DIR "/pixmaps/" PACKAGE); /* New location for all pixmaps */
   add_pixmap_directory (PACKAGE_DATA_DIR "/pixmaps"); /* Gnome users /usr/share/pixmaps folder */

Reply via email to