gtkmm r1127 - in trunk: . gtk/src



Author: daniel
Date: Thu Mar 26 14:02:32 2009
New Revision: 1127
URL: http://svn.gnome.org/viewvc/gtkmm?rev=1127&view=rev

Log:
Warning fixes and spring cleaning

* gtk/src/messagedialog.ccg (MessageDialog::set_secondary_text):
Fix nasty security hole discovered by GCC:  A non-literal was
used as a varargs format string.
* gtk/src/notebook.ccg: Spring cleaning.
(PageList::find): Fix broken loop end condition discovered by
GCC.  Replace the whole thing by std::advance().
* gtk/src/calendar.ccg (SignalProxy_Details_gtk_callback): Remove
model argument name to avoid a warning.  Also do a bit of spring
cleaning.


Modified:
   trunk/ChangeLog
   trunk/gtk/src/calendar.ccg
   trunk/gtk/src/messagedialog.ccg
   trunk/gtk/src/notebook.ccg

Modified: trunk/gtk/src/calendar.ccg
==============================================================================
--- trunk/gtk/src/calendar.ccg	(original)
+++ trunk/gtk/src/calendar.ccg	Thu Mar 26 14:02:32 2009
@@ -22,26 +22,29 @@
 
 #include <gtk/gtk.h>
 
-
-static gchar* SignalProxy_Details_gtk_callback(GtkCalendar* model, guint year, guint month, guint day, gpointer user_data)
+namespace
+{
+extern "C"
+{
+static gchar* SignalProxy_Details_gtk_callback(GtkCalendar*, guint year, guint month, guint day,
+                                               gpointer user_data)
 {
   Gtk::Calendar::SlotDetails* the_slot = static_cast<Gtk::Calendar::SlotDetails*>(user_data);
 
-  #ifdef GLIBMM_EXCEPTIONS_ENABLED
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
   try
+#endif
   {
-  #endif //GLIBMM_EXCEPTIONS_ENABLED
     const Glib::ustring temp = (*the_slot)(year, month, day);
     return g_strdup(temp.c_str()); //Freed by GtkCalendar.
-  #ifdef GLIBMM_EXCEPTIONS_ENABLED
   }
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
   catch(...)
   {
     Glib::exception_handlers_invoke();
   }
-
   return 0; // arbitrary value
-  #endif //GLIBMM_EXCEPTIONS_ENABLED
+#endif
 }
 
 static void SignalProxy_Details_gtk_callback_destroy(void* data)
@@ -49,6 +52,9 @@
   delete static_cast<Gtk::Calendar::SlotDetails*>(data);
 }
 
+} // extern "C"
+} // anonymous namespace
+
 namespace Gtk
 {
 

Modified: trunk/gtk/src/messagedialog.ccg
==============================================================================
--- trunk/gtk/src/messagedialog.ccg	(original)
+++ trunk/gtk/src/messagedialog.ccg	Thu Mar 26 14:02:32 2009
@@ -61,9 +61,9 @@
 void MessageDialog::set_secondary_text(const Glib::ustring& text, bool use_markup)
 {
   if(use_markup)
-    gtk_message_dialog_format_secondary_markup(gobj(), text.c_str());
+    gtk_message_dialog_format_secondary_markup(gobj(), "%s", text.c_str());
   else
-    gtk_message_dialog_format_secondary_text(gobj(), text.c_str());
+    gtk_message_dialog_format_secondary_text(gobj(), "%s", text.c_str());
 }
 
 } // namespace Gtk

Modified: trunk/gtk/src/notebook.ccg
==============================================================================
--- trunk/gtk/src/notebook.ccg	(original)
+++ trunk/gtk/src/notebook.ccg	Thu Mar 26 14:02:32 2009
@@ -20,39 +20,39 @@
 
 #include <gtk/gtk.h>
 #include <gtkmm/label.h>
+#include <algorithm>
 
