aboutsummaryrefslogtreecommitdiff
path: root/c
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2022-07-15 02:36:07 +0200
committerJohn Ankarström <john@ankarstrom.se>2022-07-15 02:36:07 +0200
commit0e56160e859d32adffb7c9df3cd78cde0bff8df8 (patch)
tree5ca15fd27182e661ec2888ddbd8d976dbbadcd09 /c
parent2f6bd216d1411bd6ec96eaebf815dc3d5ab5a2f4 (diff)
downloadEpisodeBrowser-0e56160e859d32adffb7c9df3cd78cde0bff8df8.tar.gz
Don't crash on Prolog exceptions.
In the future, it may be desirable to convert Prolog exceptions to C++ exceptions.
Diffstat (limited to 'c')
-rw-r--r--c/defs.h2
-rw-r--r--c/main.cpp14
-rw-r--r--c/pl.cpp2
3 files changed, 4 insertions, 14 deletions
diff --git a/c/defs.h b/c/defs.h
index f57989c..766682e 100644
--- a/c/defs.h
+++ b/c/defs.h
@@ -110,7 +110,7 @@ int Pl(const char *szMod, const char *szPred, T... args)
int iArity = Countv(0, args...);
term_t t = PL_new_term_refs(iArity);
if (!PlPutv(t, args...)) return 0;
- if (!PL_call_predicate(NULL, PL_Q_NORMAL, PL_predicate(szPred, iArity, szMod), t))
+ if (!PL_call_predicate(NULL, PL_Q_CATCH_EXCEPTION, PL_predicate(szPred, iArity, szMod), t))
return 0;
if (!PlGetv(t, args...)) return 0;
return 1;
diff --git a/c/main.cpp b/c/main.cpp
index 2ae1c84..6a43e2c 100644
--- a/c/main.cpp
+++ b/c/main.cpp
@@ -27,7 +27,6 @@ static LRESULT CALLBACK CBTProc(int, WPARAM, LPARAM);
static LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
static INT_PTR CALLBACK AboutDlgProc(HWND, UINT, WPARAM, LPARAM);
static HWND CreateStatusBar(HWND, HINSTANCE);
-static int Attach(void);
static void UpdateTheme(void);
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
@@ -63,7 +62,8 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
tszErr = TEXT("Could not initialize Prolog.");
if (!PL_initialise(1, argv)) goto f;
tszErr = TEXT("Could not attach databases.");
- if (!Attach()) goto f;
+ if (!Pl("track_episodes","attach")) goto f;
+ if (!Pl("episode_data","attach")) goto f;
/* Initialize common controls, load menu and register window class. */
INITCOMMONCONTROLSEX icc;
@@ -486,16 +486,6 @@ HWND CreateStatusBar(HWND hWndParent, HINSTANCE hInstance)
/***/
-/* Attach persistent databases. */
-int Attach()
-{
- if (!Pl("track_episodes","attach")) return 0;
- if (!Pl("episode_data","attach")) return 0;
- return 1;
-}
-
-/***/
-
void UpdateLayout()
{
int cxColumn, cyDlv, yStatus;
diff --git a/c/pl.cpp b/c/pl.cpp
index 30b70a9..3172090 100644
--- a/c/pl.cpp
+++ b/c/pl.cpp
@@ -3,7 +3,7 @@
int Pl(const char *szMod, const char *szPred)
{
term_t t = PL_new_term_refs(0);
- if (!PL_call_predicate(NULL, PL_Q_NORMAL, PL_predicate(szPred, 0, szMod), t))
+ if (!PL_call_predicate(NULL, PL_Q_CATCH_EXCEPTION, PL_predicate(szPred, 0, szMod), t))
return 0;
return 1;
}