[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdenetwork/kopete/protocols/oscar/liboscar
From: Roman Jarosz <kedgedev () centrum ! cz>
Date: 2008-10-17 8:01:14
Message-ID: 1224230474.369432.21403.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 872433 by rjarosz:
Fix crash caused by my commit 871882, sorry!
The StageOne/Two tasks are already deleted when connection is closed.
Delete StageTwoTask right after the task has finished, so we don't leave it in memory \
till we close connection.
BUG: 172997
CCBUG: 160359
M +55 -62 client.cpp
M +0 -5 client.h
--- trunk/KDE/kdenetwork/kopete/protocols/oscar/liboscar/client.cpp #872432:872433
@@ -21,10 +21,11 @@
#include "client.h"
-#include <qtimer.h>
+#include <QTimer>
#include <QList>
#include <QByteArray>
-#include <qtextcodec.h>
+#include <QPointer>
+#include <QTextCodec>
#include <QtNetwork/QTcpSocket>
#include <kdebug.h> //for kDebug()
@@ -106,6 +107,9 @@
enum { StageOne, StageTwo };
int stage;
+ StageOneLoginTask* loginTask;
+ QPointer<StageTwoLoginTask> loginTaskTwo;
+
//Protocol specific data
bool isIcq;
bool redirectRequested;
@@ -164,8 +168,6 @@
:QObject( parent )
{
setObjectName( "oscarclient" );
- m_loginTask = 0L;
- m_loginTaskTwo = 0L;
d = new ClientPrivate;
d->tzoffset = 0;
@@ -189,6 +191,8 @@
d->icqTlvInfoTask = 0L;
d->userInfoTask = 0L;
d->stage = ClientPrivate::StageOne;
+ d->loginTask = 0L;
+ d->loginTaskTwo = 0L;
d->typingNotifyTask = 0L;
d->ssiModifyTask = 0L;
d->awayMsgRequestTimer = new QTimer();
@@ -222,8 +226,8 @@
d->connections.append( c );
if ( auth == true )
{
- m_loginTask = new StageOneLoginTask( c->rootTask() );
- connect( m_loginTask, SIGNAL( finished() ), this, SLOT( lt_loginFinished() ) );
+ d->loginTask = new StageOneLoginTask( c->rootTask() );
+ connect( d->loginTask, SIGNAL( finished() ), this, SLOT( lt_loginFinished() ) );
}
connect( c, SIGNAL( socketError( int, const QString& ) ), this, SLOT( \
determineDisconnection( int, const QString& ) ) ); @@ -261,18 +265,6 @@
d->awayMsgRequestQueue.clear();
d->connections.clear();
- if ( m_loginTask )
- {
- m_loginTask->deleteLater();
- m_loginTask = 0;
- }
-
- if ( m_loginTaskTwo )
- {
- m_loginTaskTwo->deleteLater();
- m_loginTaskTwo = 0;
- }
-
deleteStaticTasks();
//don't clear the stored status between stage one and two
@@ -408,8 +400,8 @@
void Client::streamConnected()
{
kDebug(OSCAR_RAW_DEBUG) ;
- if ( m_loginTaskTwo )
- m_loginTaskTwo->go();
+ if ( d->loginTaskTwo )
+ d->loginTaskTwo->go( Task::AutoDelete );
}
void Client::lt_loginFinished()
@@ -425,22 +417,20 @@
ServiceSetupTask* ssTask = new ServiceSetupTask( \
d->connections.defaultConnection()->rootTask() ); connect( ssTask, SIGNAL( \
finished() ), this, SLOT( serviceSetupFinished() ) ); ssTask->go( Task::AutoDelete \
); //fire and forget
- m_loginTaskTwo->deleteLater();
- m_loginTaskTwo = 0;
}
else if ( d->stage == ClientPrivate::StageOne )
{
kDebug(OSCAR_RAW_DEBUG) << "stage one login done";
- disconnect( m_loginTask, SIGNAL( finished() ), this, SLOT( lt_loginFinished() ) );
+ disconnect( d->loginTask, SIGNAL( finished() ), this, SLOT( lt_loginFinished() ) \
);
- if ( m_loginTask->statusCode() == 0 ) //we can start stage two
+ if ( d->loginTask->statusCode() == 0 ) //we can start stage two
{
kDebug(OSCAR_RAW_DEBUG) << "no errors from stage one. moving to stage two";
//cache these values since they'll be deleted when we close the connections \
(which deletes the tasks)
- d->host = m_loginTask->bosServer();
- d->port = m_loginTask->bosPort().toUInt();
- d->cookie = m_loginTask->loginCookie();
+ d->host = d->loginTask->bosServer();
+ d->port = d->loginTask->bosPort().toUInt();
+ d->cookie = d->loginTask->loginCookie();
close();
QTimer::singleShot( 100, this, SLOT(startStageTwo() ) );
d->stage = ClientPrivate::StageTwo;
@@ -450,6 +440,8 @@
kDebug(OSCAR_RAW_DEBUG) << "errors reported. not moving to stage two";
close(); //deletes the connections for us
}
+ d->loginTask->deleteLater();
+ d->loginTask = 0;
}
}
@@ -461,11 +453,10 @@
new CloseConnectionTask( c->rootTask() );
//create the new login task
- m_loginTaskTwo = new StageTwoLoginTask( c->rootTask() );
- m_loginTaskTwo->setCookie( d->cookie );
- QObject::connect( m_loginTaskTwo, SIGNAL( finished() ), this, SLOT( \
lt_loginFinished() ) ); + d->loginTaskTwo = new StageTwoLoginTask( c->rootTask() );
+ d->loginTaskTwo->setCookie( d->cookie );
+ QObject::connect( d->loginTaskTwo, SIGNAL( finished() ), this, SLOT( \
lt_loginFinished() ) );
-
//connect
QObject::connect( c, SIGNAL( connected() ), this, SLOT( streamConnected() ) );
connectToServer( c, d->host, d->port, false ) ;
@@ -1548,9 +1539,9 @@
Connection* c = createConnection();
//create the new login task
- m_loginTaskTwo = new StageTwoLoginTask( c->rootTask() );
- m_loginTaskTwo->setCookie( cookie );
- QObject::connect( m_loginTaskTwo, SIGNAL( finished() ), this, SLOT( \
serverRedirectFinished() ) ); + d->loginTaskTwo = new StageTwoLoginTask( \
c->rootTask() ); + d->loginTaskTwo->setCookie( cookie );
+ QObject::connect( d->loginTaskTwo, SIGNAL( finished() ), this, SLOT( \
serverRedirectFinished() ) );
//connect
connectToServer( c, realHost, realPort.toInt(), false );
@@ -1562,7 +1553,9 @@
void Client::serverRedirectFinished()
{
- if ( m_loginTaskTwo && m_loginTaskTwo->statusCode() == 0 )
+ StageTwoLoginTask* loginTaskTwo = qobject_cast<StageTwoLoginTask*>( sender() );
+
+ if ( loginTaskTwo && loginTaskTwo->statusCode() == 0 )
{ //stage two was successful
Connection* c = d->connections.connectionForFamily( d->currentRedirect );
if ( !c )
@@ -1585,33 +1578,33 @@
emit chatNavigationConnected();
}
- if ( d->currentRedirect == 0x000E )
- {
- //HACK! such abuse! think of a better way
- if ( !m_loginTaskTwo )
- {
- kWarning(OSCAR_RAW_DEBUG) << "no login task to get connection from!";
- emit redirectionFinished( d->currentRedirect );
- return;
- }
-
- Connection* c = m_loginTaskTwo->client();
- QString roomName = d->connections.chatRoomForConnection( c );
- Oscar::WORD exchange = d->connections.exchangeForConnection( c );
- if ( c )
- {
- kDebug(OSCAR_RAW_DEBUG) << "setting up chat connection";
- ChatServiceTask* cst = new ChatServiceTask( c->rootTask(), exchange, \
roomName );
- connect( cst, SIGNAL( userJoinedChat( Oscar::Oscar::WORD, const \
QString&, const QString& ) ),
- this, SIGNAL( userJoinedChat( Oscar::Oscar::WORD, const \
QString&, const QString& ) ) );
- connect( cst, SIGNAL( userLeftChat( Oscar::Oscar::WORD, const QString&, \
const QString& ) ),
- this, SIGNAL( userLeftChat( Oscar::Oscar::WORD, const QString&, \
const QString& ) ) );
- connect( cst, SIGNAL( newChatMessage( const Oscar::Message& ) ),
- this, SIGNAL( messageReceived( const Oscar::Message& ) ) );
- }
- emit chatRoomConnected( exchange, roomName );
- }
-
+ if ( d->currentRedirect == 0x000E )
+ {
+ //HACK! such abuse! think of a better way
+ if ( !loginTaskTwo )
+ {
+ kWarning(OSCAR_RAW_DEBUG) << "no login task to get connection from!";
+ emit redirectionFinished( d->currentRedirect );
+ return;
+ }
+
+ Connection* c = loginTaskTwo->client();
+ QString roomName = d->connections.chatRoomForConnection( c );
+ Oscar::WORD exchange = d->connections.exchangeForConnection( c );
+ if ( c )
+ {
+ kDebug(OSCAR_RAW_DEBUG) << "setting up chat connection";
+ ChatServiceTask* cst = new ChatServiceTask( c->rootTask(), exchange, roomName );
+ connect( cst, SIGNAL( userJoinedChat( Oscar::Oscar::WORD, const QString&, const \
QString& ) ), + this, SIGNAL( userJoinedChat( Oscar::Oscar::WORD, const \
QString&, const QString& ) ) ); + connect( cst, SIGNAL( userLeftChat( \
Oscar::Oscar::WORD, const QString&, const QString& ) ), + this, SIGNAL( \
userLeftChat( Oscar::Oscar::WORD, const QString&, const QString& ) ) ); + connect( \
cst, SIGNAL( newChatMessage( const Oscar::Message& ) ), + this, SIGNAL( \
messageReceived( const Oscar::Message& ) ) ); + }
+ emit chatRoomConnected( exchange, roomName );
+ }
+
emit redirectionFinished( d->currentRedirect );
}
--- trunk/KDE/kdenetwork/kopete/protocols/oscar/liboscar/client.h #872432:872433
@@ -37,8 +37,6 @@
#include "contact.h"
class Connection;
-class StageOneLoginTask;
-class StageTwoLoginTask;
class ContactManager;
class UserDetails;
class QString;
@@ -628,9 +626,6 @@
private:
class ClientPrivate;
ClientPrivate* d;
-
- StageOneLoginTask* m_loginTask;
- StageTwoLoginTask* m_loginTaskTwo;
};
Q_DECLARE_OPERATORS_FOR_FLAGS(Client::ICQStatus)
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic