loader: Check for success on return from driver for create object calls
authorJon Ashburn <jon@lunarg.com>
Fri, 9 Jan 2015 17:13:48 +0000 (10:13 -0700)
committerCourtney Goeltzenleuchter <courtney@LunarG.com>
Thu, 5 Feb 2015 00:58:04 +0000 (17:58 -0700)
Allows errors from driver that prevented driver from creating object to
return to the app.

xgl-generate.py

index 75a22313725115b8345eac54f24405902905c593..513438c7da7e365420c50d6d36491ad2134db78f 100755 (executable)
@@ -130,26 +130,28 @@ class LoaderEntrypointsSubcommand(Subcommand):
                          "            (const XGL_LAYER_DISPATCH_TABLE **) wrapped_obj->baseObject;\n"
                          "    %s = wrapped_obj->nextObject;\n"
                          "    XGL_RESULT res = %s;\n"
-                         "    *(const XGL_LAYER_DISPATCH_TABLE **) (*%s) = *disp;\n"
+                         "    if (res == XGL_SUCCESS)\n"
+                         "        *(const XGL_LAYER_DISPATCH_TABLE **) (*%s) = *disp;\n"
                          "    return res;\n"
                          "}" % (qual, decl, proto.params[0].name, proto.params[1].name,
                                 proto.params[0].name, proto.params[0].name, stmt,
                                 proto.params[-1].name))
             elif self._does_function_create_object(proto):
+                if proto.name == "WsiX11CreatePresentableImage":
+                    obj_write_stmt = "\n        *(const XGL_LAYER_DISPATCH_TABLE **) (*%s) = *disp;" % (  proto.params[-2].name)
+                else:
+                    obj_write_stmt = ""
                 funcs.append("%s%s\n"
                          "{\n"
                          "    const XGL_LAYER_DISPATCH_TABLE **disp =\n"
                          "        (const XGL_LAYER_DISPATCH_TABLE **) %s;\n"
                          "    XGL_RESULT res = %s;\n"
-                         % (qual, decl, proto.params[0].name, stmt))
-                if proto.name == "WsiX11CreatePresentableImage":
-                    funcs.append(
-                         "    *(const XGL_LAYER_DISPATCH_TABLE **) (*%s) = *disp;\n"
-                         % (  proto.params[-2].name))
-                funcs.append(
-                         "    *(const XGL_LAYER_DISPATCH_TABLE **) (*%s) = *disp;\n"
+                         "    if (res == XGL_SUCCESS) {%s\n"
+                         "        *(const XGL_LAYER_DISPATCH_TABLE **) (*%s) = *disp;\n"
+                         "    }\n"
                          "    return res;\n"
-                         "}" % (  proto.params[-1].name))
+                         "}"
+                         % (qual, decl, proto.params[0].name, stmt, obj_write_stmt, proto.params[-1].name))
             elif proto.name == "GetMultiGpuCompatibility":
                 funcs.append("%s%s\n"
                          "{\n"