[CELayoutEditorII] Potential crash upon startup

If you found a bug in our library or on our website, please report it in this section. In this forum you can also make concrete suggestions or feature requests.

Moderators: CEGUI MVP, CEGUI Team

IrmatDen
Not too shy to talk
Not too shy to talk
Posts: 26
Joined: Sat Feb 26, 2011 08:04

[CELayoutEditorII] Potential crash upon startup

Postby IrmatDen » Mon Mar 07, 2011 15:34

Hi all,

When loading CELayoutEditorII with a non-existing BG image saved when last quitting the app (like, after renaming mybg.png to mybackground.png), CELayoutEditorII will crash upon startup due to this check in CEGUIOutputWidget.setBackgroundImage (qtwidgets.py):

Code: Select all

            if image.isNull():
                raise IOError("Failed to create QImage from %s" % filename)


If someone has the same issue and need a quick fix, here's a trivial candidate (which may be improved by asking the user for another image to use):

Code: Select all

    def setBackgroundImage(self, filename):
        if filename:
            image = QImage(filename)

            if image.isNull():
                QMessageBox.warning(self, "CELayoutEditorII", "Can't load background image: " + filename)

        self._unloadBackgroundImage()

        if filename and not image.isNull():
            self._bkImageTexture = self.bindTexture(image)
            self._bkImageFilename = filename


Relevant Hg shelve:

Code: Select all

diff --git a/layouteditor/qtwidgets.py b/layouteditor/qtwidgets.py
--- a/layouteditor/qtwidgets.py
+++ b/layouteditor/qtwidgets.py
@@ -387,7 +387,7 @@
             image = QImage(filename)
 
             if image.isNull():
-                raise IOError("Failed to create QImage from %s" % filename)
+                QMessageBox.warning(self, "CELayoutEditorII", "Can't load background image: " + filename)
 
         self._unloadBackgroundImage()
 

Return to “Bug Reports, Suggestions, Feature Requests”

Who is online

Users browsing this forum: No registered users and 3 guests