[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    extragear/multimedia/amarok/src/scriptengine
From:       Seb Ruiz <ruiz () kde ! org>
Date:       2009-01-17 7:05:24
Message-ID: 1232175924.048461.806.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 912279 by seb:

style fixes

 M  +15 -10    AmarokNetworkScript.cpp  
 M  +0 -4      AmarokNetworkScript.h  


--- trunk/extragear/multimedia/amarok/src/scriptengine/AmarokNetworkScript.cpp #912278:912279
@@ -45,7 +45,6 @@
     engine->setDefaultPrototype( qMetaTypeId<Downloader*>(), QScriptValue() );
     const QScriptValue ctor = engine->newFunction( Downloader_prototype_ctor );
     engine->globalObject().setProperty( "Downloader", ctor );
-
 }
 
 Downloader::~Downloader()
@@ -54,13 +53,15 @@
 
 QScriptValue
 Downloader::Downloader_prototype_ctor( QScriptContext* context, QScriptEngine* engine )
-{ // from QtScript API docs
+{
+    // from QtScript API docs
     DEBUG_BLOCK
     QScriptValue object;
+    
     if( context->isCalledAsConstructor() )
+        object = context->thisObject();
+    else
     {
-        object = context->thisObject();
-    } else {
         object = engine->newObject();
         object.setPrototype( context->callee().property("prototype") );
     }
@@ -69,16 +70,20 @@
     {
         debug() << "ERROR! Constructor not called with enough arguments:" << context->argumentCount();
         return object;
-    } else if( !context->argument( 1 ).isFunction() ) //TODO: check QUrl
+    }
+    
+    if( !context->argument( 1 ).isFunction() ) //TODO: check QUrl
     {
         debug() << "ERROR! Constructor not called with a QUrl and function!";
         return object;
     }
+    
     QString encoding = "UTF-8";
     KUrl tmpUrl;
     QUrl url = qscriptvalue_cast<QUrl>( context->argument( 0 ) );
     if( context->argumentCount() == 3 ) // encoding specified
         encoding = context->argument( 2 ).toString();
+    
     tmpUrl.setEncodedUrl( url.toEncoded() );
     // start download, and connect to it
     //FIXME: url is not working directly.
@@ -134,11 +139,14 @@
     {
         debug() << "script object is valid but not a function!!";
         return;
-    } else if( !engine )
+    }
+   
+    if( !engine )
     {
         debug() << "stored script engine is not valid!";
         return;
     }
+
     QScriptValueList args;
     args <<  QScriptValue( engine, data );
     obj.call( obj, args );
@@ -152,11 +160,8 @@
 AmarokDownloadHelper::instance()
 {
     if( !s_instance )
-    {
         s_instance = new AmarokDownloadHelper();
-        return s_instance;
-    } else
-        return s_instance;
+    return s_instance;
 }
 
 
--- trunk/extragear/multimedia/amarok/src/scriptengine/AmarokNetworkScript.h #912278:912279
@@ -33,11 +33,8 @@
     public:
         AmarokNetworkScript( QScriptEngine* ScriptEngine );
         ~AmarokNetworkScript();
-
-
 };
 
-
 class Downloader : public QObject
 {
     Q_OBJECT
@@ -50,7 +47,6 @@
         static QScriptValue Downloader_prototype_ctor( QScriptContext* context, QScriptEngine* engine );
 
         QScriptEngine* m_scriptEngine;
-
 };
 
 Q_DECLARE_METATYPE( Downloader* )
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic