[haiku-commits] r40778 - haiku/trunk/src/apps/people

  • From: philippe.houdoin@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Wed, 2 Mar 2011 16:28:09 +0100 (CET)

Author: phoudoin
Date: 2011-03-02 16:28:09 +0100 (Wed, 02 Mar 2011)
New Revision: 40778
Changeset: http://dev.haiku-os.org/changeset/40778

Modified:
   haiku/trunk/src/apps/people/PictureView.cpp
Log:
* Check data size before trying to translate it into a picture image
* Remove leftover debug traces


Modified: haiku/trunk/src/apps/people/PictureView.cpp
===================================================================
--- haiku/trunk/src/apps/people/PictureView.cpp 2011-03-02 15:08:26 UTC (rev 
40777)
+++ haiku/trunk/src/apps/people/PictureView.cpp 2011-03-02 15:28:09 UTC (rev 
40778)
@@ -458,9 +458,6 @@
 void
 PictureView::_HandleDrop(BMessage* msg)
 {
-       printf("PictureControl::_HandleDrop(): \n");
-       msg->PrintToStream();
-
        entry_ref dirRef;
        BString name, type;
        bool saveToFile = msg->FindString("be:filetypes", &type) == B_OK
@@ -483,7 +480,7 @@
 
        BBitmapStream stream(bitmap);
 
-       // find transaltion format asked for
+       // find translation format we're asked for
        translator_info* outInfo;
        int32 outNumInfo;
        bool found = false;
@@ -543,7 +540,7 @@
                }
        }
 
-       // Detach, as we don't want our picture to be deleted
+       // Detach, as we don't want our fPicture to be deleted
        stream.DetachBitmap(&bitmap);
 }
 
@@ -556,6 +553,15 @@
        if (status != B_OK)
                return status;
 
+       off_t fileSize;
+       status = file.GetSize(&fileSize);
+       if (status != B_OK)
+               return status;
+
+       // Check that we've at least some data to translate...
+       if (fileSize < 1)
+               return B_OK;
+
        translator_info info;
        memset(&info, 0, sizeof(translator_info));
        BMessage ioExtension;
@@ -583,7 +589,7 @@
        if (picture == NULL)
                return B_ERROR;
 
-       // Remember image format so we store using same
+       // Remember image format so we could store using the same
        fPictureMIMEType = info.MIME;
        fPictureType = info.type;
 


Other related posts:

  • » [haiku-commits] r40778 - haiku/trunk/src/apps/people - philippe . houdoin