gnome-system-monitor r2377 - trunk/src



Author: bdejean
Date: Sat Apr  5 17:50:41 2008
New Revision: 2377
URL: http://svn.gnome.org/viewvc/gnome-system-monitor?rev=2377&view=rev

Log:
Display an error message on invalid regex.


Modified:
   trunk/src/lsof.cpp

Modified: trunk/src/lsof.cpp
==============================================================================
--- trunk/src/lsof.cpp	(original)
+++ trunk/src/lsof.cpp	Sat Apr  5 17:50:41 2008
@@ -118,6 +118,12 @@
     }
 
 
+    void display_regex_error()
+    {
+      gtk_label_set_text(this->count, _("Invalid Perl regular expression"));
+    }
+
+
     void update_count(unsigned count)
     {
       string s = static_cast<std::ostringstream&>(std::ostringstream() << count).str();
@@ -138,11 +144,12 @@
 
       this->clear_results();
 
-      unsigned count = 0;
 
       try {
 	Lsof lsof(this->pattern(), this->case_insensitive);
 
+	unsigned count = 0;
+
 	for (ProcInfo::Iterator it(ProcInfo::begin()); it != ProcInfo::end(); ++it) {
 	  const ProcInfo &info(*it->second);
 
@@ -161,14 +168,15 @@
 			       -1);
 	  }
 	}
+
+	this->update_count(count);
       }
       catch (Glib::RegexError& error) {
 	procman_debug("Regex error with pattern '%s' : %s",
 		      this->pattern().c_str(),
 		      error.what().c_str());
+	this->display_regex_error();
       }
-
-      this->update_count(count);
     }
 
 



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