diff --git a/src/db/db/dbGlyphs.cc b/src/db/db/dbGlyphs.cc index 0e68f4e34..30ed1509a 100644 --- a/src/db/db/dbGlyphs.cc +++ b/src/db/db/dbGlyphs.cc @@ -31,6 +31,7 @@ #if defined(HAVE_QT) # include # include +# include #endif #include diff --git a/src/gsi/gsi_test/gsiTest.h b/src/gsi/gsi_test/gsiTest.h index 09836094e..439a50bdb 100644 --- a/src/gsi/gsi_test/gsiTest.h +++ b/src/gsi/gsi_test/gsiTest.h @@ -833,7 +833,7 @@ struct B std::vector > m_vvs; std::list m_ls; std::set m_ss; -#if defined_HAVE_QT +#if defined(HAVE_QT) QList m_qls; QList m_qlv; QStringList m_qsl; diff --git a/src/lay/lay/layLayoutStatisticsForm.cc b/src/lay/lay/layLayoutStatisticsForm.cc index b84fd2152..fa55815e0 100644 --- a/src/lay/lay/layLayoutStatisticsForm.cc +++ b/src/lay/lay/layLayoutStatisticsForm.cc @@ -39,6 +39,7 @@ #include #include #include +#include #if QT_VERSION >= 0x050000 # include #endif diff --git a/src/lay/lay/laySalt.cc b/src/lay/lay/laySalt.cc index fdeb1b3d3..c2cd977a6 100644 --- a/src/lay/lay/laySalt.cc +++ b/src/lay/lay/laySalt.cc @@ -397,7 +397,7 @@ Salt::create_grain (const SaltGrain &templ, SaltGrain &target) if (! path.empty ()) { coll = 0; 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-> (); break; } diff --git a/src/lay/lay/laySaltGrain.cc b/src/lay/lay/laySaltGrain.cc index a0a2a0b62..9ca74b57c 100644 --- a/src/lay/lay/laySaltGrain.cc +++ b/src/lay/lay/laySaltGrain.cc @@ -154,7 +154,7 @@ SaltGrain::eff_doc_url () const // if the resulting path is inside the downloaded package, use this path 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.setScheme (tl::to_qstring ("file")); return tl::to_string (url.toString ()); diff --git a/src/lay/lay/laySaltGrains.cc b/src/lay/lay/laySaltGrains.cc index cc6fefcf0..f414c36c5 100644 --- a/src/lay/lay/laySaltGrains.cc +++ b/src/lay/lay/laySaltGrains.cc @@ -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 for (collections_type::iterator i = m_collections.begin (); i != m_collections.end (); ++i) { 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; } 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 for (grains_type::iterator i = m_grains.begin (); i != m_grains.end (); ++i) { 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; } m_grains.erase (i); diff --git a/src/laybasic/laybasic/gtf.cc b/src/laybasic/laybasic/gtf.cc index cad92b2de..7251a08ef 100644 --- a/src/laybasic/laybasic/gtf.cc +++ b/src/laybasic/laybasic/gtf.cc @@ -53,6 +53,7 @@ #include #include #include +#include #include #include diff --git a/src/laybasic/laybasic/layLayerProperties.cc b/src/laybasic/laybasic/layLayerProperties.cc index 54f22da74..628e638ac 100644 --- a/src/laybasic/laybasic/layLayerProperties.cc +++ b/src/laybasic/laybasic/layLayerProperties.cc @@ -1803,7 +1803,7 @@ LayerPropertiesList::load (tl::XMLSource &stream, std::vector reset (); + stream.reset (); layer_prop_lists_structure.parse (stream, properties_lists); } } diff --git a/src/pya/pya/pya.cc b/src/pya/pya/pya.cc index 60d2ed425..bc9e09d43 100644 --- a/src/pya/pya/pya.cc +++ b/src/pya/pya/pya.cc @@ -39,6 +39,10 @@ #include "tlTimer.h" #include "tlFileUtils.h" +#if defined(HAVE_QT) +# include +#endif + namespace pya { diff --git a/src/rdb/rdb/rdb.cc b/src/rdb/rdb/rdb.cc index 733f24196..34a897418 100644 --- a/src/rdb/rdb/rdb.cc +++ b/src/rdb/rdb/rdb.cc @@ -817,7 +817,7 @@ Item &Item::operator= (const Item &d) m_tag_ids = d.m_tag_ids; #if defined(HAVE_QT) - if (mp_image) { + if (mp_image.get ()) { mp_image.reset (0); } if (d.mp_image.get ()) { diff --git a/src/rdb/rdb/rdb.h b/src/rdb/rdb/rdb.h index 21f31ebe7..f98742449 100644 --- a/src/rdb/rdb/rdb.h +++ b/src/rdb/rdb/rdb.h @@ -938,7 +938,7 @@ public: */ const QImage *image () const { - return mp_image; + return mp_image.get (); } /** diff --git a/src/tl/tl/tlFileSystemWatcher.cc b/src/tl/tl/tlFileSystemWatcher.cc index 0db0e8ff1..f865c71be 100644 --- a/src/tl/tl/tlFileSystemWatcher.cc +++ b/src/tl/tl/tlFileSystemWatcher.cc @@ -31,8 +31,8 @@ namespace tl { -// The maximum allowed processing tim -const int processing_time = 20; +// The maximum allowed processing time in seconds +const double processing_time = 0.02; FileSystemWatcher::FileSystemWatcher (QObject *parent) : QObject (parent) @@ -120,7 +120,7 @@ FileSystemWatcher::remove_file (const std::string &path) void FileSystemWatcher::timeout () { - QDateTime start = QDateTime::currentDateTime (); + tl::Clock start = tl::Clock::current (); if (m_iter == m_files.end ()) { m_iter = m_files.begin (); @@ -131,7 +131,7 @@ FileSystemWatcher::timeout () std::list 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)); if (! fi.exists ()) { diff --git a/src/tl/tl/tlStream.cc b/src/tl/tl/tlStream.cc index c17ee84bf..6fc993435 100644 --- a/src/tl/tl/tlStream.cc +++ b/src/tl/tl/tlStream.cc @@ -43,7 +43,8 @@ #include "tlString.h" #if defined(HAVE_QT) -# include +# include +# include #endif namespace tl diff --git a/src/tl/tl/tlThreads.h b/src/tl/tl/tlThreads.h index 6ee35a886..505846b7c 100644 --- a/src/tl/tl/tlThreads.h +++ b/src/tl/tl/tlThreads.h @@ -27,6 +27,13 @@ #include +#if defined(HAVE_QT) +# include +# include +# include +# include +#endif + namespace tl { @@ -72,7 +79,7 @@ class TL_PUBLIC WaitCondition public: WaitCondition () : QWaitCondition () { } - bool wait (Mutex *mutex, unsigned long time = std::numeric_limits::max ()) { QWaitCondition::wakt (mutex, time); } + bool wait (Mutex *mutex, unsigned long time = std::numeric_limits::max ()) { return QWaitCondition::wait (mutex, time); } }; #else @@ -118,7 +125,7 @@ private: #if defined(HAVE_QT) -public TL_PUBLIC Thread +class TL_PUBLIC Thread : public QThread { public: diff --git a/src/tl/tl/tlTimer.h b/src/tl/tl/tlTimer.h index 2bf256b6e..eda1f1ac4 100644 --- a/src/tl/tl/tlTimer.h +++ b/src/tl/tl/tlTimer.h @@ -158,7 +158,7 @@ private: * @code * tl::Clock start = tl::Clock::current (); * ... do something - * if ((tl::Clock::current () - start).second () > 2) { + * if ((tl::Clock::current () - start).seconds () > 2) { * ... took longer than 2 seconds * } * @/code diff --git a/src/tl/tl/tlUnitTest.cc b/src/tl/tl/tlUnitTest.cc index d743d95cc..b2451cdda 100644 --- a/src/tl/tl/tlUnitTest.cc +++ b/src/tl/tl/tlUnitTest.cc @@ -210,6 +210,14 @@ TestBase::TestBase (const std::string &file, const std::string &name) 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) { m_editable = editable; diff --git a/src/tl/tl/tlUnitTest.h b/src/tl/tl/tlUnitTest.h index 846e6c877..251f9a92f 100644 --- a/src/tl/tl/tlUnitTest.h +++ b/src/tl/tl/tlUnitTest.h @@ -294,6 +294,11 @@ public: */ 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 */ diff --git a/src/tl/tl/tlXMLParser.cc b/src/tl/tl/tlXMLParser.cc index a4fe81f93..eb2f98786 100644 --- a/src/tl/tl/tlXMLParser.cc +++ b/src/tl/tl/tlXMLParser.cc @@ -113,6 +113,11 @@ public: return m_error; } + void reset () + { + mp_stream->reset (); + } + private: std::auto_ptr mp_stream_holder; tl::InputStream *mp_stream; @@ -137,6 +142,12 @@ XMLSource::~XMLSource () mp_source = 0; } +void +XMLSource::reset () +{ + mp_source->reset (); +} + // -------------------------------------------------------------------- // XMLStringSource implementation @@ -345,6 +356,7 @@ XMLParser::parse (XMLSource &source, XMLStructureHandler &struct_handler) #include #include +#include namespace tl { @@ -356,7 +368,7 @@ class SAXHandler : public QXmlDefaultHandler { public: - SAXHandler (trureHandler *sh); + SAXHandler (XMLStructureHandler *sh); bool characters (const QString &ch); bool endElement (const QString &namespaceURI, const QString &localName, const QString &qName); @@ -369,13 +381,13 @@ public: private: QXmlLocator *mp_locator; - trureHandler *mp_struct_handler; + XMLStructureHandler *mp_struct_handler; }; // -------------------------------------------------------------------------------------------------------- // trureHandler implementation -SAXHandler::SAXHandler (trureHandler *sh) +SAXHandler::SAXHandler (XMLStructureHandler *sh) : QXmlDefaultHandler (), mp_locator (0), mp_struct_handler (sh) { // .. nothing yet .. @@ -429,7 +441,7 @@ bool SAXHandler::characters (const QString &t) { try { - mp_struct_handler->cdata (tl::to_string (t)); + mp_struct_handler->characters (tl::to_string (t)); } catch (tl::XMLException &ex) { throw tl::XMLLocatedException (ex.raw_msg (), mp_locator->lineNumber (), mp_locator->columnNumber ()); } catch (tl::Exception &ex) { @@ -490,6 +502,12 @@ XMLSource::~XMLSource () mp_source = 0; } +void +XMLSource::reset () +{ + mp_source->reset (); +} + // -------------------------------------------------------------------- // XMLStringSource implementation diff --git a/src/tl/tl/tlXMLParser.h b/src/tl/tl/tlXMLParser.h index c8c9d7359..848b9d714 100644 --- a/src/tl/tl/tlXMLParser.h +++ b/src/tl/tl/tlXMLParser.h @@ -312,13 +312,15 @@ class TL_PUBLIC XMLSource { public: XMLSource (); - virtual ~XMLSource (); + ~XMLSource (); - virtual XMLSourcePrivateData *source () + XMLSourcePrivateData *source () { return mp_source; } + void reset (); + protected: void set_source (XMLSourcePrivateData *source) { @@ -337,7 +339,7 @@ class TL_PUBLIC XMLStringSource : public XMLSource { public: XMLStringSource (const std::string &string); - virtual ~XMLStringSource (); + ~XMLStringSource (); }; /** @@ -349,7 +351,7 @@ class TL_PUBLIC XMLFileSource : public XMLSource public: XMLFileSource (const std::string &path); XMLFileSource (const std::string &path, const std::string &progress_message); - virtual ~XMLFileSource (); + ~XMLFileSource (); }; /** @@ -363,7 +365,7 @@ class TL_PUBLIC XMLStreamSource : public XMLSource public: XMLStreamSource (tl::InputStream &stream); XMLStreamSource (tl::InputStream &stream, const std::string &progress_message); - virtual ~XMLStreamSource (); + ~XMLStreamSource (); }; diff --git a/src/tl/unit_tests/tlFileUtils.cc b/src/tl/unit_tests/tlFileUtils.cc index 8d2831a10..1b6e385ed 100644 --- a/src/tl/unit_tests/tlFileUtils.cc +++ b/src/tl/unit_tests/tlFileUtils.cc @@ -58,7 +58,7 @@ TEST (2) adir.cd (QString::fromUtf8 ("a")); 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); tmp_dir.mkdir (QString::fromUtf8 ("a")); @@ -93,7 +93,7 @@ TEST (2) } 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 (b1dir.exists (), false); EXPECT_EQ (b2dir.exists (), false); @@ -104,7 +104,7 @@ TEST (3) { 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")); QDir adir = tmp_dir; @@ -132,10 +132,10 @@ TEST (3) 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")); - 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; EXPECT_EQ (acopydir.cd (QString::fromUtf8 ("acopy")), true);