[haiku-commits] Re: r35715 - haiku/trunk/src/kits/tracker

  • From: Bruno Albuquerque <bga@xxxxxxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Mon, 1 Mar 2010 23:19:16 -0300

I fully agree. As I told you, I think doing that for text file drags
look like bad behavior to me as, most of the time, you will be just
copying files, not adding them as a clipping. Changing BTextView (and
whatever else may need this feature) to read the file directly seems
like the way to go.


2010/3/1, anevilyak@xxxxxxxxx <anevilyak@xxxxxxxxx>:
> Author: anevilyak
> Date: 2010-03-02 01:51:17 +0100 (Tue, 02 Mar 2010)
> New Revision: 35715
> Changeset: http://dev.haiku-os.org/changeset/35715/haiku
>
> Modified:
>    haiku/trunk/src/kits/tracker/PoseView.cpp
> Log:
> Add an extra sanity check to Tracker's automatic text clipping extraction
> when
> drag and dropping text files: before it would blindly read the entirety of
> the
> file's text contents regardless of size, which probably led to more than a
> few
> nasty surprises when someone attempted to drag very large (i.e.
> multimegabyte)
> text files. We now clamp the amount of data we read to 64KB. Though it's
> debatable if this feature is at all useful, since it may potentially be
> better
> implemented by handling entry_refs in dropped messages in BTextView directly
> (assuming a compatible type). Opinions welcome.
>
>
>
> Modified: haiku/trunk/src/kits/tracker/PoseView.cpp
> ===================================================================
> --- haiku/trunk/src/kits/tracker/PoseView.cpp 2010-03-01 22:40:33 UTC (rev
> 35714)
> +++ haiku/trunk/src/kits/tracker/PoseView.cpp 2010-03-02 00:51:17 UTC (rev
> 35715)
> @@ -103,6 +103,7 @@
>  const uint32 kAddNewPoses = 'Tanp';
>  const uint32 kAddPosesCompleted = 'Tapc';
>  const int32 kMaxAddPosesChunk = 50;
> +const uint32 kMaxTextClippingSize = 64 * 1024;
>
>  namespace BPrivate {
>  extern bool delete_point(void *);
> @@ -6736,6 +6737,9 @@
>                               off_t size = 0;
>                               file.GetSize(&size);
>                               if (size) {
> +                                     // clamp the amount of text we extract 
> in order to avoid very
> unpleasant surprises if, say, the user
> +                                     // happens to have a 100MB plain text 
> file they want to drag around.
> +                                     size = min(size, 
> (off_t)kMaxTextClippingSize);
>                                       char *buffer = new char[size];
>                                       if (file.Read(buffer, (size_t)size) == 
> size) {
>                                               
> message.AddData(kPlainTextMimeType, B_MIME_TYPE, buffer,
> (ssize_t)size);
> @@ -6758,7 +6762,7 @@
>                                       delete [] buffer;
>                               }
>                       } else if (strcasecmp(type, kBitmapMimeType) == 0
> -                             // got a text file
> +                             // got a raw bitmap clipping file
>                               && file.ReadAttr(kAttrClippingFile, B_RAW_TYPE, 
> 0,
>                                       &tmp, sizeof(int32)) == sizeof(int32)) {
>                               file.Seek(0, SEEK_SET);
>
>
>

Other related posts: