[Libreoffice-commits] core.git: basctl/source basegfx/source basic/source canvas/workben chart2/source connectivity/source

Radu Ioan ioan.radu.g at gmail.com
Mon Feb 16 22:16:26 PST 2015


 basctl/source/dlged/dlgedfunc.cxx                                 |    4 -
 basegfx/source/polygon/b2dpolygontools.cxx                        |    1 
 basic/source/runtime/basrdll.cxx                                  |    7 +-
 basic/source/runtime/ddectrl.cxx                                  |    1 
 basic/source/runtime/runtime.cxx                                  |    3 -
 canvas/workben/canvasdemo.cxx                                     |    4 -
 chart2/source/controller/chartapiwrapper/WrappedScaleProperty.cxx |    2 
 chart2/source/controller/dialogs/DataBrowser.cxx                  |   11 ++-
 chart2/source/controller/main/ChartController_Window.cxx          |    4 -
 chart2/source/tools/ThreeDHelper.cxx                              |    3 -
 connectivity/source/drivers/file/fcomp.cxx                        |    2 
 connectivity/source/drivers/jdbc/CallableStatement.cxx            |    4 +
 connectivity/source/drivers/jdbc/DatabaseMetaData.cxx             |    9 +--
 connectivity/source/drivers/jdbc/JConnection.cxx                  |   10 ++-
 connectivity/source/drivers/jdbc/JStatement.cxx                   |    6 +-
 connectivity/source/drivers/jdbc/PreparedStatement.cxx            |   28 ++++++----
 connectivity/source/drivers/jdbc/Timestamp.cxx                    |   18 ++++--
 17 files changed, 66 insertions(+), 51 deletions(-)

New commits:
commit a8e6f0bea0e8bc028ee64d0b4d9046e52de94eda
Author: Radu Ioan <ioan.radu.g at gmail.com>
Date:   Sat Feb 14 00:31:54 2015 +0200

    tdf#39440 - cppcheck cleanliness
    
    Fixed some cppcheck defects
    
    Change-Id: I25fd6aba9d76df98d20b9a1bb4c9d3c1bf6f84bb
    Reviewed-on: https://gerrit.libreoffice.org/14487
    Reviewed-by: Noel Grandin <noelgrandin at gmail.com>
    Tested-by: Noel Grandin <noelgrandin at gmail.com>

