Fix order of destructor calls for DawgCache and TessBaseAPI

TessBaseAPI must release its cache use before DawgCache is destroyed.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
This commit is contained in:
Zdenko Podobný 2017-05-19 20:07:04 +02:00
parent 828bb63891
commit 201ec04caa

View File

@ -27,11 +27,12 @@
#include "allheaders.h"
#include "baseapi.h"
#include "basedir.h"
#include "dict.h"
#include "openclwrapper.h"
#include "osdetect.h"
#include "renderer.h"
#include "strngs.h"
#include "tprintf.h"
#include "openclwrapper.h"
#include "osdetect.h"
#if defined(HAVE_TIFFIO_H) && defined(_WIN32)
@ -422,6 +423,11 @@ int main(int argc, char** argv) {
PERF_COUNT_START("Tesseract:main")
// Call GlobalDawgCache here to create the global DawgCache object before
// the TessBaseAPI object. This fixes the order of destructor calls:
// first TessBaseAPI must be destructed, DawgCache must be the last object.
tesseract::Dict::GlobalDawgCache();
// Avoid memory leak caused by auto variable when exit() is called.
static tesseract::TessBaseAPI api;