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

List:       kde-commits
Subject:    extragear/graphics/kpovmodeler
From:       Christoph Feck <christoph () maxiom ! de>
Date:       2010-10-09 15:09:37
Message-ID: 20101009150937.73699AC892 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1184244 by cfeck:

Fix crash in PMSymbolTable

This bug was caused by Qt3 port away from "auto deletion".
The symbols need to be deleted both by the destructor, as
well as by the clear() method. Instead of deleting them
"by hand" before calling clear(), overload the clear() method
and delete symbols as is done in the destructor.

The actual crash was caused by the "foreach" construct, which
creates a temporary copy of the QHash object, causing symbols
to be deleted twice.

BUG: 206432


 M  +0 -1      pmparser.cpp  
 M  +7 -0      pmsymboltable.cpp  
 M  +4 -0      pmsymboltable.h  


--- trunk/extragear/graphics/kpovmodeler/pmparser.cpp #1184243:1184244
@@ -228,7 +228,6 @@
 
 	foreach(PMSymbol* s, m_renamedObjectSymbols ) s->setRenamedSymbol( 0 );
    m_renamedObjectSymbols.clear( );
-	foreach(PMSymbol* s, m_pLocalST) delete s;
    m_pLocalST.clear( );
 
    if( ( errors( ) || warnings( ) ) && m_pResultList->isEmpty( ) )
--- trunk/extragear/graphics/kpovmodeler/pmsymboltable.cpp #1184243:1184244
@@ -77,6 +77,13 @@
 	for(it = begin( ); it != end( ); ++it) delete *it;
 }
 
+void PMSymbolTable::clear()
+{
+    QHash<QString, PMSymbol*>::iterator it;
+    for(it = begin( ); it != end( ); ++it) delete *it;
+    QHash<QString, PMSymbol*>::clear();
+}
+
 QString PMSymbolTable::findNewID( const QString& prefix )
 {
    QString testID;
--- trunk/extragear/graphics/kpovmodeler/pmsymboltable.h #1184243:1184244
@@ -108,6 +108,10 @@
     */
    ~PMSymbolTable( );
    /**
+    * Clear symbol table
+    */
+   void clear();
+   /**
     * Returns a free id with prefix prefix and a number as suffix
     */
    QString findNewID( const QString& prefix );
[prev in list] [next in list] [prev in thread] [next in thread] 

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