Commit 827f5c2d authored by Csaba Kertesz's avatar Csaba Kertesz

Replace NULL with nullptr

parent d0bd857d
......@@ -26,7 +26,7 @@ class BinFileHelper;
BinFileHelper::BinFileHelper()
{
fileHandle = NULL;
fileHandle = nullptr;
init();
}
......@@ -41,7 +41,8 @@ void BinFileHelper::init()
{
if(fileHandle)
fclose(fileHandle);
fileHandle = NULL;
fileHandle = nullptr;
indexUpdated = false;
FDUpdated = false;
RSUpdated = false;
......@@ -84,7 +85,7 @@ FILE * BinFileHelper::openFile(const QString &fileName)
if(!fileHandle)
{
errnum = ERR_FILEOPEN;
return NULL;
return nullptr;
}
return fileHandle;
}
......@@ -269,7 +270,7 @@ bool BinFileHelper::readHeader()
void BinFileHelper::closeFile()
{
fclose(fileHandle);
fileHandle = NULL;
fileHandle = nullptr;
}
int BinFileHelper::getErrorNumber()
......
......@@ -76,7 +76,7 @@ class BinFileHelper
*WARNING: This function may not be compatible in other locales, because it calls QString::toAscii
*@short Open a Binary data file and set the handle
*@param fileName Reference to QString containing the name of the file
*@return Handle to the file if successful, NULL if an error occurred, sets the error.
*@return Handle to the file if successful, nullptr if an error occurred, sets the error.
*/
FILE * openFile(const QString &fileName);
......@@ -132,7 +132,7 @@ class BinFileHelper
/**
*@short Get the file handle corresponding to the currently open file
*@return The filehandle if a file is open, NULL if no file is open
*@return The filehandle if a file is open, nullptr if no file is open
*/
inline FILE * getFileHandle() const
{
......@@ -284,7 +284,7 @@ class BinFileHelper
DT_INT32, /* 32-bit Integer */
DT_UINT32, /* 32-bit Unsigned Integer */
DT_CHARV, /* Fixed-length array of characters */
DT_STR, /* Variable length array of characters, either terminated by NULL or by the limit on field size */
DT_STR, /* Variable length array of characters, either terminated by nullptr or by the limit on field size */
DT_SPCL = 128 /* Flag indicating that the field requires special treatment (eg: Different bits may mean different things) */
};
......
......@@ -61,13 +61,13 @@ class FileDownloader : public QObject
QFile m_DownloadedFile;
// Network reply
QNetworkReply * m_Reply = NULL;
QNetworkReply * m_Reply = nullptr;
// Optional Progress dialog
bool m_ShowProgressDialog = false;
#ifndef KSTARS_LITE
QProgressDialog * progressDialog = NULL;
QProgressDialog * progressDialog = nullptr;
#endif
bool isCancelled = false;
QString label, title;
......
......@@ -55,7 +55,7 @@ class GeoLocation
const QString &name="Nowhere",
const QString &province="Nowhere",
const QString &country="Nowhere",
double TZ=0, TimeZoneRule * TZrule=NULL, bool readOnly=false, int iEllips=4, double hght=-10 );
double TZ=0, TimeZoneRule * TZrule=nullptr, bool readOnly=false, int iEllips=4, double hght=-10 );
/** Constructor using doubles to specify X, Y and Z referred to the center of the Earth.
* @param x the x-position, in m
......@@ -73,7 +73,7 @@ class GeoLocation
const QString &name="Nowhere",
const QString &province="Nowhere",
const QString &country="Nowhere",
double TZ=0, TimeZoneRule * TZrule=NULL, bool readOnly=false, int iEllips=4 );
double TZ=0, TimeZoneRule * TZrule=nullptr, bool readOnly=false, int iEllips=4 );
/** @return pointer to the longitude dms object */
const CachingDms * lng() const
......
......@@ -58,7 +58,7 @@ enum dataType
DT_INT32, /* 32-bit Integer */
DT_UINT32, /* 32-bit Unsigned Integer */
DT_CHARV, /* Fixed-length array of characters */
DT_STR, /* Variable length array of characters, either terminated by NULL or by the limit on field size */
DT_STR, /* Variable length array of characters, either terminated by nullptr or by the limit on field size */
DT_SPCL = 128 /* Flag indicating that the field requires special treatment (eg: Different bits may mean different things) */
};
......@@ -173,10 +173,9 @@ char * number2trixel(char * trixel, u_int16_t number)
int str2int32(int32_t * i, const char * str, int ndec)
{
double dbl;
if(i == NULL)
if (i == nullptr)
return 0;
dbl = atof(str);
......@@ -184,7 +183,6 @@ int str2int32(int32_t * i, const char * str, int ndec)
*i = (int32_t)(round(dbl * pow(10, ndec)));
return 1;
}
/*
......@@ -196,10 +194,9 @@ int str2int32(int32_t * i, const char * str, int ndec)
int str2int16(int16_t * i, const char * str, int ndec)
{
double dbl;
if(i == NULL || str == NULL)
if (i == nullptr || str == nullptr)
return 0;
dbl = atof(str);
......@@ -218,21 +215,17 @@ int str2int16(int16_t * i, const char * str, int ndec)
int str2charv(char * a, const char * str, int n)
{
int i, ret;
if(a == NULL || str == NULL)
if (a == nullptr || str == nullptr)
return 0;
ret = 1;
int ret = 1;
for(i = 0; i < n; ++i)
for (int i = 0; i < n; ++i)
{
a[i] = ((ret < 0)? '\0' : str[i]);
if(str[i] == '\0') /* We can do this safely because we aren't storing binary data in the DB */
if (str[i] == '\0') /* We can do this safely because we aren't storing binary data in the DB */
ret = -1;
}
return ret;
}
......@@ -244,17 +237,15 @@ int str2charv(char * a, const char * str, int n)
int isblank(char * str)
{
if(str == NULL)
if (str == nullptr)
return 1;
while(*str != '\0')
while (*str != '\0')
{
if(*str != ' ' && *str != '\n' && *str != '\r' && *str != '\t')
return 0;
++str;
}
return 1;
}
......@@ -271,8 +262,10 @@ int isblank(char * str)
int writeDataElementDescription(FILE * f, char * name, int8_t size, enum dataType type, int32_t scale)
{
struct dataElement de;
if(f == NULL || name == NULL)
if (f == nullptr || name == nullptr)
return 0;
str2charv(de.name, name, 10);
de.size = size;
de.type = type;
......@@ -283,8 +276,7 @@ int writeDataElementDescription(FILE * f, char * name, int8_t size, enum dataTyp
int writeIndexEntry(FILE * hf, u_int32_t trixel_id, u_int32_t offset, u_int32_t nrec)
{
if(hf == NULL)
if (hf == nullptr)
return 0;
fwrite(&trixel_id, 4, 1, hf);
......@@ -292,7 +284,7 @@ int writeIndexEntry(FILE * hf, u_int32_t trixel_id, u_int32_t offset, u_int32_t
fwrite(&nrec, 4, 1, hf);
/* Put this just for safety, in case we change our mind - we should avoid screwing things up */
if(4 + 4 + 4 != INDEX_ENTRY_SIZE)
if (4 + 4 + 4 != INDEX_ENTRY_SIZE)
{
fprintf(stderr, "CODE ERROR: 4 + 4 + 4 != INDEX_ENTRY_SIZE\n");
}
......
......@@ -422,20 +422,20 @@ int main(int argc, char * argv[])
f = fopen(argv[1], "r");
if(f == NULL)
if(f == nullptr)
{
fprintf(stderr, "ERROR: Could not open file %s for binary read.\n", argv[1]);
return 1;
}
/* Open the Database */
if(mysql_init( &link ) == NULL)
if(mysql_init( &link ) == nullptr)
{
fprintf(stderr, "ERROR: Failed to initialize MySQL connection!\n");
return 1;
}
MYSQL * ret;
ret = mysql_real_connect(&link, "localhost", argv[2], argv[3], db_name, 0, NULL, 0);
ret = mysql_real_connect(&link, "localhost", argv[2], argv[3], db_name, 0, nullptr, 0);
if(!ret)
{
......
......@@ -809,7 +809,8 @@ void DetailDialog::viewLink()
{
QString URL;
if (m_CurrentLink == NULL) return;
if (m_CurrentLink == nullptr)
return;
if ( m_CurrentLink->listWidget() == Links->InfoTitleList )
{
......@@ -853,10 +854,11 @@ void DetailDialog::updateButtons()
void DetailDialog::editLinkDialog()
{
int type=0, row=0;
int type = 0, row = 0;
QString search_line, replace_line, currentItemTitle, currentItemURL;
if (m_CurrentLink == NULL) return;
if (m_CurrentLink == nullptr)
return;
QDialog editDialog( this );
editDialog.setWindowTitle( i18n("Edit Link") );
......@@ -968,7 +970,8 @@ void DetailDialog::removeLinkDialog()
TempFile.open();
TempFileName = TempFile.fileName();
if (m_CurrentLink == NULL) return;
if (m_CurrentLink == nullptr)
return;
if ( m_CurrentLink->listWidget() == Links->InfoTitleList )
{
......@@ -1028,7 +1031,8 @@ void DetailDialog::updateLocalDatabase(int type, const QString &search_line, con
QTemporaryFile TempFile;
TempFile.setAutoRemove(false);
TempFile.open();
QTextStream * temp_stream=NULL, *out_stream=NULL;
QTextStream * temp_stream = nullptr;
QTextStream * out_stream = nullptr;
bool replace = !replace_line.isEmpty();
if (search_line.isEmpty())
......@@ -1091,7 +1095,8 @@ void DetailDialog::updateLocalDatabase(int type, const QString &search_line, con
void DetailDialog::populateADVTree()
{
QTreeWidgetItem * parent = NULL, *temp = NULL;
QTreeWidgetItem * parent = nullptr;
QTreeWidgetItem * temp = nullptr;
// We populate the tree iterativley, keeping track of parents as we go
// This solution is more efficient than the previous recursion algorithm.
......@@ -1103,7 +1108,7 @@ void DetailDialog::populateADVTree()
// Top Level
case 0:
temp = new QTreeWidgetItem(parent, QStringList(item->Name));
if (parent == NULL)
if (parent == nullptr)
Adv->ADVTree->addTopLevelItem(temp);
parent = temp;
......@@ -1111,7 +1116,8 @@ void DetailDialog::populateADVTree()
// End of top level
case 1:
if (parent != NULL) parent = parent->parent();
if (parent != nullptr)
parent = parent->parent();
break;
// Leaf
......@@ -1219,7 +1225,7 @@ void DetailDialog::centerTelescope()
if (gd->getType() != KSTARS_TELESCOPE)
continue;
if (bd == NULL)
if (bd == nullptr)
continue;
if (bd->isConnected() == false)
......
......@@ -46,7 +46,7 @@ LocationDialog::LocationDialog( QWidget * parent ) :
#endif
KStarsData * data = KStarsData::Instance();
SelectedCity = NULL;
SelectedCity = nullptr;
ld = new LocationDialogUI(this);
QVBoxLayout * mainLayout = new QVBoxLayout;
......@@ -259,16 +259,15 @@ bool LocationDialog::addCity()
bool LocationDialog::updateCity()
{
if (SelectedCity == NULL)
if (SelectedCity == nullptr)
return false;
return updateCity(CITY_UPDATE);
}
bool LocationDialog::removeCity()
{
if (SelectedCity == NULL)
if (SelectedCity == nullptr)
return false;
return updateCity(CITY_REMOVE);
......@@ -362,7 +361,7 @@ bool LocationDialog::updateCity(CityOperation operation)
QString province = ld->NewProvinceName->text().trimmed();
QString country = ld->NewCountryName->text().trimmed();
QString TZrule = ld->DSTRuleBox->currentText();
GeoLocation * g = NULL;
GeoLocation * g = nullptr;
switch (operation)
{
......@@ -440,8 +439,8 @@ bool LocationDialog::updateCity(CityOperation operation)
filteredCityList.removeOne(g);
KStarsData::Instance()->getGeoList().removeOne(g);
delete(g);
g=NULL;
delete g;
g = nullptr;
}
break;
}
......
......@@ -77,9 +77,9 @@ Align::Align()
focusState = FOCUS_IDLE;
pahStage = PAH_IDLE;
currentCCD = NULL;
currentTelescope = NULL;
currentFilter = NULL;
currentCCD = nullptr;
currentTelescope = nullptr;
currentFilter = nullptr;
useGuideHead = false;
canSync = false;
//loadSlewMode = false;
......@@ -93,7 +93,7 @@ Align::Align()
decDeviation = azDeviation = altDeviation = 0;
rememberUploadMode = ISD::CCD::UPLOAD_CLIENT;
currentFilter = NULL;
currentFilter = nullptr;
filterPositionPending = false;
lockedFilterIndex = currentFilterIndex = -1;
retries = 0;
......@@ -101,12 +101,12 @@ Align::Align()
solverIterations = 0;
fov_x = fov_y = fov_pixscale = 0;
parser = NULL;
parser = nullptr;
solverFOV = new FOV();
solverFOV->setColor(KStars::Instance()->data()->colorScheme()->colorNamed( "SolverFOVColor" ).name());
onlineParser = NULL;
offlineParser = NULL;
remoteParser = NULL;
onlineParser = nullptr;
offlineParser = nullptr;
remoteParser = nullptr;
showFITSViewerB->setIcon(QIcon::fromTheme("kstars_fitsviewer", QIcon(":/icons/breeze/default/kstars_fitsviewer.svg")));
showFITSViewerB->setAttribute(Qt::WA_LayoutUsesWidgetRect);
......@@ -450,7 +450,7 @@ Align::~Align()
delete(solverFOV);
delete(parser);
if (alignWidget->parent() == NULL)
if (alignWidget->parent() == nullptr)
toggleAlignWidgetFullScreen();
// Remove temporary FITS files left before by the solver
......@@ -864,7 +864,7 @@ const SkyObject * Align::getWizardAlignObject(double ra, double dec)
if(mountModel.alignTypeBox->currentText() == "Any Object")
return KStarsData::Instance()->skyComposite()->objectNearest(new SkyPoint(dms(ra), dms(dec)), maxSearch );
else if(mountModel.alignTypeBox->currentText() == "Fixed DEC" || mountModel.alignTypeBox->currentText() == "Fixed Grid")
return NULL;
return nullptr;
else if(mountModel.alignTypeBox->currentText() == "Any Stars")
return KStarsData::Instance()->skyComposite()->starNearest(new SkyPoint(dms(ra), dms(dec)), maxSearch );
......@@ -1120,7 +1120,7 @@ bool Align::loadAlignmentPoints(const QString &fileURL)
LilXML * xmlParser = newLilXML();
char errmsg[MAXRBUF];
XMLEle * root = NULL;
XMLEle * root = nullptr;
char c;
while ( sFile.getChar(&c))
......@@ -1136,12 +1136,12 @@ bool Align::loadAlignmentPoints(const QString &fileURL)
return false;
}
XMLEle * ep = NULL;
XMLEle * subEP = NULL;
XMLEle * ep = nullptr;
XMLEle * subEP = nullptr;
int currentRow = 0;
for (ep = nextXMLEle(root, 1) ; ep != NULL ; ep = nextXMLEle(root, 0))
for (ep = nextXMLEle(root, 1) ; ep != nullptr ; ep = nextXMLEle(root, 0))
{
if (!strcmp(tagXMLEle(ep), "AlignmentPoint"))
{
......@@ -1789,7 +1789,7 @@ void Align::setSolverType(int type)
{
case SOLVER_ONLINE:
loadSlewB->setEnabled(true);
if (onlineParser != NULL)
if (onlineParser != nullptr)
{
parser = onlineParser;
return;
......@@ -1801,10 +1801,9 @@ void Align::setSolverType(int type)
case SOLVER_OFFLINE:
loadSlewB->setEnabled(true);
if (offlineParser != NULL)
if (offlineParser != nullptr)
{
parser = offlineParser;
return;
}
......@@ -1814,7 +1813,7 @@ void Align::setSolverType(int type)
case SOLVER_REMOTE:
loadSlewB->setEnabled(true);
if (remoteParser != NULL)
if (remoteParser != nullptr)
{
parser = remoteParser;
(dynamic_cast<RemoteAstrometryParser *>(parser))->setAstrometryDevice(remoteParserDevice);
......@@ -1906,7 +1905,7 @@ void Align::setTelescope(ISD::GDInterface * newTelescope)
void Align::syncTelescopeInfo()
{
if (currentTelescope == NULL)
if (currentTelescope == nullptr)
return;
canSync = currentTelescope->canSync();
......@@ -1925,9 +1924,8 @@ void Align::syncTelescopeInfo()
if (nvp)
{
INumber * np = NULL;
INumber * np = IUFindNumber(nvp, "TELESCOPE_APERTURE");
np = IUFindNumber(nvp, "TELESCOPE_APERTURE");
if (np && np->value > 0)
primaryAperture = np->value;
......@@ -1976,9 +1974,9 @@ void Align::syncTelescopeInfo()
void Align::syncCCDInfo()
{
INumberVectorProperty * nvp = NULL;
INumberVectorProperty * nvp = nullptr;
if (currentCCD == NULL)
if (currentCCD == nullptr)
return;
if (useGuideHead)
......@@ -2009,7 +2007,7 @@ void Align::syncCCDInfo()
targetChip->setImageView(alignView, FITS_ALIGN);
targetChip->getFrameMinMax(NULL, NULL, NULL, NULL, NULL, &ccd_width, NULL, &ccd_height);
targetChip->getFrameMinMax(nullptr, nullptr, nullptr, nullptr, nullptr, &ccd_width, nullptr, &ccd_height);
//targetChip->getFrame(&x,&y,&ccd_width,&ccd_height);
binningCombo->setEnabled(targetChip->canBin());
if (targetChip->canBin())
......@@ -2283,7 +2281,7 @@ bool Align::captureAndSolve()
{
//m_isSolverComplete = false;
if (currentCCD == NULL)
if (currentCCD == nullptr)
return false;
if (currentCCD->isConnected() == false)
......@@ -2308,7 +2306,7 @@ bool Align::captureAndSolve()
return false;
}
if (currentFilter != NULL && lockedFilterIndex != -1)
if (currentFilter != nullptr && lockedFilterIndex != -1)
{
if (lockedFilterIndex != currentFilterIndex)
{
......@@ -2506,7 +2504,7 @@ void Align::newFITS(IBLOB * bp)
targetChip->getFrame(&x, &y, &w, &h);
targetChip->getBinning(&binx, &biny);
FITSData * darkData = NULL;
FITSData * darkData = nullptr;
uint16_t offsetX = x / binx;
uint16_t offsetY = y / biny;
......@@ -3892,10 +3890,9 @@ void Align::setFOVTelescopeType(int index)
FOV * Align::fov()
{
if (sOrientation == -1)
return NULL;
return nullptr;
else
return solverFOV;
}
void Align::setLockedFilter(ISD::GDInterface * filter, int lockedPosition)
......@@ -3932,7 +3929,7 @@ void Align::processFilterNumber(INumberVectorProperty * nvp)
void Align::setWCSEnabled(bool enable)
{
if (currentCCD == NULL)
if (currentCCD == nullptr)
return;
ISwitchVectorProperty * wcsControl = currentCCD->getBaseDevice()->getSwitch("WCS_CONTROL");
......@@ -3993,7 +3990,7 @@ QStringList Align::getSolverOptionsFromFITS(const QString &filename)
{
int status = 0, fits_ccd_width, fits_ccd_height, fits_focal_length = -1, fits_binx = 1, fits_biny = 1;
char comment[128], error_status[512];
fitsfile * fptr = NULL;
fitsfile * fptr = nullptr;
double ra = 0, dec = 0, fits_fov_x, fits_fov_y, fov_lower, fov_upper, fits_ccd_hor_pixel = -1, fits_ccd_ver_pixel = -1;
QString fov_low, fov_high;
QStringList solver_args;
......@@ -4169,7 +4166,7 @@ void Align::showFITSViewer()
fv = KStars::Instance()->genericFITSViewer();
else
{
fv = new FITSViewer(Options::independentWindowFITS() ? NULL : KStars::Instance());
fv = new FITSViewer(Options::independentWindowFITS() ? nullptr : KStars::Instance());
KStars::Instance()->getFITSViewersList().append(fv);
}
......@@ -4187,7 +4184,7 @@ void Align::showFITSViewer()
void Align::toggleAlignWidgetFullScreen()
{
if (alignWidget->parent() == NULL)
if (alignWidget->parent() == nullptr)
{
alignWidget->setParent(this);
rightLayout->insertWidget(0, alignWidget);
......@@ -4610,7 +4607,7 @@ void Align::processCCDSwitch(ISwitchVectorProperty * svp)
void Align::updateTelescopeType(int index)
{
if (currentCCD == NULL)
if (currentCCD == nullptr)
return;