diff --git a/basctl/source/dlged/dlgedfunc.cxx b/basctl/source/dlged/dlgedfunc.cxx
index 7beccb6..3937b20 100644
--- a/basctl/source/dlged/dlgedfunc.cxx
+++ b/basctl/source/dlged/dlgedfunc.cxx
@@ -459,8 +459,6 @@ bool DlgEdFuncSelect::MouseButtonDown( const MouseEvent& rMEvt )
     if ( rMEvt.IsLeft() && rMEvt.GetClicks() == 1 )
     {
         SdrHdl* pHdl = rView.PickHandle(aMDPos);
-        SdrObject* pObj;
-        SdrPageView* pPV;
 
         // hit selected object?
         if ( pHdl!=NULL || rView.IsMarkedHit(aMDPos, nHitLog) )
@@ -474,6 +472,8 @@ bool DlgEdFuncSelect::MouseButtonDown( const MouseEvent& rMEvt )
                 rView.UnmarkAll();
             else
             {
+                SdrObject* pObj;
+                SdrPageView* pPV;
                 if( rView.PickObj( aMDPos, nHitLog, pObj, pPV ) )
                 {
                     //if (dynamic_cast<DlgEdForm*>(pObj))
diff --git a/basegfx/source/polygon/b2dpolygontools.cxx b/basegfx/source/polygon/b2dpolygontools.cxx
index 03c298e..09cb226 100644
--- a/basegfx/source/polygon/b2dpolygontools.cxx
+++ b/basegfx/source/polygon/b2dpolygontools.cxx
@@ -1088,7 +1088,6 @@ namespace basegfx
                             // inside parameter range edge2, too
                             if(fTools::more(fCut2, fZero) && fTools::less(fCut2, fOne))
                             {
-                                bFinished = true;
                                 aRetval = CUTFLAG_LINE;
                             }
                         }
diff --git a/basic/source/runtime/basrdll.cxx b/basic/source/runtime/basrdll.cxx
index 85fe736..a1ad75a 100644
--- a/basic/source/runtime/basrdll.cxx
+++ b/basic/source/runtime/basrdll.cxx
@@ -86,14 +86,13 @@ void BasicDLL::SetDebugMode( bool bDebugMode )
 
 void BasicDLL::BasicBreak()
 {
-    // bJustStopping: if there's someone pressing STOP like crazy umpteen times,
-    // but the Basic doesn't stop early enough, the box might appear more often...
-    static bool bJustStopping = false;
-
     BasicDLL* pThis = BASIC_DLL();
     DBG_ASSERT( pThis, "BasicDLL::EnableBreak: No instance yet!" );
     if ( pThis )
     {
+        // bJustStopping: if there's someone pressing STOP like crazy umpteen times,
+        // but the Basic doesn't stop early enough, the box might appear more often...
+        static bool bJustStopping = false;
         if (StarBASIC::IsRunning() && !bJustStopping
             && (pThis->m_xImpl->bBreakEnabled || pThis->m_xImpl->bDebugMode))
         {
diff --git a/basic/source/runtime/ddectrl.cxx b/basic/source/runtime/ddectrl.cxx
index 2557c9e..232008a 100644
--- a/basic/source/runtime/ddectrl.cxx
+++ b/basic/source/runtime/ddectrl.cxx
@@ -133,7 +133,6 @@ SbError SbiDdeControl::Terminate( size_t nChannel )
         return SbERR_DDE_NO_CHANNEL;
     }
     delete pConv;
-    pConv = DDE_FREECHANNEL;
 
     return 0L;
 }
diff --git a/basic/source/runtime/runtime.cxx b/basic/source/runtime/runtime.cxx
index 4dc9979..21d1cb8 100644
--- a/basic/source/runtime/runtime.cxx
+++ b/basic/source/runtime/runtime.cxx
@@ -1397,12 +1397,13 @@ void SbiRuntime::StepCompare( SbxOperator eOp )
     }
     static SbxVariable* pTRUE = NULL;
     static SbxVariable* pFALSE = NULL;
-    static SbxVariable* pNULL = NULL;
     // why do this on non-windows ?
     // why do this at all ?
     // I dumbly follow the pattern :-/
     if ( bVBAEnabled && ( p1->IsNull() || p2->IsNull() ) )
     {
+        static SbxVariable* pNULL = NULL;
+
         if( !pNULL )
         {
             pNULL = new SbxVariable;
diff --git a/canvas/workben/canvasdemo.cxx b/canvas/workben/canvasdemo.cxx
index d32fe70..cdf3acb 100644
--- a/canvas/workben/canvasdemo.cxx
+++ b/canvas/workben/canvasdemo.cxx
@@ -462,8 +462,6 @@ class DemoRenderer
             //This stuff doesn't belong here, but probably in curves
             //This stuff doesn't work in VCL b/c vcl doesn't do beziers
             //Hah!  Every time the window redraws, we do this
-            double ax;
-            double ay;
             double bx;
             double by;
             bx= gimmerand();
@@ -471,6 +469,8 @@ class DemoRenderer
 
             for (int i= 0; i < 1; i++)
             {
+                double ax;
+                double ay;
                 //point a= point b;
                 ax= bx;
                 ay= by;
diff --git a/chart2/source/controller/chartapiwrapper/WrappedScaleProperty.cxx b/chart2/source/controller/chartapiwrapper/WrappedScaleProperty.cxx
index 9a1966d..8c86559 100644
--- a/chart2/source/controller/chartapiwrapper/WrappedScaleProperty.cxx
+++ b/chart2/source/controller/chartapiwrapper/WrappedScaleProperty.cxx
@@ -190,7 +190,7 @@ void WrappedScaleProperty::setPropertyValue( tScaleProperty eScaleProperty, cons
                     (aScaleData.IncrementData.Distance >>= fStepMain) )
                 {
                     // approximate interval count
-                    sal_Int32 nIntervalCount = static_cast< sal_Int32 >(fStepMain / fStepHelp);
+                    sal_Int32 nIntervalCount = static_cast< sal_Int32 >(fStepMain / fStepHelp);//cppcheck-suppress zerodiv
                     rSubIncrements[ 0 ].IntervalCount <<= nIntervalCount;
                 }
             }
diff --git a/chart2/source/controller/dialogs/DataBrowser.cxx b/chart2/source/controller/dialogs/DataBrowser.cxx
index 5276546..75b55d4 100644
--- a/chart2/source/controller/dialogs/DataBrowser.cxx
+++ b/chart2/source/controller/dialogs/DataBrowser.cxx
@@ -641,8 +641,7 @@ OUString DataBrowser::GetCellText( long nRow, sal_uInt16 nColumnId ) const
     {
         aResult = GetRowString( static_cast< sal_Int32 >( nRow ));
     }
-    else if( nRow >= 0 &&
-             m_apDataBrowserModel.get())
+    else if( nRow >= 0 && m_apDataBrowserModel.get())
     {
         sal_Int32 nColIndex = static_cast< sal_Int32 >( nColumnId ) - 1;
 
@@ -650,13 +649,15 @@ OUString DataBrowser::GetCellText( long nRow, sal_uInt16 nColumnId ) const
         {
             double fData( m_apDataBrowserModel->getCellNumber( nColIndex, nRow ));
             sal_Int32 nLabelColor;
-            bool bColorChanged = false;
 
             if( ! ::rtl::math::isNan( fData ) &&
                 m_spNumberFormatterWrapper.get() )
+            {
+                bool bColorChanged = false;
                 aResult = m_spNumberFormatterWrapper->getFormattedString(
                                       GetNumberFormatKey( nRow, nColumnId ),
                                       fData, nLabelColor, bColorChanged );
+            }
         }
         else if( m_apDataBrowserModel->getCellType( nColIndex, nRow ) == DataBrowserModel::TEXTORDATE )
         {
@@ -668,11 +669,13 @@ OUString DataBrowser::GetCellText( long nRow, sal_uInt16 nColumnId ) const
             else if( aAny>>=fDouble )
             {
                 sal_Int32 nLabelColor;
-                bool bColorChanged = false;
                 sal_Int32 nDateNumberFormat = DiagramHelper::getDateNumberFormat( Reference< util::XNumberFormatsSupplier >( m_xChartDoc, uno::UNO_QUERY) );
                 if( ! ::rtl::math::isNan( fDouble ) && m_spNumberFormatterWrapper.get() )
+                {
+                    bool bColorChanged = false;
                     aResult = m_spNumberFormatterWrapper->getFormattedString(
                         nDateNumberFormat, fDouble, nLabelColor, bColorChanged );
+                }
             }
         }
         else
diff --git a/chart2/source/controller/main/ChartController_Window.cxx b/chart2/source/controller/main/ChartController_Window.cxx
index a8de0328..b7a677b 100644
--- a/chart2/source/controller/main/ChartController_Window.cxx
+++ b/chart2/source/controller/main/ChartController_Window.cxx
@@ -1722,7 +1722,6 @@ bool ChartController::impl_moveOrResizeObject(
     double fAmountLogicY )
 {
     bool bResult = false;
-    bool bNeedShift = true;
     bool bNeedResize = ( eType == CENTERED_RESIZE_OBJECT );
 
     uno::Reference< frame::XModel > xChartModel( getModel() );
@@ -1788,8 +1787,7 @@ bool ChartController::impl_moveOrResizeObject(
                     eActionType, ObjectNameProvider::getName( eObjectType )), m_xUndoManager );
             {
                 ControllerLockGuardUNO aCLGuard( xChartModel );
-                if( bNeedShift )
-                    xObjProp->setPropertyValue( "RelativePosition", uno::makeAny( aRelPos ));
+                xObjProp->setPropertyValue( "RelativePosition", uno::makeAny( aRelPos ));
                 if( bNeedResize || (eObjectType == OBJECTTYPE_DIAGRAM) )//Also set an explicat size at the diagram when an explicit position is set
                     xObjProp->setPropertyValue( "RelativeSize", uno::makeAny( aRelSize ));
             }
diff --git a/chart2/source/tools/ThreeDHelper.cxx b/chart2/source/tools/ThreeDHelper.cxx
index 1ae9261..407efb1 100644
--- a/chart2/source/tools/ThreeDHelper.cxx
+++ b/chart2/source/tools/ThreeDHelper.cxx
@@ -1453,7 +1453,6 @@ CuboidPlanePosition ThreeDHelper::getAutomaticCuboidPlanePositionForStandardLeft
     if( lcl_isRightAngledAxesSetAndSupported( xSceneProperties ) )
     {
         ThreeDHelper::adaptRadAnglesForRightAngledAxes( fXAngleRad, fYAngleRad );
-        fZAngleRad=0.0;
     }
     if( sin(fYAngleRad)>0.0 )
         eRet = CuboidPlanePosition_Right;
@@ -1469,7 +1468,6 @@ CuboidPlanePosition ThreeDHelper::getAutomaticCuboidPlanePositionForStandardBack
     if( lcl_isRightAngledAxesSetAndSupported( xSceneProperties ) )
     {
         ThreeDHelper::adaptRadAnglesForRightAngledAxes( fXAngleRad, fYAngleRad );
-        fZAngleRad=0.0;
     }
     if( cos(fXAngleRad)*cos(fYAngleRad)<0.0 )
         eRet = CuboidPlanePosition_Front;
@@ -1485,7 +1483,6 @@ CuboidPlanePosition ThreeDHelper::getAutomaticCuboidPlanePositionForStandardBott
     if( lcl_isRightAngledAxesSetAndSupported( xSceneProperties ) )
     {
         ThreeDHelper::adaptRadAnglesForRightAngledAxes( fXAngleRad, fYAngleRad );
-        fZAngleRad=0.0;
     }
     if( sin(fXAngleRad)*cos(fYAngleRad)<0.0 )
         eRet = CuboidPlanePosition_Top;
diff --git a/connectivity/source/drivers/file/fcomp.cxx b/connectivity/source/drivers/file/fcomp.cxx
index 7a86ce3..8926b94 100644
--- a/connectivity/source/drivers/file/fcomp.cxx
+++ b/connectivity/source/drivers/file/fcomp.cxx
@@ -72,10 +72,10 @@ void OPredicateCompiler::start(OSQLParseNode* pSQLParseNode)
     // analyse Parse Tree (depending on Statement-type)
     // and set pointer on WHERE-clause:
     OSQLParseNode * pWhereClause = NULL;
-    OSQLParseNode * pOrderbyClause = NULL;
 
     if (SQL_ISRULE(pSQLParseNode,select_statement))
     {
+        OSQLParseNode * pOrderbyClause = NULL;
         DBG_ASSERT(pSQLParseNode->count() >= 4,"OFILECursor: Fehler im Parse Tree");
 
         OSQLParseNode * pTableExp = pSQLParseNode->getChild(3);
diff --git a/connectivity/source/drivers/jdbc/CallableStatement.cxx b/connectivity/source/drivers/jdbc/CallableStatement.cxx
index 86f479c..2a086ab 100644
--- a/connectivity/source/drivers/jdbc/CallableStatement.cxx
+++ b/connectivity/source/drivers/jdbc/CallableStatement.cxx
@@ -321,7 +321,6 @@ void java_sql_CallableStatement::createStatement(JNIEnv* /*_pEnv*/)
     SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
     if( t.pEnv && !object ){
         // initialize temporary variable
-        static const char * cSignature = "(Ljava/lang/String;II)Ljava/sql/CallableStatement;";
         static const char * cMethodName = "prepareCall";
         // execute Java-Call
         jobject out = NULL;
@@ -330,7 +329,10 @@ void java_sql_CallableStatement::createStatement(JNIEnv* /*_pEnv*/)
 
         static jmethodID mID(NULL);
         if ( !mID  )
+        {
+            static const char * cSignature = "(Ljava/lang/String;II)Ljava/sql/CallableStatement;";
             mID  = t.pEnv->GetMethodID( m_pConnection->getMyClass(), cMethodName, cSignature );
+        }
         if( mID ){
             out = t.pEnv->CallObjectMethod( m_pConnection->getJavaObject(), mID, str.get() ,m_nResultSetType,m_nResultSetConcurrency);
         } //mID
diff --git a/connectivity/source/drivers/jdbc/DatabaseMetaData.cxx b/connectivity/source/drivers/jdbc/DatabaseMetaData.cxx
index 8155e69..b08ece9 100644
--- a/connectivity/source/drivers/jdbc/DatabaseMetaData.cxx
+++ b/connectivity/source/drivers/jdbc/DatabaseMetaData.cxx
@@ -106,7 +106,6 @@ Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getColumns(
 Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getTables(
         const Any& catalog, const OUString& schemaPattern, const OUString& tableNamePattern, const Sequence< OUString >& _types ) throw(SQLException, RuntimeException, std::exception)
 {
-    static const char * cSignature = "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;)Ljava/sql/ResultSet;";
     static const char * cMethodName = "getTables";
 
     m_aLogger.log( LogLevel::FINEST, STR_LOG_META_DATA_METHOD, cMethodName );
@@ -115,6 +114,7 @@ Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getTables(
     SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
 
     {
+        static const char * cSignature = "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;)Ljava/sql/ResultSet;";
         // execute Java-Call
         static jmethodID mID(NULL);
         obtainMethodId_throwSQL(t.pEnv, cMethodName,cSignature, mID);
@@ -335,7 +335,6 @@ Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getIndexInfo(
         const Any& catalog, const OUString& schema, const OUString& table,
         sal_Bool unique, sal_Bool approximate ) throw(SQLException, RuntimeException, std::exception)
 {
-    static const char * cSignature = "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZZ)Ljava/sql/ResultSet;";
     static const char * cMethodName = "getIndexInfo";
 
     m_aLogger.log( LogLevel::FINEST, STR_LOG_META_DATA_METHOD, cMethodName );
@@ -344,6 +343,7 @@ Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getIndexInfo(
     SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
 
     {
+        static const char * cSignature = "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZZ)Ljava/sql/ResultSet;";
         // execute Java-Call
         static jmethodID mID(NULL);
         obtainMethodId_throwSQL(t.pEnv, cMethodName,cSignature, mID);
@@ -376,7 +376,6 @@ Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getBestRowIdentifier
         const Any& catalog, const OUString& schema, const OUString& table, sal_Int32 scope,
         sal_Bool nullable ) throw(SQLException, RuntimeException, std::exception)
 {
-    static const char * cSignature = "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;IZ)Ljava/sql/ResultSet;";
     static const char * cMethodName = "getBestRowIdentifier";
 
     m_aLogger.log( LogLevel::FINEST, STR_LOG_META_DATA_METHOD, cMethodName );
@@ -385,6 +384,7 @@ Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getBestRowIdentifier
     SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
 
     {
+        static const char * cSignature = "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;IZ)Ljava/sql/ResultSet;";
         // execute Java-Call
         static jmethodID mID(NULL);
         obtainMethodId_throwSQL(t.pEnv, cMethodName,cSignature, mID);
@@ -493,14 +493,13 @@ Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getCrossReference(
         const OUString& primaryTable, const Any& foreignCatalog,
         const OUString& foreignSchema, const OUString& foreignTable ) throw(SQLException, RuntimeException, std::exception)
 {
-    static const char * cSignature = "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/sql/ResultSet;";
     static const char * cMethodName = "getCrossReference";
     m_aLogger.log( LogLevel::FINEST, STR_LOG_META_DATA_METHOD, cMethodName );
 
     jobject out(0);
     SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
     {
-
+        static const char * cSignature = "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/sql/ResultSet;";
         // execute Java-Call
         static jmethodID mID(NULL);
         obtainMethodId_throwSQL(t.pEnv, cMethodName,cSignature, mID);
diff --git a/connectivity/source/drivers/jdbc/JConnection.cxx b/connectivity/source/drivers/jdbc/JConnection.cxx
index 1bf1270..da9c188 100644
--- a/connectivity/source/drivers/jdbc/JConnection.cxx
+++ b/connectivity/source/drivers/jdbc/JConnection.cxx
@@ -809,13 +809,15 @@ bool java_sql_Connection::construct(const OUString& url,
 
     if ( t.pEnv && m_Driver_theClass && m_pDriverobject )
     {
-        // initialize temporary Variable
-        static const char * cSignature = "(Ljava/lang/String;Ljava/util/Properties;)Ljava/sql/Connection;";
-        static const char * cMethodName = "connect";
         // Java-Call
         jmethodID mID = NULL;
-        if ( !mID  )
+        if ( !mID )
+        {
+            // initialize temporary Variable
+            static const char * cSignature = "(Ljava/lang/String;Ljava/util/Properties;)Ljava/sql/Connection;";
+            static const char * cMethodName = "connect";
             mID  = t.pEnv->GetMethodID( m_Driver_theClass, cMethodName, cSignature );
+        }
         if ( mID )
         {
             jvalue args[2];
diff --git a/connectivity/source/drivers/jdbc/JStatement.cxx b/connectivity/source/drivers/jdbc/JStatement.cxx
index 2c102c1..7452abc 100644
--- a/connectivity/source/drivers/jdbc/JStatement.cxx
+++ b/connectivity/source/drivers/jdbc/JStatement.cxx
@@ -781,13 +781,15 @@ void java_sql_Statement::createStatement(JNIEnv* _pEnv)
 
     if( _pEnv && !object ){
         // initialize temporary variable
-        static const char * cSignature = "(II)Ljava/sql/Statement;";
         static const char * cMethodName = "createStatement";
         // Java-Call
         jobject out = NULL;
         static jmethodID mID(NULL);
-        if ( !mID  )
+        if ( !mID )
+        {
+            static const char * cSignature = "(II)Ljava/sql/Statement;";
             mID  = _pEnv->GetMethodID( m_pConnection->getMyClass(), cMethodName, cSignature );
+        }
         if( mID ){
             out = _pEnv->CallObjectMethod( m_pConnection->getJavaObject(), mID,m_nResultSetType,m_nResultSetConcurrency );
         } //mID
diff --git a/connectivity/source/drivers/jdbc/PreparedStatement.cxx b/connectivity/source/drivers/jdbc/PreparedStatement.cxx
index 427931e..5b14f1d 100644
--- a/connectivity/source/drivers/jdbc/PreparedStatement.cxx
+++ b/connectivity/source/drivers/jdbc/PreparedStatement.cxx
@@ -470,13 +470,15 @@ void SAL_CALL java_sql_PreparedStatement::setCharacterStream( sal_Int32 paramete
         args2[0].l =  pByteArray;
         args2[1].i =  0;
         args2[2].i =  actualLength;
-        // initialize temporary variable
-        const char * cSignatureStream = "([BII)V";
         // Java-Call
         jclass aClass = t.pEnv->FindClass("java/io/CharArrayInputStream");
         static jmethodID mID2 = NULL;
-        if ( !mID2  )
+        if ( !mID2 )
+        {
+            // initialize temporary variable
+            const char * cSignatureStream = "([BII)V";
             mID2  = t.pEnv->GetMethodID( aClass, "<init>", cSignatureStream );
+        }
         jobject tempObj = NULL;
         if(mID2)
             tempObj = t.pEnv->NewObjectA( aClass, mID2, args2 );
@@ -519,13 +521,15 @@ void SAL_CALL java_sql_PreparedStatement::setBinaryStream( sal_Int32 parameterIn
             args2[1].i =  0;
             args2[2].i =  (sal_Int32)actualLength;
 
-            // initialize temporary variable
-            const char * cSignatureStream = "([BII)V";
             // Java-Call
             jclass aClass = t.pEnv->FindClass("java/io/ByteArrayInputStream");
             static jmethodID mID2 = NULL;
-            if ( !mID2  )
+            if ( !mID2 )
+            {
+                // initialize temporary variable
+                const char * cSignatureStream = "([BII)V";
                 mID2  = t.pEnv->GetMethodID( aClass, "<init>", cSignatureStream );
+            }
             jobject tempObj = NULL;
             if(mID2)
                 tempObj = t.pEnv->NewObjectA( aClass, mID2, args2 );
@@ -629,7 +633,6 @@ void java_sql_PreparedStatement::createStatement(JNIEnv* _pEnv)
 
     if( !object && _pEnv ){
         // initialize temporary variable
-        static const char * cSignature = "(Ljava/lang/String;II)Ljava/sql/PreparedStatement;";
         static const char * cMethodName = "prepareStatement";
 
         jvalue args[1];
@@ -638,18 +641,23 @@ void java_sql_PreparedStatement::createStatement(JNIEnv* _pEnv)
         // Java-Call
         jobject out = NULL;
         static jmethodID mID(NULL);
-        if ( !mID  )
+        if ( !mID )
+        {
+            static const char * cSignature = "(Ljava/lang/String;II)Ljava/sql/PreparedStatement;";
             mID  = _pEnv->GetMethodID( m_pConnection->getMyClass(), cMethodName, cSignature );
+        }
         if( mID )
         {
             out = _pEnv->CallObjectMethod( m_pConnection->getJavaObject(), mID, args[0].l ,m_nResultSetType,m_nResultSetConcurrency);
         }
         else
         {
-            static const char * cSignature2 = "(Ljava/lang/String;)Ljava/sql/PreparedStatement;";
             static jmethodID mID2 = NULL;
-            if ( !mID2)
+            if ( !mID2 )
+            {
+                static const char * cSignature2 = "(Ljava/lang/String;)Ljava/sql/PreparedStatement;";
                 mID2 = _pEnv->GetMethodID( m_pConnection->getMyClass(), cMethodName, cSignature2 );
+            }
             if ( mID2 )
                 out = _pEnv->CallObjectMethod( m_pConnection->getJavaObject(), mID2, args[0].l );
         }
diff --git a/connectivity/source/drivers/jdbc/Timestamp.cxx b/connectivity/source/drivers/jdbc/Timestamp.cxx
index 86f0fe7..9648473 100644
--- a/connectivity/source/drivers/jdbc/Timestamp.cxx
+++ b/connectivity/source/drivers/jdbc/Timestamp.cxx
@@ -42,11 +42,13 @@ java_sql_Date::java_sql_Date( const ::com::sun::star::util::Date& _rOut ) : java
 
     // Turn of Java-Call for the constructor
     // initialise temporary variables
-    static const char * cSignature = "(Ljava/lang/String;)Ljava/sql/Date;";
     jobject tempObj;
     static jmethodID mID(NULL);
-    if ( !mID  )
+    if ( !mID )
+    {
+        static const char * cSignature = "(Ljava/lang/String;)Ljava/sql/Date;";
         mID  = t.pEnv->GetStaticMethodID( getMyClass(), "valueOf", cSignature );
+    }
     OSL_ENSURE(mID,"Unknown method id!");
     tempObj = t.pEnv->CallStaticObjectMethod( getMyClass(), mID, args[0].l );
     saveRef( t.pEnv, tempObj );
@@ -109,11 +111,13 @@ java_sql_Time::java_sql_Time( const ::com::sun::star::util::Time& _rOut ): java_
 
     // Turn off Java-Call for the constructor
     // intialise temporary variables
-    static const char * cSignature = "(Ljava/lang/String;)Ljava/sql/Time;";
     jobject tempObj;
     static jmethodID mID(NULL);
-    if ( !mID  )
+    if ( !mID )
+    {
+        static const char * cSignature = "(Ljava/lang/String;)Ljava/sql/Time;";
         mID  = t.pEnv->GetStaticMethodID( getMyClass(), "valueOf", cSignature );
+    }
     OSL_ENSURE(mID,"Unknown method id!");
     tempObj = t.pEnv->CallStaticObjectMethod( getMyClass(), mID, args[0].l );
     t.pEnv->DeleteLocalRef(static_cast<jstring>(args[0].l));
@@ -163,11 +167,13 @@ java_sql_Timestamp::java_sql_Timestamp(const ::com::sun::star::util::DateTime& _
 
     // Turn off Java-Call for the constructor
     // initialise temporary variables
-    static const char * cSignature = "(Ljava/lang/String;)Ljava/sql/Timestamp;";
     jobject tempObj;
     static jmethodID mID(NULL);
-    if ( !mID  )
+    if ( !mID )
+    {
+        static const char * cSignature = "(Ljava/lang/String;)Ljava/sql/Timestamp;";
         mID  = t.pEnv->GetStaticMethodID( getMyClass(), "valueOf", cSignature );
+    }
     OSL_ENSURE(mID,"Unknown method id!");
     tempObj = t.pEnv->CallStaticObjectMethod( getMyClass(), mID, args[0].l );
 


More information about the Libreoffice-commits mailing list