Made normal build work again.

This commit is contained in:
Matthias Koefferlein 2018-07-03 01:49:06 +02:00
parent ab06ce3445
commit bbfcd9cf9e
20 changed files with 78 additions and 30 deletions

View File

@ -31,6 +31,7 @@
#if defined(HAVE_QT) #if defined(HAVE_QT)
# include <QResource> # include <QResource>
# include <QByteArray> # include <QByteArray>
# include <QFileInfo>
#endif #endif
#include <cctype> #include <cctype>

View File

@ -833,7 +833,7 @@ struct B
std::vector<std::vector<std::string> > m_vvs; std::vector<std::vector<std::string> > m_vvs;
std::list<std::string> m_ls; std::list<std::string> m_ls;
std::set<std::string> m_ss; std::set<std::string> m_ss;
#if defined_HAVE_QT #if defined(HAVE_QT)
QList<QString> m_qls; QList<QString> m_qls;
QList<QVariant> m_qlv; QList<QVariant> m_qlv;
QStringList m_qsl; QStringList m_qsl;

View File

@ -39,6 +39,7 @@
#include <QDomElement> #include <QDomElement>
#include <QDomDocument> #include <QDomDocument>
#include <QXmlStreamWriter> #include <QXmlStreamWriter>
#include <QTextStream>
#if QT_VERSION >= 0x050000 #if QT_VERSION >= 0x050000
# include <QUrlQuery> # include <QUrlQuery>
#endif #endif

View File

