[gtkmm] last-minute API decision



Hi,

currently the following Gtk::TextBuffer methods are broken API wise:

   iterator insert_interactive(...); // all 4 overloads
   iterator erase_interactive(...);

The parameter lists aren't interesting in this context, thus I omitted
them for clarity.

The problem is as follows:  These methods are currently defined to
return the end() iterator if the insertion/erasure fails (which can
happen due to the operation being interactive), otherwise iterators
pointing after the inserted/erased range are returned (just as the STL
does).  Unfortunately it is possible that the action was successful and
end() is returned, i.e. when inserting the empty string at the end or
erasing a range that reaches till end().

While the insert case could be quite easily worked around by the
programmer, it's not that easy (or clean) for erase_interactive().  GTK+
doesn't have the problem because it returns a bool (true on success) and
modifies the iterator input parameter.  So my proposal is to fix it like
this:

  std::pair<iterator,bool> insert_interactive(...);
  std::pair<iterator,bool> erase_interactive(...);

These methods probably aren't used often so the API change shouldn't be
a problem.  But if they're used they should work.  If you've a better
idea how to solve this please send in your comments now.

Cheers,
--Daniel





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