Exceptions are instantiated in stack instead of heap.
authorMikko Keinänen <mikko.keinanen@gmail.com>
Wed, 17 Nov 2010 20:45:07 +0000 (22:45 +0200)
committerMikko Keinänen <mikko.keinanen@gmail.com>
Wed, 17 Nov 2010 20:45:07 +0000 (22:45 +0200)
src/db/databasemanager.cpp
src/db/dbmediaimagecontainer.cpp
src/dialogs/executableeditdialog.cpp
src/emulauncher.cpp
src/utils/fileutil.cpp
src/utils/unziphelper.cpp
src/widgets/efcombobox.cpp

index b1e47db..5f33485 100644 (file)
@@ -129,9 +129,8 @@ EmuFrontObject* DatabaseManager::getFilteredDataObject()
     if (sqlTableModel->rowCount() >= 1)
     {
         QSqlRecord record = sqlTableModel->record(0);
-        if (record.isEmpty())
-        {
-            throw new EmuFrontException(tr("No filtered data available"));
+        if (record.isEmpty()) {
+            throw EmuFrontException(tr("No filtered data available"));
         }
         else plf = recordToDataObject(&record);
     }
index e91edda..4ed6d10 100644 (file)
@@ -48,7 +48,7 @@ int DbMediaImageContainer::storeMediaImageContainer(EmuFrontObject *efo)
         = dynamic_cast<MediaImageContainer *>(efo);
 
     if (!mic->getFilePath())
-        throw new EmuFrontException("Cannot install media image "
+        throw EmuFrontException("Cannot install media image "
             "container to database without a file path object!");
 
     // multiple media image containers with matching checksum will be stored
@@ -82,7 +82,7 @@ int DbMediaImageContainer::storeMediaImageContainer(EmuFrontObject *efo)
             // in the calling code block and clean
             // all the media image and ...containers from
             // the memory!
-            throw new EmuFrontException(
+            throw EmuFrontException(
                     QString(tr("Inserting media image container %1 to file database failed"))
                     .arg(mic->getName()));
         }
@@ -91,7 +91,7 @@ int DbMediaImageContainer::storeMediaImageContainer(EmuFrontObject *efo)
 
         if (!linkMediaImageContainerToPath(mic)){
             DbFile::deleteDataObject(fileId);
-            throw new EmuFrontException("Failed inserting media image to database!");
+            throw EmuFrontException("Failed inserting media image to database!");
         }
         //qDebug() << "Inserted media image container " << fileId << " to mediaimagecontainer table.";
         linkMediaImagesWithContainer(fileId, images.values());
@@ -224,7 +224,7 @@ void DbMediaImageContainer::linkMediaImagesWithContainer(int micId, QList<EmuFro
         /*qDebug() << "Linking media image container " << micId
             << " to media image " << mi->getId()  << ", " << mi->getName() << ".";*/
         if (!linkMediaImageToMediaImageContainer(mi, micId)) {
-                throw new EmuFrontException(QString("Failed linking media "
+                throw EmuFrontException(QString("Failed linking media "
                                                     "image container %1 to a media image %2").arg(micId).arg(mi->getId()));
         }
     }
index c62fe9f..4be8b01 100644 (file)
@@ -83,19 +83,19 @@ void ExecutableEditDialog::acceptChanges()
     try {
         Setup *su = getSelectedSetup();
         if (!su) {
-            throw new EmuFrontException(tr("Setup not selected"));
+            throw EmuFrontException(tr("Setup not selected"));
         }
         QString name = nameEdit->text().trimmed();
         if (name.isEmpty()){
-            throw new EmuFrontException(tr("Name is not set"));
+            throw EmuFrontException(tr("Name is not set"));
         }
         QString exec = execEdit->text().trimmed();
         if (exec.isEmpty()){
-            throw new EmuFrontException(tr("Executable is not set"));
+            throw EmuFrontException(tr("Executable is not set"));
         }
         QString opts = optEdit->text().trimmed();
         if (opts.isEmpty()) {
-            throw new EmuFrontException(tr("Options not set"));
+            throw EmuFrontException(tr("Options not set"));
         }
         bool change = false;
         Setup *supTmp = ex->getSetup();
index c6403e9..f750963 100644 (file)
@@ -167,7 +167,7 @@ void EmuLauncher::launchEmu()
 
 
         if (mame && listMIndex.count() > 1) {
-            throw new EmuFrontException(tr("No supported file types configured for this emulator configuration. "
+            throw EmuFrontException(tr("No supported file types configured for this emulator configuration. "
                 "Assuming emulator support container files as is. "
                 "Only one container can be selected without configuring supported file types."
             ));
index f1a5f2d..ecc3b59 100644 (file)
@@ -56,7 +56,7 @@ int FileUtil::scanFilePath(FilePathObject *fp,
             .arg(fp->getSetup()->getName()));
     }
     else if (!fp->getSetup()->getMediaType()){
-        throw new EmuFrontException(tr("No media type available with %1.")
+        throw EmuFrontException(tr("No media type available with %1.")
             .arg(fp->getSetup()->getName()));
     }
 
@@ -138,7 +138,7 @@ quint32 FileUtil::readCrc32(QString filePath)
     QFile file(filePath);
     //qDebug() << "readCrc32: " << filePath;
     if (!file.open(QIODevice::ReadOnly)) {
-        throw new EmuFrontException(QString(tr("Failed opening file %1 for reading the checksum!")).arg(filePath));
+        throw EmuFrontException(QString(tr("Failed opening file %1 for reading the checksum!")).arg(filePath));
     }
     quint32 crc = crc32(0L, Z_NULL, 0);
     int read = 0;
@@ -147,7 +147,7 @@ quint32 FileUtil::readCrc32(QString filePath)
     }
     file.close();
     if (crc <= 0)
-        throw new EmuFrontException(QString(tr("Failed reading crc checksum for file %1!")).arg(filePath));
+        throw EmuFrontException(QString(tr("Failed reading crc checksum for file %1!")).arg(filePath));
     //qDebug() << QString("readCrc32, crc: %1").arg(crc, 0, 16);
     return crc;
 }
index af489a1..14b4bce 100644 (file)
@@ -41,7 +41,7 @@ QMap<QString, EmuFrontObject*> UnzipHelper::listContents(const QString filePath,
 
     QFile fl(filePath);
     if (!fl.open(QIODevice::ReadOnly)) {
-        throw new EmuFrontException(tr("Couldn't read file %1.").arg(filePath));
+        throw EmuFrontException(tr("Couldn't read file %1.").arg(filePath));
     }
 
     //Setup *sup = fp->getSetup();
index 15769c0..d0a3d80 100644 (file)
@@ -30,7 +30,7 @@ EFComboBox::EFComboBox(DatabaseManager *dbMan, QWidget *parent)
     : QComboBox(parent), dbManager(dbMan)
 {
     if (!dbManager)
-        throw new EmuFrontException("Database manager is not available!");
+        throw EmuFrontException("Database manager is not available!");
     setSizeAdjustPolicy(QComboBox::AdjustToContents);
     updateDataModel();
 }