Skip to content

Commit

Permalink
Fix various app crashed related to resource system
Browse files Browse the repository at this point in the history
  • Loading branch information
manup committed May 18, 2017
1 parent 256f2ce commit be873c9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
3 changes: 3 additions & 0 deletions colorspace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1350,6 +1350,9 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray*prhs[])
******************************************************************************/
void MiredColorTemperatureToXY(unsigned short int temperature, unsigned short int *x, unsigned short int *y)
{
if (temperature == 0)
temperature = 153;

unsigned long long localX, localY;
unsigned short int temp = 1000000 / temperature;

Expand Down
7 changes: 6 additions & 1 deletion light_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -380,9 +380,14 @@ void LightNode::setColorTemperature(uint16_t colorTemperature)
*/
const QString &LightNode::colorMode() const
{
static QString foo;
const ResourceItem *i = item(RStateColorMode);
DBG_Assert(i != 0);
return i->toString();
if (i)
{
return i->toString();
}
return foo;
}

/*! Sets the current colormode.
Expand Down
5 changes: 2 additions & 3 deletions rest_groups.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1230,7 +1230,7 @@ int DeRestPluginPrivate::setGroupState(const ApiRequest &req, ApiResponse &rsp)

item = i->item(RStateHue);

if (item->toNumber() != hue)
if (item && item->toNumber() != hue)
{
i->setEnhancedHue(hue);
item->setValue(hue);
Expand Down Expand Up @@ -2150,8 +2150,7 @@ int DeRestPluginPrivate::storeScene(const ApiRequest &req, ApiResponse &rsp)
needModify = true;
}
}

if (item->toString() == QLatin1String("ct"))
else if (item->toString() == QLatin1String("ct"))
{
item = lightNode->item(RStateCt);
DBG_Assert(item != 0);
Expand Down

0 comments on commit be873c9

Please sign in to comment.