[poppler] poppler/qt4/src: poppler-document.cc, 1.19, 1.20 poppler-private.h, 1.10, 1.11

Albert Astals Cid aacid at kemper.freedesktop.org
Sat May 13 08:58:41 PDT 2006


Update of /cvs/poppler/poppler/qt4/src
In directory kemper:/tmp/cvs-serv23092/qt4/src

Modified Files:
	poppler-document.cc poppler-private.h 
Log Message:
        * qt4/src/poppler-document.cc: leak--
        * qt4/src/poppler-private.h: Refcount globalparams
        * qt4/tests/test-poppler-qt4.cpp: Some leaks less


Index: poppler-document.cc
===================================================================
RCS file: /cvs/poppler/poppler/qt4/src/poppler-document.cc,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- poppler-document.cc	9 May 2006 20:07:06 -0000	1.19
+++ poppler-document.cc	13 May 2006 15:58:39 -0000	1.20
@@ -41,13 +41,11 @@
 
 namespace Poppler {
 
+  int DocumentData::count = 0;
+
   Document *Document::load(const QString &filePath, const QByteArray &ownerPassword,
 			   const QByteArray &userPassword)
     {
-	if (!globalParams) {
-	    globalParams = new GlobalParams("/etc/xpdfrc");
-	}
-
 	DocumentData *doc = new DocumentData(new GooString(QFile::encodeName(filePath)), 
 					     new GooString(ownerPassword.data()),
 					     new GooString(userPassword.data()));
@@ -286,7 +284,9 @@
 
 	if ( infoDict->lookup( type.toLatin1().data(), &obj )->isString() )
 	{
-	    result = Poppler::convertDate(UGooString(*obj.getString()).getCString());
+	    char *aux = UGooString(*obj.getString()).getCString();
+	    result = Poppler::convertDate(aux);
+	    delete[] aux;
 	}
 	obj.free();
 	info.free();

Index: poppler-private.h
===================================================================
RCS file: /cvs/poppler/poppler/qt4/src/poppler-private.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- poppler-private.h	9 May 2006 20:07:06 -0000	1.10
+++ poppler-private.h	13 May 2006 15:58:39 -0000	1.11
@@ -21,6 +21,7 @@
  */
 
 #include <GfxState.h>
+#include <GlobalParams.h>
 #include <Link.h>
 #include <Outline.h>
 #include <PDFDoc.h>
@@ -71,6 +72,9 @@
 		// It might be more appropriate to delete these in PDFDoc
 		delete ownerPassword;
 		delete userPassword;
+		
+		if ( count == 0 ) globalParams = new GlobalParams("/etc/xpdfrc");
+		count ++;
 	    }
 	
 	~DocumentData()
@@ -78,6 +82,9 @@
 		qDeleteAll(m_embeddedFiles);
 		delete m_splashOutputDev;
 		delete m_fontInfoScanner;
+		
+		count --;
+		if ( count == 0 ) delete globalParams;
 	}
 	
 	SplashOutputDev *getSplashOutputDev()
@@ -165,6 +172,7 @@
 	SplashOutputDev *m_splashOutputDev;
 	QList<EmbeddedFile*> m_embeddedFiles;
 	QColor paperColor;
+	static int count;
     };
 
     class FontInfoData



More information about the poppler mailing list