List Info

Thread: KDE/kdevplatform/plugins/subversion




KDE/kdevplatform/plugins/subversion
user name
2008-03-18 17:28:38
SVN commit 787300 by apaku:

Just found a nice thread on the qt-interest list that queued
connections work automatically, without the need for any
"helper" object that lives in the non-gui-thread.
So remove all the helper classes and simply emit the signals
directly, Qt auto-connection will take care of the rest.

cc'ing the -devel list in case somebody else knows of
similar code
CCMAIL:kdevelop-develkdevelop.org

 M  +2 -9      svnblamejob.cpp  
 M  +0 -12     svnblamejob_p.h  
 M  +1 -5      svncatjob.cpp  
 M  +0 -13     svncatjob_p.h  
 M  +1 -5      svndiffjob.cpp  
 M  +0 -13     svndiffjob_p.h  
 M  +1 -4      svninfojob.cpp  
 M  +0 -13     svninfojob_p.h  
 M  +7 -78     svninternaljobbase.cpp  
 M  +0 -3      svninternaljobbase.h  
 M  +1 -6      svnlogjob.cpp  
 M  +0 -12     svnlogjob_p.h  
 M  +2 -5      svnstatusjob.cpp  
 M  +0 -13     svnstatusjob_p.h  


---
trunk/KDE/kdevplatform/plugins/subversion/svnblamejob.cpp
#787299:787300
 -41,17
+41,11 
 
 void SvnInternalBlameJob::run()
 {
-    BlameJobHelper helper;
-    connect( &helper, SIGNAL( blameLine( const
KDevelop::VcsAnnotationLine& ) ),
-             this, SIGNAL( blameLine( const
KDevelop::VcsAnnotationLine& ) ),
-             Qt::QueuedConnection );
-
-
     initBeforeRun();
 
     SvnClient cli(m_ctxt);
     connect( &cli, SIGNAL( lineReceived( const
KDevelop::VcsAnnotationLine& ) ),
-             &helper, SLOT( emitBlameLine( const
KDevelop::VcsAnnotationLine& ) ) );
+             this, SIGNAL( blameLine( const
KDevelop::VcsAnnotationLine& ) ) );
     try
     {
         QByteArray ba = location().path().toUtf8();
 -127,8
+121,7 
     }else
     {
         connect( m_job, SIGNAL( blameLine( const
KDevelop::VcsAnnotationLine& ) ),
-                 this, SLOT( blameLineReceived( const
KDevelop::VcsAnnotationLine& ) ),
-                 Qt::QueuedConnection );
+                 this, SLOT( blameLineReceived( const
KDevelop::VcsAnnotationLine& ) ) );
         kDebug(9510) << "blameging url:"
<< m_job->location();
         ThreadWeaver::Weaver::instance()->enqueue( m_job
);
     }
---
trunk/KDE/kdevplatform/plugins/subversion/svnblamejob_p.h
#787299:787300
 -27,18
+27,6 
 #include <vcsrevision.h>
 #include <vcsevent.h>
 