@ -397,7 +397,7 @@ Salt::create_grain (const SaltGrain &templ, SaltGrain &target)
if (! path.empty ()) { if (! path.empty ()) {
coll = 0; coll = 0;
for (SaltGrains::collection_iterator gg = m_root.begin_collections (); gg != m_root.end_collections (); ++gg) { for (SaltGrains::collection_iterator gg = m_root.begin_collections (); gg != m_root.end_collections (); ++gg) {
if (tl::is_parent_path (tl::to_qstring (gg->path ()), tl::to_qstring (path))) { if (tl::is_parent_path (gg->path (), path)) {
coll = gg.operator-> (); coll = gg.operator-> ();
break; break;
} }

View File

@ -154,7 +154,7 @@ SaltGrain::eff_doc_url () const
// if the resulting path is inside the downloaded package, use this path // if the resulting path is inside the downloaded package, use this path
QString dp = fi.canonicalFilePath (); QString dp = fi.canonicalFilePath ();
if (!dp.isEmpty () && tl::is_parent_path (p, dp)) { if (!dp.isEmpty () && tl::is_parent_path (tl::to_string (p), tl::to_string (dp))) {
url = QUrl::fromLocalFile (dp); url = QUrl::fromLocalFile (dp);
url.setScheme (tl::to_qstring ("file")); url.setScheme (tl::to_qstring ("file"));
return tl::to_string (url.toString ()); return tl::to_string (url.toString ());

View File

@ -78,7 +78,7 @@ SaltGrains::remove_collection (collection_iterator iter, bool with_files)
// NOTE: this is kind of inefficient, but in order to maintain the const iterator semantics this approach is required // NOTE: this is kind of inefficient, but in order to maintain the const iterator semantics this approach is required
for (collections_type::iterator i = m_collections.begin (); i != m_collections.end (); ++i) { for (collections_type::iterator i = m_collections.begin (); i != m_collections.end (); ++i) {
if (i == iter) { if (i == iter) {
if (with_files && !tl::rm_dir_recursive (tl::to_qstring (i->path ()))) { if (with_files && !tl::rm_dir_recursive (i->path ())) {
return false; return false;
} }
m_collections.erase (i); m_collections.erase (i);
@ -101,7 +101,7 @@ SaltGrains::remove_grain (grain_iterator iter, bool with_files)
// NOTE: this is kind of inefficient, but in order to maintain the const iterator semantics this approach is required // NOTE: this is kind of inefficient, but in order to maintain the const iterator semantics this approach is required
for (grains_type::iterator i = m_grains.begin (); i != m_grains.end (); ++i) { for (grains_type::iterator i = m_grains.begin (); i != m_grains.end (); ++i) {
if (i == iter) { if (i == iter) {
if (with_files && !tl::rm_dir_recursive (tl::to_qstring (i->path ()))) { if (with_files && !tl::rm_dir_recursive (i->path ())) {
return false; return false;
} }
m_grains.erase (i); m_grains.erase (i);

View File

@ -53,6 +53,7 @@
#include <QFile> #include <QFile>
#include <QBuffer> #include <QBuffer>
#include <QTimer> #include <QTimer>
#include <QXmlContentHandler>
#include <fstream> #include <fstream>
#include <sstream> #include <sstream>

View File

@ -1803,7 +1803,7 @@ LayerPropertiesList::load (tl::XMLSource &stream, std::vector <lay::LayerPropert
properties_lists.push_back (properties_list); properties_lists.push_back (properties_list);
} catch (...) { } catch (...) {
// "new" way // "new" way
stream.source ()->reset (); stream.reset ();
layer_prop_lists_structure.parse (stream, properties_lists); layer_prop_lists_structure.parse (stream, properties_lists);
} }
} }

View File

@ -39,6 +39,10 @@
#include "tlTimer.h" #include "tlTimer.h"
#include "tlFileUtils.h" #include "tlFileUtils.h"
#if defined(HAVE_QT)
# include <QCoreApplication>
#endif
namespace pya namespace pya
{ {

View File

@ -817,7 +817,7 @@ Item &Item::operator= (const Item &d)
m_tag_ids = d.m_tag_ids; m_tag_ids = d.m_tag_ids;
#if defined(HAVE_QT) #if defined(HAVE_QT)
if (mp_image) { if (mp_image.get ()) {
mp_image.reset (0); mp_image.reset (0);
} }
if (d.mp_image.get ()) { if (d.mp_image.get ()) {

View File

@ -938,7 +938,7 @@ public:
*/ */
const QImage *image () const const QImage *image () const
{ {
return mp_image; return mp_image.get ();
} }
/** /**

View File

@ -31,8 +31,8 @@
namespace tl namespace tl
{ {
// The maximum allowed processing tim // The maximum allowed processing time in seconds
const int processing_time = 20; const double processing_time = 0.02;
FileSystemWatcher::FileSystemWatcher (QObject *parent) FileSystemWatcher::FileSystemWatcher (QObject *parent)
: QObject (parent) : QObject (parent)
@ -120,7 +120,7 @@ FileSystemWatcher::remove_file (const std::string &path)
void void
FileSystemWatcher::timeout () FileSystemWatcher::timeout ()
{ {
QDateTime start = QDateTime::currentDateTime (); tl::Clock start = tl::Clock::current ();
if (m_iter == m_files.end ()) { if (m_iter == m_files.end ()) {
m_iter = m_files.begin (); m_iter = m_files.begin ();
@ -131,7 +131,7 @@ FileSystemWatcher::timeout ()
std::list<std::string> files_removed, files_changed; std::list<std::string> files_removed, files_changed;
while (m_index < i0 + m_batch_size && m_iter != m_files.end () && tl::msecs_to (start, QDateTime::currentDateTime()) < processing_time) { while (m_index < i0 + m_batch_size && m_iter != m_files.end () && (tl::Clock::current () - start).seconds () < processing_time) {
QFileInfo fi (tl::to_qstring (m_iter->first)); QFileInfo fi (tl::to_qstring (m_iter->first));
if (! fi.exists ()) { if (! fi.exists ()) {

View File

@ -43,7 +43,8 @@
#include "tlString.h" #include "tlString.h"
#if defined(HAVE_QT) #if defined(HAVE_QT)
# include <QUrl> # include <QUrl>
# include <QFileInfo>
#endif #endif
namespace tl namespace tl

View File

@ -27,6 +27,13 @@
#include <limits> #include <limits>
#if defined(HAVE_QT)
# include <QMutex>
# include <QWaitCondition>
# include <QThread>
# include <QThreadStorage>
#endif
namespace tl namespace tl
{ {
@ -72,7 +79,7 @@ class TL_PUBLIC WaitCondition
public: public:
WaitCondition () : QWaitCondition () { } WaitCondition () : QWaitCondition () { }
bool wait (Mutex *mutex, unsigned long time = std::numeric_limits<unsigned long>::max ()) { QWaitCondition::wakt (mutex, time); } bool wait (Mutex *mutex, unsigned long time = std::numeric_limits<unsigned long>::max ()) { return QWaitCondition::wait (mutex, time); }
}; };
#else #else
@ -118,7 +125,7 @@ private:
#if defined(HAVE_QT) #if defined(HAVE_QT)
public TL_PUBLIC Thread class TL_PUBLIC Thread
: public QThread : public QThread
{ {
public: public:

View File

@ -158,7 +158,7 @@ private:
* @code * @code
* tl::Clock start = tl::Clock::current (); * tl::Clock start = tl::Clock::current ();
* ... do something * ... do something
* if ((tl::Clock::current () - start).second () > 2) { * if ((tl::Clock::current () - start).seconds () > 2) {
* ... took longer than 2 seconds * ... took longer than 2 seconds
* } * }
* @/code * @/code

View File

@ -210,6 +210,14 @@ TestBase::TestBase (const std::string &file, const std::string &name)
tl::TestRegistrar::reg (this); tl::TestRegistrar::reg (this);
} }
void TestBase::remove_tmp_folder ()
{
std::string tmpdir = tl::combine_path (tl::absolute_file_path (testtmp ()), m_testdir);
if (tl::file_exists (tmpdir) && ! tl::rm_dir_recursive (tmpdir)) {
throw tl::Exception ("Unable to clean temporary dir: " + tmpdir);
}
}
bool TestBase::do_test (bool editable, bool slow) bool TestBase::do_test (bool editable, bool slow)
{ {
m_editable = editable; m_editable = editable;

View File

@ -294,6 +294,11 @@ public:
*/ */
std::string tmp_file (const std::string &fn = "tmp") const; std::string tmp_file (const std::string &fn = "tmp") const;
/**
* @brief Removes the temporay file folder
*/
void remove_tmp_folder ();
/** /**
* @brief A generic diff printer * @brief A generic diff printer
*/ */

View File

@ -113,6 +113,11 @@ public:
return m_error; return m_error;
} }
void reset ()
{
mp_stream->reset ();
}
private: private:
std::auto_ptr<tl::InputStream> mp_stream_holder; std::auto_ptr<tl::InputStream> mp_stream_holder;
tl::InputStream *mp_stream; tl::InputStream *mp_stream;
@ -137,6 +142,12 @@ XMLSource::~XMLSource ()
mp_source = 0; mp_source = 0;
} }
void
XMLSource::reset ()
{
mp_source->reset ();
}
// -------------------------------------------------------------------- // --------------------------------------------------------------------
// XMLStringSource implementation // XMLStringSource implementation
@ -345,6 +356,7 @@ XMLParser::parse (XMLSource &source, XMLStructureHandler &struct_handler)
#include <QFile> #include <QFile>
#include <QIODevice> #include <QIODevice>
#include <QXmlContentHandler>
namespace tl namespace tl
{ {
@ -356,7 +368,7 @@ class SAXHandler
: public QXmlDefaultHandler : public QXmlDefaultHandler
{ {
public: public:
SAXHandler (trureHandler *sh); SAXHandler (XMLStructureHandler *sh);
bool characters (const QString &ch); bool characters (const QString &ch);
bool endElement (const QString &namespaceURI, const QString &localName, const QString &qName); bool endElement (const QString &namespaceURI, const QString &localName, const QString &qName);
@ -369,13 +381,13 @@ public:
private: private:
QXmlLocator *mp_locator; QXmlLocator *mp_locator;
trureHandler *mp_struct_handler; XMLStructureHandler *mp_struct_handler;
}; };
// -------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------
// trureHandler implementation // trureHandler implementation
SAXHandler::SAXHandler (trureHandler *sh) SAXHandler::SAXHandler (XMLStructureHandler *sh)
: QXmlDefaultHandler (), mp_locator (0), mp_struct_handler (sh) : QXmlDefaultHandler (), mp_locator (0), mp_struct_handler (sh)
{ {
// .. nothing yet .. // .. nothing yet ..
@ -429,7 +441,7 @@ bool
SAXHandler::characters (const QString &t) SAXHandler::characters (const QString &t)
{ {
try { try {
mp_struct_handler->cdata (tl::to_string (t)); mp_struct_handler->characters (tl::to_string (t));
} catch (tl::XMLException &ex) { } catch (tl::XMLException &ex) {
throw tl::XMLLocatedException (ex.raw_msg (), mp_locator->lineNumber (), mp_locator->columnNumber ()); throw tl::XMLLocatedException (ex.raw_msg (), mp_locator->lineNumber (), mp_locator->columnNumber ());
} catch (tl::Exception &ex) { } catch (tl::Exception &ex) {
@ -490,6 +502,12 @@ XMLSource::~XMLSource ()
mp_source = 0; mp_source = 0;
} }
void
XMLSource::reset ()
{
mp_source->reset ();
}
// -------------------------------------------------------------------- // --------------------------------------------------------------------
// XMLStringSource implementation // XMLStringSource implementation

View File

@ -312,13 +312,15 @@ class TL_PUBLIC XMLSource
{ {
public: public:
XMLSource (); XMLSource ();
virtual ~XMLSource (); ~XMLSource ();
virtual XMLSourcePrivateData *source () XMLSourcePrivateData *source ()
{ {
return mp_source; return mp_source;
} }
void reset ();
protected: protected:
void set_source (XMLSourcePrivateData *source) void set_source (XMLSourcePrivateData *source)
{ {
@ -337,7 +339,7 @@ class TL_PUBLIC XMLStringSource : public XMLSource
{ {
public: public:
XMLStringSource (const std::string &string); XMLStringSource (const std::string &string);
virtual ~XMLStringSource (); ~XMLStringSource ();
}; };
/** /**
@ -349,7 +351,7 @@ class TL_PUBLIC XMLFileSource : public XMLSource
public: public:
XMLFileSource (const std::string &path); XMLFileSource (const std::string &path);
XMLFileSource (const std::string &path, const std::string &progress_message); XMLFileSource (const std::string &path, const std::string &progress_message);
virtual ~XMLFileSource (); ~XMLFileSource ();
}; };
/** /**
@ -363,7 +365,7 @@ class TL_PUBLIC XMLStreamSource : public XMLSource
public: public:
XMLStreamSource (tl::InputStream &stream); XMLStreamSource (tl::InputStream &stream);
XMLStreamSource (tl::InputStream &stream, const std::string &progress_message); XMLStreamSource (tl::InputStream &stream, const std::string &progress_message);
virtual ~XMLStreamSource (); ~XMLStreamSource ();
}; };

View File

@ -58,7 +58,7 @@ TEST (2)
adir.cd (QString::fromUtf8 ("a")); adir.cd (QString::fromUtf8 ("a"));
EXPECT_EQ (adir.exists (), true); EXPECT_EQ (adir.exists (), true);
EXPECT_EQ (tl::rm_dir_recursive (adir.absolutePath ()), true); EXPECT_EQ (tl::rm_dir_recursive (tl::to_string (adir.absolutePath ())), true);
EXPECT_EQ (adir.exists (), false); EXPECT_EQ (adir.exists (), false);
tmp_dir.mkdir (QString::fromUtf8 ("a")); tmp_dir.mkdir (QString::fromUtf8 ("a"));
@ -93,7 +93,7 @@ TEST (2)
} }
EXPECT_EQ (adir.exists (), true); EXPECT_EQ (adir.exists (), true);
EXPECT_EQ (tl::rm_dir_recursive (adir.absolutePath ()), true); EXPECT_EQ (tl::rm_dir_recursive (tl::to_string (adir.absolutePath ())), true);
EXPECT_EQ (adir.exists (), false); EXPECT_EQ (adir.exists (), false);
EXPECT_EQ (b1dir.exists (), false); EXPECT_EQ (b1dir.exists (), false);
EXPECT_EQ (b2dir.exists (), false); EXPECT_EQ (b2dir.exists (), false);
@ -104,7 +104,7 @@ TEST (3)
{ {
QDir tmp_dir = QFileInfo (tl::to_qstring (tmp_file ())).absoluteDir (); QDir tmp_dir = QFileInfo (tl::to_qstring (tmp_file ())).absoluteDir ();
tl::rm_dir_recursive (tmp_dir.filePath (QString::fromUtf8 ("a"))); tl::rm_dir_recursive (tl::to_string (tmp_dir.filePath (QString::fromUtf8 ("a"))));
tmp_dir.mkdir (QString::fromUtf8 ("a")); tmp_dir.mkdir (QString::fromUtf8 ("a"));
QDir adir = tmp_dir; QDir adir = tmp_dir;
@ -132,10 +132,10 @@ TEST (3)
file.close (); file.close ();
} }
tl::rm_dir_recursive (tmp_dir.filePath (QString::fromUtf8 ("acopy"))); tl::rm_dir_recursive (tl::to_string (tmp_dir.filePath (QString::fromUtf8 ("acopy"))));
tmp_dir.mkdir (QString::fromUtf8 ("acopy")); tmp_dir.mkdir (QString::fromUtf8 ("acopy"));
tl::cp_dir_recursive (tmp_dir.absoluteFilePath (QString::fromUtf8 ("a")), tmp_dir.absoluteFilePath (QString::fromUtf8 ("acopy"))); tl::cp_dir_recursive (tl::to_string (tmp_dir.absoluteFilePath (QString::fromUtf8 ("a"))), tl::to_string (tmp_dir.absoluteFilePath (QString::fromUtf8 ("acopy"))));
QDir acopydir = tmp_dir; QDir acopydir = tmp_dir;
EXPECT_EQ (acopydir.cd (QString::fromUtf8 ("acopy")), true); EXPECT_EQ (acopydir.cd (QString::fromUtf8 ("acopy")), true);