OSDN Git Service

Added x64 binaries of mpg123 decoder v1.26.3 (2020-07-16), compiled with GCC 10.2.0.
[lamexp/LameXP.git] / src / Model_Artwork.cpp
index b392fd1..518bd90 100644 (file)
@@ -1,12 +1,12 @@
 ///////////////////////////////////////////////////////////////////////////////
 // LameXP - Audio Encoder Front-End
-// Copyright (C) 2004-2013 LoRd_MuldeR <MuldeR2@GMX.de>
+// Copyright (C) 2004-2020 LoRd_MuldeR <MuldeR2@GMX.de>
 //
 // This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
+// it under the terms of the GNU GENERAL PUBLIC LICENSE as published by
 // the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version, but always including the *additional*
-// restrictions defined in the "License.txt" file.
+// (at your option) any later version; always including the non-optional
+// LAMEXP GNU GENERAL PUBLIC LICENSE ADDENDUM. See "License.txt" file!
 //
 // This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
 
 #include "Model_Artwork.h"
 
+//Internal
 #include "Global.h"
 
+//MUtils
+#include <MUtils/Global.h>
+
+//Qt
 #include <QFile>
 #include <QMutex>
 #include <QMutexLocker>
@@ -51,9 +56,12 @@ protected:
                        if(file->open(QIODevice::ReadOnly))
                        {
                                m_fileHandle = file;
-                               return;
                        }
-                       LAMEXP_DELETE(file);
+                       else
+                       {
+                               qWarning("[ArtworkModel] Failed to open artwork file!");
+                               MUTILS_DELETE(file);
+                       }
                }
        }
 
@@ -66,7 +74,7 @@ protected:
                                m_fileHandle->remove();
                        }
                        m_fileHandle->close();
-                       LAMEXP_DELETE(m_fileHandle);
+                       MUTILS_DELETE(m_fileHandle);
                }
        }
 
@@ -86,10 +94,17 @@ protected:
                if(*ptr)
                {
                        QMutexLocker lock(&s_mutex);
-                       (*ptr)->m_referenceCounter = (*ptr)->m_referenceCounter - 1;
-                       if((*ptr)->m_referenceCounter < 1)
+                       if((*ptr)->m_referenceCounter > 0)
                        {
-                               delete (*ptr);
+                               (*ptr)->m_referenceCounter = (*ptr)->m_referenceCounter - 1;
+                               if((*ptr)->m_referenceCounter < 1)
+                               {
+                                       delete (*ptr);
+                               }
+                       }
+                       else
+                       {
+                               qWarning("[ArtworkModel::detach] Ref counter already zero!");
                        }
                        *ptr = NULL;
                }
@@ -146,7 +161,7 @@ ArtworkModel::~ArtworkModel(void)
        QMutexLocker lock(m_mutex);
        ArtworkModel_SharedData::detach(&m_data);
        lock.unlock();
-       LAMEXP_DELETE(m_mutex);
+       MUTILS_DELETE(m_mutex);
 }
 
 ////////////////////////////////////////////////////////////
@@ -169,7 +184,10 @@ void ArtworkModel::setFilePath(const QString &newPath, bool isOwner)
 {
        QMutexLocker lock(m_mutex);
        ArtworkModel_SharedData::detach(&m_data);
-       m_data = new ArtworkModel_SharedData(newPath, isOwner);
+       if(!newPath.isEmpty())
+       {
+               m_data = new ArtworkModel_SharedData(newPath, isOwner);
+       }
 }
 
 void ArtworkModel::clear(void)