-class BlameJobHelper : public QObject
-{
-    Q_OBJECT
-public slots:
-    void emitBlameLine( const
KDevelop::VcsAnnotationLine& line )
-    {
-        emit blameLine( line );
-    }
-signals:
-    void blameLine( const KDevelop::VcsAnnotationLine&
);
-};
-
 class SvnInternalBlameJob : public SvnInternalJobBase
 {
     Q_OBJECT
--- trunk/KDE/kdevplatform/plugins/subversion/svncatjob.cpp
#787299:787300
 -44,10
+44,6 
 
 void SvnInternalCatJob::run()
 {
-    CatJobHelper helper;
-    connect( &helper, SIGNAL( gotContent( const
QString& ) ),
-           this, SIGNAL( gotContent( const QString& )
), Qt::QueuedConnection );
-
     initBeforeRun();
 
     SvnClient cli(m_ctxt);
 -72,7
+68,7 
         }
         svn::Revision srcRev =
createSvnCppRevisionFromVcsRevision( srcRevision() );
         content = QString::fromUtf8( cli.cat( svn::Path(
srcba.data() ), srcRev ).c_str() );
-        helper.emitContent( content );
+        emit gotContent( content );
     }catch( svn::ClientException ce )
     {
         kDebug(9510) << "Exception while doing a
diff: "
--- trunk/KDE/kdevplatform/plugins/subversion/svncatjob_p.h
#787299:787300
 -25,19
+25,6 
 #include <QVariant>
 #include <vcsrevision.h>
 
-class CatJobHelper : public QObject
-{
-    Q_OBJECT
-public:
-    void emitContent( const QString& diff )
-    {
-        emit gotContent( diff );
-    }
-signals:
-    void gotContent( const QString& );
-};
-
-
 class SvnInternalCatJob : public SvnInternalJobBase
 {
     Q_OBJECT
--- trunk/KDE/kdevplatform/plugins/subversion/svndiffjob.cpp
#787299:787300
 -52,10
+52,6 
 
 void SvnInternalDiffJob::run()
 {
-    DiffJobHelper helper;
-    connect( &helper, SIGNAL( gotDiff( const
QString& ) ),
-           this, SIGNAL( gotDiff( const QString& ) ),
Qt::QueuedConnection );
-
     initBeforeRun();
 
     SvnClient cli(m_ctxt);
 -136,7
+132,7 
                              dstRev, recursive(),
ignoreAncestry(),
                              noDiffOnDelete(),
ignoreContentType() );
         }
-        helper.emitDiff( diff );
+        emit gotDiff( diff );
 
     }catch( svn::ClientException ce )
     {
--- trunk/KDE/kdevplatform/plugins/subversion/svndiffjob_p.h
#787299:787300
 -25,19
+25,6 
 #include <QVariant>
 #include <vcsrevision.h>
 
-class DiffJobHelper : public QObject
-{
-    Q_OBJECT
-public:
-    void emitDiff( const QString& diff )
-    {
-        emit gotDiff( diff );
-    }
-signals:
-    void gotDiff( const QString& );
-};
-
-
 class SvnInternalDiffJob : public SvnInternalJobBase
 {
     Q_OBJECT
--- trunk/KDE/kdevplatform/plugins/subversion/svninfojob.cpp
#787299:787300
 -40,9
+40,6 
 void SvnInternalInfoJob::run()
 {
     initBeforeRun();
-    SvnInfoJobHelper help;
-    connect( &help, SIGNAL( gotInfo( const
SvnInfoHolder&) ),
-              this, SIGNAL( gotInfo( const
SvnInfoHolder&) ) );
     svn::Client cli(m_ctxt);
     try
     {
 -68,7
+65,7 
         h.workingCopyFileConflict = QString::fromUtf8(
e.conflictWrk() );
         h.propertyRejectFile = QString::fromUtf8(
e.prejfile() );
 
-        help.emitInfo( h );
+        emit gotInfo( h );
     }catch( svn::ClientException ce )
     {
         kDebug(9510) << "Exception while getting
info for file: "
--- trunk/KDE/kdevplatform/plugins/subversion/svninfojob_p.h
#787299:787300
 -24,19
+24,6 
 #include "svninternaljobbase.h"
 #include "svninfojob.h"
 
-class SvnInfoJobHelper : public QObject
-{
-    Q_OBJECT
-public:
-    void emitInfo( const SvnInfoHolder & state )
-    {
-        emit gotInfo( state );
-    }
-signals:
-    void gotInfo( const SvnInfoHolder& );
-
-};
-
 class SvnInternalInfoJob : public SvnInternalJobBase
 {
     Q_OBJECT
---
trunk/KDE/kdevplatform/plugins/subversion/svninternaljobbase
.cpp #787299:787300
 -42,51
+42,10 
 #include <svncpp/apr.hpp>
 #include <svncpp/revision.hpp>
 
-class JobHelper : public QObject
-{
-    friend class SvnInternalJobBase;
-    Q_OBJECT
-    public:
-        JobHelper()
-        {}
-        void emitNeedLogin( const QString& realm )
-        {
-            std::cerr << "Emitting login"
<< std::endl;
-            emit needLogin( realm );
-        }
-        void emitNeedCommitMessage()
-        {
-            std::cerr << "Emitting commit"
<< std::endl;
-            emit needCommitMessage();
-        }
-
-        void emitShowNotification( const QString& path,
const QString& msg )
-        {
-            emit showNotification( path, msg );
-        }
-        void emitNeedSslServerTrust( const QStringList&
failures, const QString& host, const QString&
print,
-                                 const QString& from,
const QString& until, const QString& issuer,
-                                 const QString& realm
)
-        {
-            std::cerr << "Emitting trust"
<< std::endl;
-            emit needSslServerTrust( failures, host, print,
from, until, issuer, realm );
-        }
-    signals:
-        void needLogin( const QString& );
-        void showNotification( const QString&, const
QString& );
-        void needCommitMessage();
-        void needSslServerTrust( const QStringList&,
const QString&, const QString&,
-                                 const QString&, const
QString&, const QString&,
-                                 const QString& );
-        void needSslClientCert( const QString& );
-        void needSslClientCertPassword( const QString&
);
-};
-
-
 SvnInternalJobBase::SvnInternalJobBase( SvnJobBase* parent
)
     : ThreadWeaver::Job( parent ), m_ctxt( new
svn::Context() ),
       m_guiSemaphore( 0 ), m_mutex( new QMutex() ),
-      helper(0), m_success( true ), sendFirstDelta( false
)
+      m_success( true ), sendFirstDelta( false )
 {
     m_ctxt->setListener(this);
     connect( this, SIGNAL( failed( ThreadWeaver::Job* ) ),
 -99,7
+58,6 
 
 SvnInternalJobBase::~SvnInternalJobBase()
 {
-    delete helper; helper = 0;
 }
 
 bool SvnInternalJobBase::contextGetLogin( const
std::string& realm,
 -107,9
+65,7 
                         bool& maySave )
 {
 
-    std::cerr << "login" <<
std::endl;
-
-    helper->emitNeedLogin( QString::fromUtf8(
realm.c_str() )  );
+    emit needLogin( QString::fromUtf8( realm.c_str() )  );
     m_guiSemaphore.acquire( 1 );
     QMutexLocker l(m_mutex);
     if( m_login_username.isEmpty() ||
m_login_password.isEmpty() )
 -125,9
+81,6 
                     svn_wc_notify_state_t contentState,
                     svn_wc_notify_state_t propState,
svn_revnum_t rev )
 {
-    if( !helper )
-        return;
-    std::cerr << "notify"  <<
std::endl;
     QString notifyString;
     switch( action ){
         case svn_wc_notify_add:
 -233,7
+186,7 
             break;
     }
     kDebug(9510) << "showing notification:"
<< path << notifyString ;
-    helper->emitShowNotification( QString::fromUtf8(
path ), notifyString );
+    emit showNotification( QString::fromUtf8( path ),
notifyString );
 }
 
 bool SvnInternalJobBase::contextCancel()
 -244,8
+197,7 
 
 bool SvnInternalJobBase::contextGetLogMessage(
std::string& msg )
 {
-    std::cerr << "logmsg" <<
std::endl;
-    helper->emitNeedCommitMessage();
+    emit needCommitMessage();
     m_guiSemaphore.acquire( 1 );
     QMutexLocker l( m_mutex );
     QByteArray ba = m_commitMessage.toUtf8();
 -255,25
+207,6 
 
 void SvnInternalJobBase::initBeforeRun()
 {
-    helper = new JobHelper();
-
-    connect( helper, SIGNAL( needLogin( const QString&
) ),
-             this, SIGNAL( needLogin( const QString& )
) );
-    connect( helper, SIGNAL( showNotification( const
QString&, const QString& ) ),
-             this, SIGNAL( showNotification( const
QString&, const QString& ) ) );
-    connect( helper, SIGNAL( needCommitMessage() ),
-             this, SIGNAL( needCommitMessage() ) );
-    connect( helper, SIGNAL( needSslServerTrust( const
QStringList&, const QString&,
-                                 const QString&, const
QString&, const QString&,
-                                 const QString&, const
QString& ) ),
-             this, SIGNAL( needSslServerTrust( const
QStringList&, const QString&,
-                                 const QString&, const
QString&, const QString&,
-                                 const QString&, const
QString& ) ) );
-    connect( helper, SIGNAL( needSslClientCert( const
QString& ) ),
-             this, SIGNAL( needSslClientCert( const
QString& ) ) );
-    connect( helper, SIGNAL( needSslClientCertPassword(
const QString& ) ),
-             this, SIGNAL( needSslClientCertPassword( const
QString& ) ) );
-
     connect( this, SIGNAL( needCommitMessage() ),
              parent(), SLOT( askForCommitMessage() ),
Qt::QueuedConnection );
     connect( this, SIGNAL( needLogin( const QString& )
),
 -297,7
+230,6 
         apr_uint32_t& acceptedFailures )
 {
 
-    std::cerr << "server trust" <<
std::endl;
     std::string host = data.hostname;
     std::string print = data.fingerprint;
     std::string from = data.validFrom;
 -326,7
+258,7 
     {
         failures << i18n("Other unknown
error.");
     }
-    emit helper->emitNeedSslServerTrust( failures,
+    emit needSslServerTrust( failures,
                                      QString::fromUtf8(
host.c_str() ),
                                      QString::fromUtf8(
print.c_str() ),
                                      QString::fromUtf8(
from.c_str() ),
 -340,8
+272,7 
 
 bool SvnInternalJobBase::contextSslClientCertPrompt(
std::string& cert )
 {
-    std::cerr << "Client cert" <<
std::endl;
-    emit helper->needSslClientCert( QString::fromUtf8(
cert.c_str() ) );
+    emit needSslClientCert( QString::fromUtf8( cert.c_str()
) );
     m_guiSemaphore.acquire( 1 );
     return true;
 }
 -349,8
+280,7 
 bool SvnInternalJobBase::contextSslClientCertPwPrompt(
std::string& pw, const std::string& realm,
                                     bool& maySave )
 {
-    std::cerr << "Client cert PW" <<
std::endl;
-    emit helper->needSslClientCertPassword(
QString::fromUtf8( realm.c_str() ) );
+    emit needSslClientCertPassword( QString::fromUtf8(
realm.c_str() ) );
     m_guiSemaphore.acquire( 1 );
     return false;
 }
 -436,4
+366,3 
 
 
 #include "svninternaljobbase.moc"
-#include "moc_svninternaljobbase.cpp"
---
trunk/KDE/kdevplatform/plugins/subversion/svninternaljobbase
.h #787299:787300
 -46,8
+46,6 
 class SvnJobBase;
 class QMutex;
 class QSemaphore;
-class JobHelper;
-
 class SvnInternalJobBase : public ThreadWeaver::Job, public
svn::ContextListener
 {
     Q_OBJECT
 -99,7
+97,6 
 
 protected:
     QMutex* m_mutex;
-    JobHelper* helper;
     bool m_success;
     void setErrorMessage( const QString& );
 private:
--- trunk/KDE/kdevplatform/plugins/subversion/svnlogjob.cpp
#787299:787300
 -41,16
+41,11 
 
 void SvnInternalLogJob::run()
 {
-    LogJobHelper helper;
-    connect( &helper, SIGNAL( logEvent( const
KDevelop::VcsEvent& ) ),
-           this, SIGNAL( logEvent( const
KDevelop::VcsEvent& ) ), Qt::QueuedConnection );
-
-
     initBeforeRun();
 
     SvnClient cli(m_ctxt);
     connect( &cli, SIGNAL( logEventReceived( const
KDevelop::VcsEvent& ) ),
-             &helper, SLOT(emitLogEvent( const
KDevelop::VcsEvent&) ) );
+             this, SIGNAL(logEvent( const
KDevelop::VcsEvent&) ) );
     try
     {
         QByteArray ba = location().path().toUtf8();
--- trunk/KDE/kdevplatform/plugins/subversion/svnlogjob_p.h
#787299:787300
 -26,18
+26,6 
 #include <vcsrevision.h>
 #include <vcsevent.h>
 
-class LogJobHelper : public QObject
-{
-    Q_OBJECT
-public slots:
-    void emitLogEvent( const KDevelop::VcsEvent& ev )
-    {
-        emit logEvent( ev );
-    }
-signals:
-    void logEvent( const KDevelop::VcsEvent& );
-};
-
 class SvnInternalLogJob : public SvnInternalJobBase
 {
     Q_OBJECT
---
trunk/KDE/kdevplatform/plugins/subversion/svnstatusjob.cpp
#787299:787300
 -100,9
+100,6 
 void SvnInternalStatusJob::run()
 {
     kDebug(9510) << "Running internal status job
with urls:" << m_locations;
-    StatusJobHelper helper;
-    connect( &helper, SIGNAL( gotNewStatus( const
KDevelop::VcsStatusInfo& ) ),
-           this, SIGNAL( gotNewStatus( const
KDevelop::VcsStatusInfo& ) ), Qt::QueuedConnection );
     initBeforeRun();
 
     svn::Client cli(m_ctxt);
 -122,7
+119,7 
                     KDevelop::VcsStatusInfo info;
                     info.setUrl( url );
                     info.setState( getState( *it ) );
-                    helper.emitNewStatus( info );
+                    emit gotNewStatus( info );
                 }
             }else
             {
 -132,7
+129,7 
                 KDevelop::VcsStatusInfo info;
                 info.setUrl( url );
                 info.setState( getState( st ) );
-                helper.emitNewStatus( info );
+                emit gotNewStatus( info );
             }
         }catch( svn::ClientException ce )
         {
---
trunk/KDE/kdevplatform/plugins/subversion/svnstatusjob_p.h
#787299:787300
 -28,18
+28,6 
 #include <vcsstatusinfo.h>
 #include <kurl.h>
 
-class StatusJobHelper : public QObject
-{
-    Q_OBJECT
-public:
-    void emitNewStatus( const KDevelop::VcsStatusInfo&
state )
-    {
-        emit gotNewStatus( state );
-    }
-signals:
-    void gotNewStatus( const KDevelop::VcsStatusInfo&
);
-};
-
 class SvnInternalStatusJob : public SvnInternalJobBase
 {
     Q_OBJECT
 -57,7
+45,6 
 private:
     KUrl::List m_locations;
     bool m_recursive;
-    StatusJobHelper* m_stathelper;
 };
 
 #endif

_______________________________________________
KDevelop-devel mailing list
KDevelop-develkdevelop.org
https://barney.cs.uni-potsdam.de/mailman/listinf
o/kdevelop-devel

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )