|
@@ -23,6 +23,7 @@
|
|
|
|
|
|
|
|
#include "ctkCmdLineModuleBackend.h"
|
|
#include "ctkCmdLineModuleBackend.h"
|
|
|
#include "ctkCmdLineModuleFrontend.h"
|
|
#include "ctkCmdLineModuleFrontend.h"
|
|
|
|
|
+#include "ctkCmdLineModuleTimeoutException.h"
|
|
|
#include "ctkCmdLineModuleCache_p.h"
|
|
#include "ctkCmdLineModuleCache_p.h"
|
|
|
#include "ctkCmdLineModuleFuture.h"
|
|
#include "ctkCmdLineModuleFuture.h"
|
|
|
#include "ctkCmdLineModuleXmlValidator.h"
|
|
#include "ctkCmdLineModuleXmlValidator.h"
|
|
@@ -50,7 +51,8 @@ extern int qHash(const QUrl& url);
|
|
|
struct ctkCmdLineModuleManagerPrivate
|
|
struct ctkCmdLineModuleManagerPrivate
|
|
|
{
|
|
{
|
|
|
ctkCmdLineModuleManagerPrivate(ctkCmdLineModuleManager::ValidationMode mode, const QString& cacheDir)
|
|
ctkCmdLineModuleManagerPrivate(ctkCmdLineModuleManager::ValidationMode mode, const QString& cacheDir)
|
|
|
- : ValidationMode(mode)
|
|
|
|
|
|
|
+ : XmlTimeOut(30000)
|
|
|
|
|
+ , ValidationMode(mode)
|
|
|
{
|
|
{
|
|
|
QFileInfo fileInfo(cacheDir);
|
|
QFileInfo fileInfo(cacheDir);
|
|
|
if (!fileInfo.exists())
|
|
if (!fileInfo.exists())
|
|
@@ -84,6 +86,7 @@ struct ctkCmdLineModuleManagerPrivate
|
|
|
QHash<QString, ctkCmdLineModuleBackend*> SchemeToBackend;
|
|
QHash<QString, ctkCmdLineModuleBackend*> SchemeToBackend;
|
|
|
QHash<QUrl, ctkCmdLineModuleReference> LocationToRef;
|
|
QHash<QUrl, ctkCmdLineModuleReference> LocationToRef;
|
|
|
QScopedPointer<ctkCmdLineModuleCache> ModuleCache;
|
|
QScopedPointer<ctkCmdLineModuleCache> ModuleCache;
|
|
|
|
|
+ int XmlTimeOut;
|
|
|
|
|
|
|
|
const ctkCmdLineModuleManager::ValidationMode ValidationMode;
|
|
const ctkCmdLineModuleManager::ValidationMode ValidationMode;
|
|
|
};
|
|
};
|
|
@@ -106,6 +109,17 @@ ctkCmdLineModuleManager::ValidationMode ctkCmdLineModuleManager::validationMode(
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
+void ctkCmdLineModuleManager::setXmlTimeout(int xmlTimeout)
|
|
|
|
|
+{
|
|
|
|
|
+ d->XmlTimeOut = xmlTimeout;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+//----------------------------------------------------------------------------
|
|
|
|
|
+int ctkCmdLineModuleManager::xmlTimeout() const
|
|
|
|
|
+{
|
|
|
|
|
+ return d->XmlTimeOut;
|
|
|
|
|
+}
|
|
|
|
|
+//----------------------------------------------------------------------------
|
|
|
void ctkCmdLineModuleManager::registerBackend(ctkCmdLineModuleBackend *backend)
|
|
void ctkCmdLineModuleManager::registerBackend(ctkCmdLineModuleBackend *backend)
|
|
|
{
|
|
{
|
|
|
QMutexLocker lock(&d->Mutex);
|
|
QMutexLocker lock(&d->Mutex);
|
|
@@ -159,7 +173,13 @@ ctkCmdLineModuleManager::registerModule(const QUrl &location)
|
|
|
// newly fetch the XML description
|
|
// newly fetch the XML description
|
|
|
try
|
|
try
|
|
|
{
|
|
{
|
|
|
- xml = backend->rawXmlDescription(location);
|
|
|
|
|
|
|
+ xml = backend->rawXmlDescription(location, d->XmlTimeOut);
|
|
|
|
|
+ }
|
|
|
|
|
+ catch (const ctkCmdLineModuleTimeoutException&)
|
|
|
|
|
+ {
|
|
|
|
|
+ // in case of a time-out, do not cache it as a failed attempt
|
|
|
|
|
+ // by recording an empty QByteArray in the cache
|
|
|
|
|
+ throw;
|
|
|
}
|
|
}
|
|
|
catch (...)
|
|
catch (...)
|
|
|
{
|
|
{
|
|
@@ -177,7 +197,7 @@ ctkCmdLineModuleManager::registerModule(const QUrl &location)
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
|
{
|
|
{
|
|
|
- xml = backend->rawXmlDescription(location);
|
|
|
|
|
|
|
+ xml = backend->rawXmlDescription(location, d->XmlTimeOut);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (xml.isEmpty())
|
|
if (xml.isEmpty())
|