Skip to content
This repository has been archived by the owner on Apr 15, 2023. It is now read-only.

Commit

Permalink
return ADDON_STATUS_PERMANENT_FAILURE when a call to RegisterMe() fai…
Browse files Browse the repository at this point in the history
…ls in ADDON_Create()
  • Loading branch information
opdenkamp committed Oct 9, 2012
1 parent e425e9f commit b908d34
Show file tree
Hide file tree
Showing 9 changed files with 77 additions and 36 deletions.
12 changes: 10 additions & 2 deletions addons/pvr.demo/src/client.cpp
Expand Up @@ -22,6 +22,7 @@
#include "client.h" #include "client.h"
#include "xbmc_pvr_dll.h" #include "xbmc_pvr_dll.h"
#include "PVRDemoData.h" #include "PVRDemoData.h"
#include "platform/util/util.h"


using namespace std; using namespace std;
using namespace ADDON; using namespace ADDON;
Expand Down Expand Up @@ -62,11 +63,18 @@ ADDON_STATUS ADDON_Create(void* hdl, void* props)


XBMC = new CHelper_libXBMC_addon; XBMC = new CHelper_libXBMC_addon;
if (!XBMC->RegisterMe(hdl)) if (!XBMC->RegisterMe(hdl))
return ADDON_STATUS_UNKNOWN; {
SAFE_DELETE(XBMC);
return ADDON_STATUS_PERMANENT_FAILURE;
}


PVR = new CHelper_libXBMC_pvr; PVR = new CHelper_libXBMC_pvr;
if (!PVR->RegisterMe(hdl)) if (!PVR->RegisterMe(hdl))
return ADDON_STATUS_UNKNOWN; {
SAFE_DELETE(PVR);
SAFE_DELETE(XBMC);
return ADDON_STATUS_PERMANENT_FAILURE;
}


XBMC->Log(LOG_DEBUG, "%s - Creating the PVR demo add-on", __FUNCTION__); XBMC->Log(LOG_DEBUG, "%s - Creating the PVR demo add-on", __FUNCTION__);


Expand Down
4 changes: 2 additions & 2 deletions addons/pvr.fortherecord.argus/src/client.cpp
Expand Up @@ -73,15 +73,15 @@ ADDON_STATUS ADDON_Create(void* hdl, void* props)
if (!XBMC->RegisterMe(hdl)) if (!XBMC->RegisterMe(hdl))
{ {
SAFE_DELETE(XBMC); SAFE_DELETE(XBMC);
return ADDON_STATUS_UNKNOWN; return ADDON_STATUS_PERMANENT_FAILURE;
} }


PVR = new CHelper_libXBMC_pvr; PVR = new CHelper_libXBMC_pvr;
if (!PVR->RegisterMe(hdl)) if (!PVR->RegisterMe(hdl))
{ {
SAFE_DELETE(PVR); SAFE_DELETE(PVR);
SAFE_DELETE(XBMC); SAFE_DELETE(XBMC);
return ADDON_STATUS_UNKNOWN; return ADDON_STATUS_PERMANENT_FAILURE;
} }


#ifdef TSREADER #ifdef TSREADER
Expand Down
14 changes: 6 additions & 8 deletions addons/pvr.hts/src/client.cpp
Expand Up @@ -25,6 +25,7 @@
#include "HTSPDemux.h" #include "HTSPDemux.h"
#include "platform/threads/mutex.h" #include "platform/threads/mutex.h"
#include "platform/util/atomic.h" #include "platform/util/atomic.h"
#include "platform/util/util.h"


using namespace std; using namespace std;
using namespace ADDON; using namespace ADDON;
Expand Down Expand Up @@ -128,19 +129,16 @@ ADDON_STATUS ADDON_Create(void* hdl, void* props)
XBMC = new CHelper_libXBMC_addon; XBMC = new CHelper_libXBMC_addon;
if (!XBMC->RegisterMe(hdl)) if (!XBMC->RegisterMe(hdl))
{ {
delete XBMC; SAFE_DELETE(XBMC);
XBMC = NULL; return ADDON_STATUS_PERMANENT_FAILURE;
return ADDON_STATUS_UNKNOWN;
} }


PVR = new CHelper_libXBMC_pvr; PVR = new CHelper_libXBMC_pvr;
if (!PVR->RegisterMe(hdl)) if (!PVR->RegisterMe(hdl))
{ {
delete PVR; SAFE_DELETE(PVR);
delete XBMC; SAFE_DELETE(XBMC);
PVR = NULL; return ADDON_STATUS_PERMANENT_FAILURE;
XBMC = NULL;
return ADDON_STATUS_UNKNOWN;
} }


