View Issue Details

IDProjectCategoryView StatusLast Update
0002236ScribusInternalpublic2005-08-11 21:48
Reporterjghali Assigned Toringerc 
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
PlatformWindowsOSWindowsOS Version2000 SP4
Product Version1.3.0cvs 
Fixed in Version1.3.1cvs 
Summary0002236: Convert gtgettext.cpp to new plugin loading api
DescriptionThe attached diff allow gtgettext to use new plugin loading abstraction instead of qlibrary.
TagsNo tags attached.
Patch

Relationships

child of 0000015 closedjghali Windows Port 

Activities

2005-07-14 22:16

 

gettext_plugin_loading_api.diff (3,094 bytes)   
Index: gtgettext.cpp
===================================================================
RCS file: /cvs/Scribus/scribus/gtgettext.cpp,v
retrieving revision 1.3.2.7
diff -u -r1.3.2.7 gtgettext.cpp
--- gtgettext.cpp	13 Mar 2005 15:09:20 -0000	1.3.2.7
+++ gtgettext.cpp	15 Jul 2005 00:00:34 -0000
@@ -18,8 +18,6 @@
  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
  ***************************************************************************/
 
-#include "qlibrary.h"
-
 #include "gtgettext.h"
 #include "pluginmanager.h"
 #include "scpaths.h"
@@ -121,47 +119,60 @@
 void gtGetText::CallDLL(const ImporterData& idata, const QString& filePath,
                         const QString& encoding, bool textOnly, bool append)
 {
+	void* gtplugin;
 	typedef void (*sdem)(QString filename, QString encoding, bool textOnly, gtWriter *writer);
 	sdem fp_GetText;
 	QString pluginFilePath = QString("%1/gettext/%2").arg(ScPaths::instance().pluginDir()).arg(idata.soFilePath);
-	// This is the new, QLibrary based plugin loading code.
-	QLibrary gtplugin(pluginFilePath);
-	gtplugin.setAutoUnload(true);
-	fp_GetText = (sdem)gtplugin.resolve("GetText");
+	gtplugin = PluginManager::loadDLL("pluginFilePath");
+	if (!gtplugin)
+	{
+		qWarning("Failed to load plugin %s", pluginFilePath.ascii());
+		return;
+	}
+	fp_GetText = (sdem) PluginManager::resolveSym(gtplugin, "GetText");
 	if (!fp_GetText)
 	{
 		qWarning("Failed to get GetText() from %s", pluginFilePath.ascii());
+		PluginManager::unloadDLL(gtplugin);
 		return;
 	}
 	gtWriter *w = new gtWriter(append);
 	(*fp_GetText)(filePath, encoding, textOnly, w);
 	delete w;
+	PluginManager::unloadDLL(gtplugin);
 }
 
 bool gtGetText::DLLName(QString name, QString *ffName, QStringList *fEndings)
 {
+	void* gtplugin;
 	typedef QString (*sdem0)();
 	typedef QStringList (*sdem1)();
 	sdem0 fp_FileFormatName;
 	sdem1 fp_FileExtensions;
 	QString pluginFilePath = QString("%1/gettext/%2").arg(ScPaths::instance().pluginDir()).arg(name);
-
-	QLibrary gtplugin(pluginFilePath);
-	gtplugin.setAutoUnload(true);
-	fp_FileFormatName = (sdem0)gtplugin.resolve("FileFormatName");
+	gtplugin = PluginManager::loadDLL(pluginFilePath);
+	if (!gtplugin)
+	{
+		qWarning("Failed to load plugin %s", pluginFilePath.ascii());
+		return false;
+	}
+	fp_FileFormatName = (sdem0) PluginManager::resolveSym( gtplugin, "FileFormatName");
 	if (!fp_FileFormatName)
 	{
 		qWarning("Failed to get FileFormatName() from %s", pluginFilePath.ascii());
+		PluginManager::unloadDLL(gtplugin);
 		return false;
 	}
-	fp_FileExtensions = (sdem1)gtplugin.resolve("FileExtensions");
+	fp_FileExtensions = (sdem1) PluginManager::resolveSym( gtplugin, "FileExtensions");
 	if (!fp_FileExtensions)
 	{
 		qWarning("Failed to get FileExtensions() from %s", pluginFilePath.ascii());
+		PluginManager::unloadDLL(gtplugin);
 		return false;
 	}
 	*ffName = (*fp_FileFormatName)();
 	*fEndings = (*fp_FileExtensions)();
+	PluginManager::unloadDLL(gtplugin);
 	return true;
 }
 

ringerc

2005-07-15 06:26

reporter   ~0005589

Looks good. Merged.

ringerc

2005-07-16 19:19

reporter   ~0005611

It seems I was blind, deaf and dumb when merging that. No idea how I screwed up testing it.

gtplugin = PluginManager::loadDLL("pluginFilePath");

!=

gtplugin = PluginManager::loadDLL(pluginFilePath);

jghali, did you test to see that gettext worked on win32 before submitting this?

ringerc

2005-07-16 19:20

reporter   ~0005612

Fixed in CVS, anyway.

jghali

2005-08-11 21:48

administrator   ~0006078

tested with compiled gettext plugins on win32, works.

Issue History

Date Modified Username Field Change
2005-07-14 22:16 jghali New Issue
2005-07-14 22:16 jghali File Added: gettext_plugin_loading_api.diff
2005-07-15 05:53 ringerc Status new => assigned
2005-07-15 05:53 ringerc Assigned To => ringerc
2005-07-15 06:26 ringerc Status assigned => resolved
2005-07-15 06:26 ringerc Fixed in Version => 1.3.1cvs
2005-07-15 06:26 ringerc Resolution open => fixed
2005-07-15 06:26 ringerc Note Added: 0005589
2005-07-15 07:37 ringerc Relationship added related to 0000015
2005-07-15 07:41 ringerc Relationship replaced child of 0000015
2005-07-16 19:19 ringerc Note Added: 0005611
2005-07-16 19:20 ringerc Note Added: 0005612
2005-08-11 21:48 jghali Status resolved => closed
2005-08-11 21:48 jghali Note Added: 0006078