Skip to content

Commit

Permalink
Save default value to prevent crash
Browse files Browse the repository at this point in the history
  • Loading branch information
knro committed Oct 14, 2023
1 parent 4732cad commit d1622b9
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions indi-svbony/svbony_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ void SVBONYBase::workerExposure(const std::atomic_bool &isAboutToQuit, float dur
/*
Perform exposure and image data reading
*/
int nRetry = 100; // Number of retries when ret is SVB_ERROR_TIMEOUT
int nRetry = 100; // Number of retries when ret is SVB_ERROR_TIMEOUT
while (1)
{
if (isAboutToQuit)
Expand Down Expand Up @@ -240,7 +240,7 @@ void SVBONYBase::workerExposure(const std::atomic_bool &isAboutToQuit, float dur
delay = 0.5f;
break;
}
//fall through
//fall through
default: // Cannot continue to retrive image data when ret is any error except timeout.
if (type == SVB_IMG_RGB24)
free(buffer);
Expand Down Expand Up @@ -317,6 +317,8 @@ bool SVBONYBase::initProperties()
NicknameTP[0].fill("nickname", "nickname", mNickname);
NicknameTP.fill(getDeviceName(), "NICKNAME", "Nickname", INFO_TAB, IP_RW, 60, IPS_IDLE);

IUSaveText(&BayerT[2], "GRBG");

addAuxControls();

return true;
Expand Down Expand Up @@ -1357,4 +1359,4 @@ bool SVBONYBase::saveConfigItems(FILE *fp)
bool SVBONYBase::SetCaptureFormat(uint8_t index)
{
return setVideoFormat(index);
}
}

1 comment on commit d1622b9

@jctk
Copy link
Contributor

@jctk jctk commented on d1622b9 Oct 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Jasem

I understand this change as a workaround. This issue is workaroundable, so there is no change itself or any other problem. But it is not a good idea to assume and register a Bayer Pattern that has not yet been determined.
The Bayer Pattern is obtained from the camera at the time of Connect, so it should be initialized at that time.
I have fixed several bugs, including this one, and submitted a pull request today.

The root cause of the problem may be solved by the following methods. I believe these methods will result in a more robust INDI::PropertyText with fewer segmentation faults.

  • Prepare a member function in INDI::PropertyText for comparing strings with INDI::PropertyText instead of strcmp so that INDI::PropertyText can be successfully compared with INDI::PropertyText that contains nullptr.
  • Initialize INDI::PropertyText with "" instead of nullptr when initializing INDI::PropertyText.
  • Make BayerT[].text a private variable and prevent it from being directly referenced. Define an access function to obtain text information and return "" instead of nullptr.
    etc.

These are just a few ideas at the level of ideas, but I believe that measures taken in the base class will reduce problems in the derived classes.

Please sign in to comment.