diff options
Diffstat (limited to 'languages/cpp/backgroundparser.cpp')
| -rw-r--r-- | languages/cpp/backgroundparser.cpp | 142 | 
1 files changed, 71 insertions, 71 deletions
| diff --git a/languages/cpp/backgroundparser.cpp b/languages/cpp/backgroundparser.cpp index ed51d0c6..d3f9c2ee 100644 --- a/languages/cpp/backgroundparser.cpp +++ b/languages/cpp/backgroundparser.cpp @@ -18,7 +18,7 @@  #include "kdevdeepcopy.h"  #include "kdevdriver.h" -#include <qmutex.h> +#include <tqmutex.h>  #include <kparts/part.h>  #include <ktexteditor/editinterface.h> @@ -32,11 +32,11 @@  #include <kdebug.h>  #include <kapplication.h> -#include <qfile.h> -#include <qfileinfo.h> -#include <qtextstream.h> +#include <tqfile.h> +#include <tqfileinfo.h> +#include <tqtextstream.h>  #include <list> -#include <qdatastream.h> +#include <tqdatastream.h>  class BackgroundKDevDriver : public KDevDriver { @@ -44,7 +44,7 @@ public:  	BackgroundKDevDriver( CppSupportPart* cppSupport, BackgroundParser* bp ) : KDevDriver( cppSupport, false ), m_backgroundParser(bp) {  	}  	virtual void fileParsed( ParsedFile& fileName ); -	virtual void addDependence( const QString& fileName, const Dependence& dep ); +	virtual void addDependence( const TQString& fileName, const Dependence& dep );  private:  	BackgroundParser* m_backgroundParser;  }; @@ -53,8 +53,8 @@ private:  class KDevSourceProvider: public SourceProvider  {  public: -	//Deadlock is a mutex that is locked when KDevSourceProvider::contents(..) is used, and that should be unlocked before QApplication is locked(that way a deadlock where the thread that holds the QApplication-mutex and tries to lock the given mutex, while the thread that calls contents(..) and holds the given mutex and tries to lock the QApplication-mutex, cannot happen) -	KDevSourceProvider( CppSupportPart* cppSupport, QMutex& deadlock ) +	//Deadlock is a mutex that is locked when KDevSourceProvider::contents(..) is used, and that should be unlocked before TQApplication is locked(that way a deadlock where the thread that holds the QApplication-mutex and tries to lock the given mutex, while the thread that calls contents(..) and holds the given mutex and tries to lock the QApplication-mutex, cannot happen) +	KDevSourceProvider( CppSupportPart* cppSupport, TQMutex& deadlock )  		: m_cppSupport( cppSupport ),  		m_readFromDisk( false ),  		m_deadlock(deadlock) @@ -69,9 +69,9 @@ public:  		return m_readFromDisk;  	} -	virtual QString contents( const QString& fileName ) +	virtual TQString contents( const TQString& fileName )  	{ -		QString contents = QString::null; +		TQString contents = TQString::null;  		if ( !m_readFromDisk )  		{ @@ -81,8 +81,8 @@ public:  			//kdDebug(9007) << "-------> kapp locked" << endl; -			QPtrList<KParts::Part> parts( *m_cppSupport->partController() ->parts() ); -			QPtrListIterator<KParts::Part> it( parts ); +			TQPtrList<KParts::Part> parts( *m_cppSupport->partController() ->parts() ); +			TQPtrListIterator<KParts::Part> it( parts );  			while ( it.current() )  			{  				KTextEditor::Document * doc = dynamic_cast<KTextEditor::Document*>( it.current() ); @@ -92,7 +92,7 @@ public:  				if ( !doc || !editIface || doc->url().path() != fileName )  					continue; -				contents = QString( editIface->text().ascii() ); // deep copy +				contents = TQString( editIface->text().ascii() ); // deep copy  				//kdDebug(9007) << "-------> kapp unlocked" << endl; @@ -105,12 +105,12 @@ public:  			//kdDebug(9007) << "-------> kapp unlocked" << endl;  		} -		if( m_readFromDisk || contents == QString::null ) +		if( m_readFromDisk || contents == TQString::null )  		{ -			QFile f( fileName ); +			TQFile f( fileName );  			if ( f.open( IO_ReadOnly ) )  			{ -				QTextStream stream( &f ); +				TQTextStream stream( &f );  				contents = stream.read();  				f.close();  			} @@ -119,7 +119,7 @@ public:  		return contents;  	} -	virtual bool isModified( const QString& fileName ) +	virtual bool isModified( const TQString& fileName )  	{  		bool ret = false;  		m_deadlock.unlock(); @@ -139,7 +139,7 @@ public:  private:  	CppSupportPart* m_cppSupport;  	bool m_readFromDisk; -	QMutex& m_deadlock; +	TQMutex& m_deadlock;  private:  	KDevSourceProvider( const KDevSourceProvider& source );  	void operator = ( const KDevSourceProvider& source ); @@ -156,52 +156,52 @@ public:  	bool isEmpty() const  	{ -		QMutexLocker locker( &m_mutex ); +		TQMutexLocker locker( &m_mutex );  		return m_fileList.empty();  	}  	uint count() const  	{ -		QMutexLocker locker( &m_mutex ); +		TQMutexLocker locker( &m_mutex );  		return m_fileList.size();  	}  	QPair<SafeString, bool> front() const  	{ -		QMutexLocker locker( &m_mutex ); +		TQMutexLocker locker( &m_mutex );  		return m_fileList.front();  	}  	void clear()  	{ -		QMutexLocker locker( &m_mutex ); +		TQMutexLocker locker( &m_mutex );  		m_fileList.clear();  	} -	void push_front( const QString& fileName, bool readFromDisk = false ) +	void push_front( const TQString& fileName, bool readFromDisk = false )  	{  		SafeString s( fileName.ascii() ); -		QMutexLocker locker( &m_mutex ); +		TQMutexLocker locker( &m_mutex );  		m_fileList.push_front( qMakePair( s, readFromDisk ) );  	} -	void push_back( const QString& fileName, bool readFromDisk = false ) +	void push_back( const TQString& fileName, bool readFromDisk = false )  	{  	        SafeString s( fileName.ascii() ); -		QMutexLocker locker( &m_mutex ); +		TQMutexLocker locker( &m_mutex );  		m_fileList.push_back( qMakePair( s, readFromDisk ) );  	}  	void pop_front()  	{ -		QMutexLocker locker( &m_mutex ); +		TQMutexLocker locker( &m_mutex );  		m_fileList.pop_front();  	} -	int count( const QString& fileName ) const { +	int count( const TQString& fileName ) const {  		int c = 0; -		QMutexLocker locker( &m_mutex ); +		TQMutexLocker locker( &m_mutex );  		ListType::const_iterator it = m_fileList.begin();  		while ( it != m_fileList.end() )  		{ @@ -214,15 +214,15 @@ public:    QPair<SafeString, bool> takeFront()    { -    QMutexLocker locker( &m_mutex ); +    TQMutexLocker locker( &m_mutex );      QPair<SafeString, bool> ret = m_fileList.front();      m_fileList.pop_front();      return ret;    } -	bool contains( const QString& fileName ) const +	bool contains( const TQString& fileName ) const  	{ -		QMutexLocker locker( &m_mutex ); +		TQMutexLocker locker( &m_mutex );  		ListType::const_iterator it = m_fileList.begin();  		while ( it != m_fileList.end() )  		{ @@ -233,9 +233,9 @@ public:  		return false;  	} -	void remove( const QString& fileName ) +	void remove( const TQString& fileName )  	{ -		QMutexLocker locker( &m_mutex ); +		TQMutexLocker locker( &m_mutex );  		ListType::iterator it = m_fileList.begin();  		while ( it != m_fileList.end() )  		{ @@ -247,20 +247,20 @@ public:  	}  private: -	mutable QMutex m_mutex; +	mutable TQMutex m_mutex;  	ListType m_fileList;  }; -BackgroundParser::BackgroundParser( CppSupportPart* part, QWaitCondition* consumed ) +BackgroundParser::BackgroundParser( CppSupportPart* part, TQWaitCondition* consumed )  : m_consumed( consumed ), m_cppSupport( part ), m_close( false ), m_saveMemory( false )  {  	m_fileList = new SynchronizedFileList();  	m_driver = new BackgroundKDevDriver( m_cppSupport, this );  	m_driver->setSourceProvider( new KDevSourceProvider( m_cppSupport,  m_mutex ) ); -	QString conf_file_name = m_cppSupport->specialHeaderName(); +	TQString conf_file_name = m_cppSupport->specialHeaderName();  	m_mutex.lock(); -	if ( QFile::exists( conf_file_name ) ) +	if ( TQFile::exists( conf_file_name ) )  		m_driver->parseFile( conf_file_name, true, true, true );  	m_mutex.unlock(); @@ -278,9 +278,9 @@ BackgroundParser::~BackgroundParser()  	m_fileList = 0;  } -void BackgroundParser::addFile( const QString& fileName, bool readFromDisk ) +void BackgroundParser::addFile( const TQString& fileName, bool readFromDisk )  { -	QString fn = deepCopy( fileName ); +	TQString fn = deepCopy( fileName );    //bool added = false;  	/*if ( !m_fileList->contains( fn ) ) @@ -294,9 +294,9 @@ void BackgroundParser::addFile( const QString& fileName, bool readFromDisk )  		m_canParse.wakeAll();  } -void BackgroundParser::addFileFront( const QString& fileName, bool readFromDisk ) +void BackgroundParser::addFileFront( const TQString& fileName, bool readFromDisk )  { -	QString fn = deepCopy( fileName ); +	TQString fn = deepCopy( fileName );  	bool added = false;  	/*if ( m_fileList->contains( fn ) ) @@ -312,9 +312,9 @@ void BackgroundParser::addFileFront( const QString& fileName, bool readFromDisk  void BackgroundParser::removeAllFiles()  {  	kdDebug( 9007 ) << "BackgroundParser::removeAllFiles()" << endl; -	QMutexLocker locker( &m_mutex ); +	TQMutexLocker locker( &m_mutex ); -	QMap<QString, Unit*>::Iterator it = m_unitDict.begin(); +	TQMap<TQString, Unit*>::Iterator it = m_unitDict.begin();  	while ( it != m_unitDict.end() )  	{  		Unit * unit = it.data(); @@ -329,9 +329,9 @@ void BackgroundParser::removeAllFiles()  	m_isEmpty.wakeAll();  } -void BackgroundParser::removeFile( const QString& fileName ) +void BackgroundParser::removeFile( const TQString& fileName )  { -	QMutexLocker locker( &m_mutex ); +	TQMutexLocker locker( &m_mutex );  	Unit* unit = findUnit( fileName );  	if ( unit ) @@ -347,7 +347,7 @@ void BackgroundParser::removeFile( const QString& fileName )  		m_isEmpty.wakeAll();  } -void BackgroundKDevDriver::addDependence( const QString& fileName, const Dependence& dep ) { +void BackgroundKDevDriver::addDependence( const TQString& fileName, const Dependence& dep ) {  	//give waiting threads a chance to perform their actions  	m_backgroundParser->m_mutex.unlock();  	m_backgroundParser->m_mutex.lock(); @@ -358,7 +358,7 @@ void BackgroundKDevDriver::fileParsed( ParsedFile& fileName ) {  	m_backgroundParser->fileParsed( fileName );  } -void BackgroundParser::parseFile( const QString& fileName, bool readFromDisk, bool lock ) +void BackgroundParser::parseFile( const TQString& fileName, bool readFromDisk, bool lock )  {  	if( lock )  		m_mutex.lock(); @@ -374,9 +374,9 @@ void BackgroundParser::parseFile( const QString& fileName, bool readFromDisk, bo          m_mutex.unlock();  } -QValueList<Problem> cloneProblemList( const QValueList<Problem>& list ) { -	QValueList<Problem> ret; -	for( QValueList<Problem>::const_iterator it = list.begin(); it != list.end(); ++it ) { +TQValueList<Problem> cloneProblemList( const TQValueList<Problem>& list ) { +	TQValueList<Problem> ret; +	for( TQValueList<Problem>::const_iterator it = list.begin(); it != list.end(); ++it ) {  		ret << Problem( *it, true );  	}  	return ret; @@ -389,13 +389,13 @@ void BackgroundParser::fileParsed( ParsedFile& file ) {  	ParsedFilePointer translationUnit;  	//Since the lexer-cache keeps many QStrings like macro-names used in the background, everything must be copied here. The safest solution is just  	//serializing and deserializing the whole thing(the serialization does not respect the AST, but that can be copied later because that's safe) -	QMemArray<char> data; +	TQMemArray<char> data;  	{ -	  QDataStream stream( data, IO_WriteOnly ); +	  TQDataStream stream( data, IO_WriteOnly );  	  translationUnitUnsafe->write( stream );  	}  	{ -	  QDataStream stream( data, IO_ReadOnly ); +	  TQDataStream stream( data, IO_ReadOnly );  	  translationUnit = new ParsedFile( stream );  	} @@ -422,24 +422,24 @@ void BackgroundParser::fileParsed( ParsedFile& file ) {  	KApplication::postEvent( m_cppSupport, new FileParsedEvent( file.fileName(), unit->problems, m_readFromDisk ) ); -	m_currentFile = QString::null; +	m_currentFile = TQString::null;    if ( m_fileList->isEmpty() )  		m_isEmpty.wakeAll();	  } -Unit* BackgroundParser::findUnit( const QString& fileName ) +Unit* BackgroundParser::findUnit( const TQString& fileName )  { -	QMap<QString, Unit*>::Iterator it = m_unitDict.find( fileName ); +	TQMap<TQString, Unit*>::Iterator it = m_unitDict.find( fileName );  	return it != m_unitDict.end() ? *it : 0;  } -bool BackgroundParser::hasTranslationUnit( const QString& fileName ) { -	QMap<QString, Unit*>::Iterator it = m_unitDict.find( fileName ); +bool BackgroundParser::hasTranslationUnit( const TQString& fileName ) { +	TQMap<TQString, Unit*>::Iterator it = m_unitDict.find( fileName );  	return it != m_unitDict.end();  } -ParsedFilePointer BackgroundParser::translationUnit( const QString& fileName ) +ParsedFilePointer BackgroundParser::translationUnit( const TQString& fileName )  {  	Unit * u = findUnit( fileName );  	if ( u == 0 ) @@ -453,7 +453,7 @@ ParsedFilePointer BackgroundParser::translationUnit( const QString& fileName )  	return u->translationUnit;  } -QValueList<Problem> BackgroundParser::problems( const QString& fileName, bool readFromDisk, bool forceParse ) +TQValueList<Problem> BackgroundParser::problems( const TQString& fileName, bool readFromDisk, bool forceParse )  {      Q_UNUSED(readFromDisk);  	Unit * u = findUnit( fileName ); @@ -465,13 +465,13 @@ QValueList<Problem> BackgroundParser::problems( const QString& fileName, bool re          u = parseFile( fileName, readFromDisk ); */  	} -	return u ? u->problems : QValueList<Problem>(); +	return u ? u->problems : TQValueList<Problem>();  }  void BackgroundParser::close()  {    { -	QMutexLocker locker( &m_mutex ); +	TQMutexLocker locker( &m_mutex );  	m_close = true;  	m_canParse.wakeAll();    } @@ -484,28 +484,28 @@ void BackgroundParser::close()  bool BackgroundParser::filesInQueue()  { -	QMutexLocker locker( &m_mutex ); +	TQMutexLocker locker( &m_mutex );  	return m_fileList->count() || !m_currentFile.isEmpty();  } -int BackgroundParser::countInQueue( const QString& file ) const { +int BackgroundParser::countInQueue( const TQString& file ) const {  	return m_fileList->count( file );  }  void BackgroundParser::updateParserConfiguration()  { -	QMutexLocker locker( &m_mutex ); +	TQMutexLocker locker( &m_mutex );  	m_driver->setup(); -	QString conf_file_name = m_cppSupport->specialHeaderName(); +	TQString conf_file_name = m_cppSupport->specialHeaderName();  	m_driver->removeAllMacrosInFile( conf_file_name );  	m_driver->parseFile( conf_file_name, true, true, true );  }  void BackgroundParser::run()  { -	// (void) m_cppSupport->codeCompletion()->repository()->getEntriesInScope( QStringList(), false ); +	// (void) m_cppSupport->codeCompletion()->repository()->getEntriesInScope( TQStringList(), false );  	while ( !m_close )  	{ @@ -527,20 +527,20 @@ void BackgroundParser::run()  			break;  		QPair<SafeString, bool> entry = m_fileList->takeFront(); -		QString fileName = entry.first.c_str(); +		TQString fileName = entry.first.c_str();  		bool readFromDisk = entry.second;  		m_currentFile = deepCopy(fileName);  		( void ) parseFile( fileName, readFromDisk, true ); -		m_currentFile = QString::null; +		m_currentFile = TQString::null;  	}  	kdDebug( 9007 ) << "!!!!!!!!!!!!!!!!!! BG PARSER DESTROYED !!!!!!!!!!!!" << endl;  //	adymo: commented to fix #88091 -//	QThread::exit(); +//	TQThread::exit();  }  void BackgroundParser::saveMemory() { | 