XBMC->Log(LOG_DEBUG, "%s - Creating Tvheadend PVR-Client", __FUNCTION__); XBMC->Log(LOG_DEBUG, "%s - Creating Tvheadend PVR-Client", __FUNCTION__);
Expand Down
4 changes: 2 additions & 2 deletions addons/pvr.mediaportal.tvserver/src/client.cpp
Expand Up @@ -78,15 +78,15 @@ ADDON_STATUS ADDON_Create(void* hdl, void* props)
if (!XBMC->RegisterMe(hdl)) if (!XBMC->RegisterMe(hdl))
{ {
SAFE_DELETE(XBMC); SAFE_DELETE(XBMC);
return ADDON_STATUS_UNKNOWN; return ADDON_STATUS_PERMANENT_FAILURE;
} }


PVR = new CHelper_libXBMC_pvr; PVR = new CHelper_libXBMC_pvr;
if (!PVR->RegisterMe(hdl)) if (!PVR->RegisterMe(hdl))
{ {
SAFE_DELETE(PVR); SAFE_DELETE(PVR);
SAFE_DELETE(XBMC); SAFE_DELETE(XBMC);
return ADDON_STATUS_UNKNOWN; return ADDON_STATUS_PERMANENT_FAILURE;
} }


XBMC->Log(LOG_INFO, "Creating MediaPortal PVR-Client"); XBMC->Log(LOG_INFO, "Creating MediaPortal PVR-Client");
Expand Down
4 changes: 2 additions & 2 deletions addons/pvr.nextpvr/src/client.cpp
Expand Up @@ -66,15 +66,15 @@ ADDON_STATUS ADDON_Create(void* hdl, void* props)
if (!XBMC->RegisterMe(hdl)) if (!XBMC->RegisterMe(hdl))
{ {
SAFE_DELETE(XBMC); SAFE_DELETE(XBMC);
return ADDON_STATUS_UNKNOWN; return ADDON_STATUS_PERMANENT_FAILURE;
} }


PVR = new CHelper_libXBMC_pvr; PVR = new CHelper_libXBMC_pvr;
if (!PVR->RegisterMe(hdl)) if (!PVR->RegisterMe(hdl))
{ {
SAFE_DELETE(PVR); SAFE_DELETE(PVR);
SAFE_DELETE(XBMC); SAFE_DELETE(XBMC);
return ADDON_STATUS_UNKNOWN; return ADDON_STATUS_PERMANENT_FAILURE;
} }


XBMC->Log(LOG_INFO, "Creating NextPVR PVR-Client"); XBMC->Log(LOG_INFO, "Creating NextPVR PVR-Client");
Expand Down
13 changes: 10 additions & 3 deletions addons/pvr.njoy/src/client.cpp
Expand Up @@ -22,7 +22,7 @@
#include "client.h" #include "client.h"
#include "xbmc_pvr_dll.h" #include "xbmc_pvr_dll.h"
#include "N7Xml.h" #include "N7Xml.h"

#include "platform/util/util.h"


using namespace std; using namespace std;
using namespace ADDON; using namespace ADDON;
Expand Down Expand Up @@ -73,11 +73,18 @@ ADDON_STATUS ADDON_Create(void* hdl, void* props)


XBMC = new CHelper_libXBMC_addon; XBMC = new CHelper_libXBMC_addon;
if (!XBMC->RegisterMe(hdl)) if (!XBMC->RegisterMe(hdl))
return ADDON_STATUS_UNKNOWN; {
SAFE_DELETE(XBMC);
return ADDON_STATUS_PERMANENT_FAILURE;
}


PVR = new CHelper_libXBMC_pvr; PVR = new CHelper_libXBMC_pvr;
if (!PVR->RegisterMe(hdl)) if (!PVR->RegisterMe(hdl))
return ADDON_STATUS_UNKNOWN; {
SAFE_DELETE(PVR);
SAFE_DELETE(XBMC);
return ADDON_STATUS_PERMANENT_FAILURE;
}
XBMC->Log(LOG_DEBUG, "Creating N7 PVR-Client"); XBMC->Log(LOG_DEBUG, "Creating N7 PVR-Client");


