From 3ca9bb7c3c90a8e7da3e2e440a72cdb11b3e66b0 Mon Sep 17 00:00:00 2001 From: Don Pellegrino Date: Thu, 01 Oct 2009 20:18:18 +0000 Subject: Separated checking for an error in the database library from checking for an error in the OpenGL library. The check_error function still checks for both however the check_error_db function can now be used to check only the database. This is used at connect time as the OpenGL library may not yet be fully initialized and running the error checking could be premature. --- diff --git a/src/Makefile.am b/src/Makefile.am index 4938ed4..d6253b8 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -35,6 +35,7 @@ flumap_SOURCES = \ model/state/zoom_info_init.c \ util/ati_meminfo.c \ util/check_error.c \ + util/check_error_db.c \ util/pick_convert.c \ util/sqlinfoprint.c \ view/geometry.c \ @@ -75,6 +76,7 @@ noinst_HEADERS = \ model/state/zoom_info_init.h \ util/ati_meminfo.h \ util/check_error.h \ + util/check_error_db.h \ util/pick_convert.h \ util/sqlinfoprint.h \ view/geometry.h \ diff --git a/src/db/dbconnect.sqc b/src/db/dbconnect.sqc index 1e41a12..aab7bcb 100644 --- a/src/db/dbconnect.sqc +++ b/src/db/dbconnect.sqc @@ -1,5 +1,5 @@ #include "dbconnect.h" -#include "../util/check_error.h" +#include "../util/check_error_db.h" EXEC SQL INCLUDE sqlca; @@ -7,5 +7,13 @@ void dbconnect (void) { EXEC SQL CONNECT TO exp004; - check_error (__FILE__, __LINE__); + + /* + * Only check for a database error rather than using check_error to + * test for OpenGL and database errors. OpenGL may not yet be + * prepared and checking it prematurely could cause odd behavior. + */ + check_error_db (__FILE__, __LINE__); + + return; } diff --git a/src/util/check_error.c b/src/util/check_error.c index c47ca43..7d116e9 100644 --- a/src/util/check_error.c +++ b/src/util/check_error.c @@ -2,8 +2,7 @@ #include #include #include -#include "sqlinfoprint.h" -extern struct sqlca sqlca; +#include "check_error_db.h" void check_error (const char *filename, const unsigned int linenum) @@ -23,8 +22,7 @@ check_error (const char *filename, const unsigned int linenum) /* * Check for an error from the Database API. */ - if (sqlinfoprint ("DB Error", &sqlca, filename, linenum) == 1) - exit (EXIT_FAILURE); + check_error_db (filename, linenum); return; } diff --git a/src/util/check_error_db.c b/src/util/check_error_db.c new file mode 100644 index 0000000..a6b7f51 --- a/dev/null +++ b/src/util/check_error_db.c @@ -0,0 +1,13 @@ +#include "check_error_db.h" +#include "sqlinfoprint.h" +#include +extern struct sqlca sqlca; + +void +check_error_db (const char *filename, const unsigned int linenum) +{ + if (sqlinfoprint ("DB Error", &sqlca, filename, linenum) == 1) + exit (EXIT_FAILURE); + + return; +} diff --git a/src/util/check_error_db.h b/src/util/check_error_db.h new file mode 100644 index 0000000..cc8467b --- a/dev/null +++ b/src/util/check_error_db.h @@ -0,0 +1,9 @@ +#ifndef CHECK_ERROR_H +#define CHECK_ERROR_H + +/* + * Check the database library to see if an error has occurred. + */ +void check_error_db (const char* filename, unsigned int linenum); + +#endif // CHECK_ERROR_H -- cgit v0.8.3.1-22-g547a