-//We use a function instead of a static method, so we can make it static, so it is not exported.
-static GtkNotebook* SignalProxy_WindowCreation_gtk_callback(GtkNotebook* /* source */, GtkWidget* page, gint x, gint y, gpointer data)
+namespace
 {
-  Gtk::Notebook::SlotWindowCreation* the_slot = static_cast<Gtk::Notebook::SlotWindowCreation*>(data);
-
-  #ifdef GLIBMM_EXCEPTIONS_ENABLED
+extern "C"
+{
+static GtkNotebook* SignalProxy_WindowCreation_gtk_callback(GtkNotebook*, GtkWidget* page,
+                                                            int x, int y, void* data)
+{
+  Gtk::Notebook::SlotWindowCreation *const
+    slot = *static_cast<Gtk::Notebook::SlotWindowCreation*>(data);
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
   try
+#endif
   {
-  #endif //GLIBMM_EXCEPTIONS_ENABLED
-    Gtk::Widget* pCppPage = Glib::wrap(page);
-
-    Gtk::Notebook* pCppNotebookResult = (*the_slot)(pCppPage, x, y);
-    if(pCppNotebookResult)
-      return pCppNotebookResult->gobj();
-    else
-      return 0;
-  #ifdef GLIBMM_EXCEPTIONS_ENABLED
+    return Glib::unwrap((*slot)(Glib::wrap(page), x, y));
   }
-  catch(...)
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+  catch (...)
   {
     Glib::exception_handlers_invoke();
-    return 0;
   }
-  #endif //GLIBMM_EXCEPTIONS_ENABLED
+  return 0;
+#endif
 }
 
 static void SignalProxy_WindowCreation_gtk_callback_destroy(void* data)
 {
-  Gtk::Notebook::SlotWindowCreation* the_slot = static_cast<Gtk::Notebook::SlotWindowCreation*>(data);
-  delete the_slot;
+  delete static_cast<Gtk::Notebook::SlotWindowCreation*>(data);
 }
 
+} // extern "C"
+} // anonymous namespace
 
 namespace Gtk
 {
@@ -83,24 +83,20 @@
 const PageIterator PageIterator::operator++(int)
 {
   const PageIterator tmp (*this);
-  this->operator++();
+  ++*this;
   return tmp;
 }
 
 PageIterator& PageIterator::operator--()
 {
-  if(node_)
-    node_ = node_->prev;
-  else
-    node_ = g_list_last(parent_->gobj()->children);
-
+  node_ = (node_) ? node_->prev : g_list_last(parent_->gobj()->children);
   return *this;
 }
 
 const PageIterator PageIterator::operator--(int)
 {
   const PageIterator tmp (*this);
-  this->operator--();
+  --*this;
   return tmp;
 }
 
@@ -183,9 +179,9 @@
 {}
 
 PageList::PageList(const PageList& src)
-{
-  operator=(src);
-}
+:
+  gparent_ (gparent)
+{}
 
 PageList& PageList::operator=(const PageList& src)
 {
@@ -215,8 +211,7 @@
 
 PageList::value_type PageList::back() const
 {
-  iterator pend (end());
-  return *--pend;
+  return *--end();
 }
 
 PageList::value_type PageList::operator[](size_type index) const
@@ -280,24 +275,26 @@
 
 PageList::iterator PageList::find(int num)
 {
-  if(num < 0) return end();
-  int j = 0;
-  iterator i;
-  for(i = begin(), j = 0; i != end(), j < num; ++i, ++j);
+  if (num < 0)
+    return end();
+  iterator i = begin();
+  std::advance(i, num);
   return i;
 }
 
 PageList::iterator PageList::find(const_reference c)
 {
   iterator i = begin();
-  for(i = begin(); i != end() && ((*i).get_child() != c.get_child()); i++);
+  while (i != end() && ((*i).get_child() != c.get_child()))
+    ++i;
   return i;
 }
 
 PageList::iterator PageList::find(Widget& widget)
 {
-  iterator i;
-  for(i = begin(); i != end() && ((*i).get_child() != &widget); i++);
+  iterator i = begin();
+  while (i != end() && ((*i).get_child() != &widget))
+    ++i;
   return i;
 }
 



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