m_CurStatus = ADDON_STATUS_UNKNOWN; m_CurStatus = ADDON_STATUS_UNKNOWN;
Expand Down
21 changes: 12 additions & 9 deletions addons/pvr.vdr.vnsi/src/client.cpp
Expand Up @@ -25,6 +25,7 @@
#include "VNSIRecording.h" #include "VNSIRecording.h"
#include "VNSIData.h" #include "VNSIData.h"
#include "VNSIChannelScan.h" #include "VNSIChannelScan.h"
#include "platform/util/util.h"


#include <sstream> #include <sstream>
#include <string> #include <string>
Expand Down Expand Up @@ -70,23 +71,25 @@ ADDON_STATUS ADDON_Create(void* hdl, void* props)
XBMC = new CHelper_libXBMC_addon; XBMC = new CHelper_libXBMC_addon;
if (!XBMC->RegisterMe(hdl)) if (!XBMC->RegisterMe(hdl))
{ {
delete XBMC; SAFE_DELETE(XBMC);
XBMC = NULL; return ADDON_STATUS_PERMANENT_FAILURE;
return ADDON_STATUS_UNKNOWN;
} }


GUI = new CHelper_libXBMC_gui; GUI = new CHelper_libXBMC_gui;
if (!GUI->RegisterMe(hdl)) if (!GUI->RegisterMe(hdl))
return ADDON_STATUS_UNKNOWN; {
SAFE_DELETE(GUI);
SAFE_DELETE(XBMC);
return ADDON_STATUS_PERMANENT_FAILURE;
}


PVR = new CHelper_libXBMC_pvr; PVR = new CHelper_libXBMC_pvr;
if (!PVR->RegisterMe(hdl)) if (!PVR->RegisterMe(hdl))
{ {
delete PVR; SAFE_DELETE(PVR);
delete XBMC; SAFE_DELETE(GUI);
PVR = NULL; SAFE_DELETE(XBMC);
XBMC = NULL; return ADDON_STATUS_PERMANENT_FAILURE;
return ADDON_STATUS_UNKNOWN;
} }


XBMC->Log(LOG_DEBUG, "Creating VDR VNSI PVR-Client"); XBMC->Log(LOG_DEBUG, "Creating VDR VNSI PVR-Client");
Expand Down
14 changes: 6 additions & 8 deletions addons/pvr.vuplus/src/client.cpp
Expand Up @@ -23,6 +23,7 @@
#include "xbmc_pvr_dll.h" #include "xbmc_pvr_dll.h"
#include <stdlib.h> #include <stdlib.h>
#include "VuData.h" #include "VuData.h"
#include "platform/util/util.h"


using namespace std; using namespace std;
using namespace ADDON; using namespace ADDON;
Expand Down Expand Up @@ -166,19 +167,16 @@ ADDON_STATUS ADDON_Create(void* hdl, void* props)
XBMC = new CHelper_libXBMC_addon; XBMC = new CHelper_libXBMC_addon;
if (!XBMC->RegisterMe(hdl)) if (!XBMC->RegisterMe(hdl))
{ {
delete XBMC; SAFE_DELETE(XBMC);
XBMC = NULL; return ADDON_STATUS_PERMANENT_FAILURE;
return ADDON_STATUS_UNKNOWN;
} }


PVR = new CHelper_libXBMC_pvr; PVR = new CHelper_libXBMC_pvr;
if (!PVR->RegisterMe(hdl)) if (!PVR->RegisterMe(hdl))
{ {
delete PVR; SAFE_DELETE(PVR);
delete XBMC; SAFE_DELETE(XBMC);
PVR = NULL; return ADDON_STATUS_PERMANENT_FAILURE;
XBMC = NULL;
return ADDON_STATUS_UNKNOWN;
} }


XBMC->Log(LOG_DEBUG, "%s - Creating VU+ PVR-Client", __FUNCTION__); XBMC->Log(LOG_DEBUG, "%s - Creating VU+ PVR-Client", __FUNCTION__);
Expand Down
27 changes: 27 additions & 0 deletions lib/platform/util/util.h
@@ -0,0 +1,27 @@
#pragma once
/*
* Copyright (C) 2012 Team XBMC
* http://www.xbmc.org
*
* 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
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with XBMC; see the file COPYING. If not, see
* <http://www.gnu.org/licenses/>.
*
*/

#ifndef SAFE_DELETE
#define SAFE_DELETE(p) do { delete (p); (p)=NULL; } while (0)
#endif
#ifndef SAFE_DELETE_ARRAY
#define SAFE_DELETE_ARRAY(p) do { delete[] (p); (p)=NULL; } while (0)
#endif

0 comments on commit b908d34

Please sign in to comment.