fix error handling in Camera::getDescription()
This commit is contained in:
33
uvoscam.cpp
33
uvoscam.cpp
@ -284,6 +284,7 @@ std::vector<Camera::Description> Camera::getAvailableCameras(bool update)
|
|||||||
{
|
{
|
||||||
if(!scanned_ || update)
|
if(!scanned_ || update)
|
||||||
{
|
{
|
||||||
|
arv_enable_interface("Fake");
|
||||||
arv_update_device_list();
|
arv_update_device_list();
|
||||||
scanned_ = true;
|
scanned_ = true;
|
||||||
}
|
}
|
||||||
@ -351,6 +352,7 @@ Camera::~Camera()
|
|||||||
}
|
}
|
||||||
if(ARV_IS_CAMERA(aCamera_))
|
if(ARV_IS_CAMERA(aCamera_))
|
||||||
g_object_unref(aCamera_);
|
g_object_unref(aCamera_);
|
||||||
|
delete description;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Camera::isOpen()
|
bool Camera::isOpen()
|
||||||
@ -461,17 +463,26 @@ void Camera::trigger()
|
|||||||
|
|
||||||
Camera::Description Camera::getDescription()
|
Camera::Description Camera::getDescription()
|
||||||
{
|
{
|
||||||
Description desc;
|
if(!description)
|
||||||
if(ARV_IS_CAMERA(aCamera_))
|
|
||||||
{
|
{
|
||||||
GError* error;
|
if(ARV_IS_CAMERA(aCamera_))
|
||||||
desc.vendor = arv_camera_get_vendor_name(aCamera_, &error);
|
{
|
||||||
desc.serial = arv_camera_get_device_serial_number(aCamera_, &error);
|
description = new Description;
|
||||||
desc.id = arv_camera_get_device_id(aCamera_, &error);
|
GError* error = nullptr;
|
||||||
desc.model= arv_camera_get_model_name(aCamera_, &error);
|
if(!error)
|
||||||
if(!error)
|
description->vendor = arv_camera_get_vendor_name(aCamera_, &error);
|
||||||
return desc;
|
if(!error)
|
||||||
else return Description();
|
description->serial = arv_camera_get_device_serial_number(aCamera_, &error);
|
||||||
|
if(!error)
|
||||||
|
description->id = arv_camera_get_device_id(aCamera_, &error);
|
||||||
|
if(!error)
|
||||||
|
description->model = arv_camera_get_model_name(aCamera_, &error);
|
||||||
|
if(error)
|
||||||
|
{
|
||||||
|
delete description;
|
||||||
|
description = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return desc;
|
return description ? *description : Description();
|
||||||
}
|
}
|
||||||
|
@ -39,6 +39,8 @@ public:
|
|||||||
|
|
||||||
class Description
|
class Description
|
||||||
{
|
{
|
||||||
|
private:
|
||||||
|
size_t hash = 0;
|
||||||
public:
|
public:
|
||||||
std::string vendor;
|
std::string vendor;
|
||||||
std::string serial;
|
std::string serial;
|
||||||
@ -47,7 +49,9 @@ public:
|
|||||||
|
|
||||||
size_t getHash() const
|
size_t getHash() const
|
||||||
{
|
{
|
||||||
return std::hash<std::string>{}(vendor + serial + id + model);
|
//if(hash == 0)
|
||||||
|
return /*hash =*/ std::hash<std::string>{}(vendor + serial + id + model);
|
||||||
|
//return hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator==(const Description& in) const
|
bool operator==(const Description& in) const
|
||||||
@ -83,6 +87,8 @@ private:
|
|||||||
ArvStream* aStream_ = nullptr;
|
ArvStream* aStream_ = nullptr;
|
||||||
ArvCamera* aCamera_ = nullptr;
|
ArvCamera* aCamera_ = nullptr;
|
||||||
|
|
||||||
|
Description* description = nullptr;
|
||||||
|
|
||||||
unsigned int width_;
|
unsigned int width_;
|
||||||
unsigned int height_;
|
unsigned int height_;
|
||||||
int64_t format = -1;
|
int64_t format = -1;
|
||||||
|
Reference in New Issue
Block a user