OSDN Git Service

Prevent inserting an image which is zero bytes.
authorRandy Baumgarte <randy@fbn.cx>
Fri, 8 Oct 2010 13:29:33 +0000 (09:29 -0400)
committerRandy Baumgarte <randy@fbn.cx>
Sun, 10 Oct 2010 14:04:26 +0000 (10:04 -0400)
src/cx/fbn/nevernote/gui/BrowserWindow.java

index e9005dd..d8f4857 100644 (file)
@@ -984,6 +984,7 @@ public class BrowserWindow extends QWidget {
 \r
                if (mime.hasImage()) {\r
                        logger.log(logger.EXTREME, "Image paste found");\r
+                       browser.setFocus();\r
                        insertImage(mime);\r
                        browser.setFocus();\r
                        return;\r
@@ -1681,7 +1682,10 @@ public class BrowserWindow extends QWidget {
                // Open the file & write the data\r
                QFile tfile = new QFile(path);\r
                tfile.open(new QIODevice.OpenMode(QIODevice.OpenModeFlag.WriteOnly));\r
-               img.save(tfile);\r
+               if (!img.save(tfile)) {\r
+                       tfile.close();\r
+                       return;\r
+               }\r
                tfile.close();\r
                \r
                Resource newRes = createResource(QUrl.fromLocalFile(path).toString(), 0, "image/jpeg", false);\r