diff options
-rw-r--r-- | c/datalistview.c | 12 | ||||
-rw-r--r-- | c/episodelistview.c | 5 | ||||
-rw-r--r-- | c/main.c | 9 |
3 files changed, 21 insertions, 5 deletions
diff --git a/c/datalistview.c b/c/datalistview.c index 4a0208d..208ef22 100644 --- a/c/datalistview.c +++ b/c/datalistview.c @@ -34,8 +34,8 @@ DlvCreate(HWND hWnd) void DlvShowEpisode(int iEpisode) { + fid_t f; HWND hListView; - int r; LVITEM lviKey, lviValue; term_t t; @@ -45,14 +45,15 @@ DlvShowEpisode(int iEpisode) lviKey.mask = LVIF_TEXT; lviValue.mask = LVIF_TEXT; + f = PL_open_foreign_frame(); t = PL_new_term_refs(3); + if(!PL_put_integer(t+0, iEpisode)) return; - r = PL_call_predicate(NULL, PL_Q_NORMAL, + if (!PL_call_predicate(NULL, PL_Q_NORMAL, PL_predicate("lookup_episode_local", 3, "episode_data"), - t); - if (!r) + t)) return; /* The episode data is a list of unary compounds, @@ -78,6 +79,7 @@ DlvShowEpisode(int iEpisode) if (!szKey) continue; + tValue = PL_new_term_ref(); if (!PL_get_arg(1, tHead, tValue)) continue; if (!PL_get_atom_chars(tValue, &szValue)) @@ -106,4 +108,6 @@ DlvShowEpisode(int iEpisode) free(tszValue); } } + + PL_close_foreign_frame(f); } diff --git a/c/episodelistview.c b/c/episodelistview.c index 0b9e855..42a2151 100644 --- a/c/episodelistview.c +++ b/c/episodelistview.c @@ -81,6 +81,7 @@ ElvHandleNotify(LPARAM lParam) void ElvUpdate() { + fid_t f; HWND hListView; LVITEM lviEpisode, lviName; qid_t q; @@ -92,6 +93,7 @@ ElvUpdate() lviEpisode.mask = LVIF_TEXT|LVIF_PARAM; lviName.mask = LVIF_TEXT; + f = PL_open_foreign_frame(); t = PL_new_term_refs(2); PL_call_predicate(NULL, PL_Q_NORMAL, PL_predicate("update_tracked_episodes", 0, "track_episodes"), @@ -162,7 +164,8 @@ ElvUpdate() } close: - PL_close_query(q); + PL_cut_query(q); + PL_close_foreign_frame(f); } /* Update episode name. */ @@ -23,6 +23,7 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, HWND hWnd; MSG msg; INITCOMMONCONTROLSEX icc; + //term_t t; WNDCLASSEX wc; /* Initialize Prolog. */ @@ -33,6 +34,14 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, if (!PL_initialise(1, rgArgs)) PL_halt(1); + //t = PL_new_term_refs(1); + //if (!PL_put_atom_chars(t+0, "false")) + // return 0; + //if (!PL_call_predicate(NULL, PL_Q_NORMAL, + // PL_predicate("set_prolog_gc_thread", 1, "user"), + // t)) + // return 0; + Attach(); /* Create window. */ |