mirror of
https://github.com/ariya/phantomjs.git
synced 2024-09-11 12:55:33 +03:00
Replace NULL (or 0) with Q_NULLPTR
This commit is contained in:
parent
a283cb4e55
commit
cb1b04bb50
@ -92,11 +92,11 @@ qint64 ChildProcessContext::_write(const QString& chunk, const QString& encoding
|
|||||||
QTextCodec* codec = QTextCodec::codecForName(encoding.toLatin1());
|
QTextCodec* codec = QTextCodec::codecForName(encoding.toLatin1());
|
||||||
|
|
||||||
// If unavailable, attempt UTF-8 codec
|
// If unavailable, attempt UTF-8 codec
|
||||||
if ((QTextCodec*)NULL == codec) {
|
if (!codec) {
|
||||||
codec = QTextCodec::codecForName("UTF-8");
|
codec = QTextCodec::codecForName("UTF-8");
|
||||||
|
|
||||||
// Don't even try to write if UTF-8 codec is unavailable
|
// Don't even try to write if UTF-8 codec is unavailable
|
||||||
if ((QTextCodec*)NULL == codec) {
|
if (!codec) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ class CookieJar : public QNetworkCookieJar {
|
|||||||
Q_PROPERTY(QVariantList cookies READ cookiesToMap WRITE addCookiesFromMap)
|
Q_PROPERTY(QVariantList cookies READ cookiesToMap WRITE addCookiesFromMap)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CookieJar(QString cookiesFile, QObject* parent = NULL);
|
CookieJar(QString cookiesFile, QObject* parent = Q_NULLPTR);
|
||||||
virtual ~CookieJar();
|
virtual ~CookieJar();
|
||||||
|
|
||||||
bool setCookiesFromUrl(const QList<QNetworkCookie>& cookieList, const QUrl& url);
|
bool setCookiesFromUrl(const QList<QNetworkCookie>& cookieList, const QUrl& url);
|
||||||
|
@ -35,7 +35,7 @@ Encoding::Encoding()
|
|||||||
QTextCodec* codec = QTextCodec::codecForName(DEFAULT_CODEC_NAME);
|
QTextCodec* codec = QTextCodec::codecForName(DEFAULT_CODEC_NAME);
|
||||||
|
|
||||||
// Fall back to locale codec
|
// Fall back to locale codec
|
||||||
if ((QTextCodec*)NULL == codec) {
|
if (!codec) {
|
||||||
codec = QTextCodec::codecForLocale();
|
codec = QTextCodec::codecForLocale();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,7 +49,11 @@ Encoding::Encoding(const QString& encoding)
|
|||||||
|
|
||||||
Encoding::~Encoding()
|
Encoding::~Encoding()
|
||||||
{
|
{
|
||||||
m_codec = (QTextCodec*)NULL;
|
if (m_codec) {
|
||||||
|
// TODO: Encoding class does not inherit QObject, so
|
||||||
|
// we have to nullifyt m_codec member manually;
|
||||||
|
m_codec = Q_NULLPTR;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Encoding::decode(const QByteArray& bytes) const
|
QString Encoding::decode(const QByteArray& bytes) const
|
||||||
@ -73,7 +77,7 @@ void Encoding::setEncoding(const QString& encoding)
|
|||||||
if (!encoding.isEmpty()) {
|
if (!encoding.isEmpty()) {
|
||||||
QTextCodec* codec = QTextCodec::codecForName(encoding.toLatin1());
|
QTextCodec* codec = QTextCodec::codecForName(encoding.toLatin1());
|
||||||
|
|
||||||
if ((QTextCodec*)NULL != codec) {
|
if (codec) {
|
||||||
m_codec = codec;
|
m_codec = codec;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -86,7 +90,7 @@ QTextCodec* Encoding::getCodec() const
|
|||||||
{
|
{
|
||||||
QTextCodec* codec = m_codec;
|
QTextCodec* codec = m_codec;
|
||||||
|
|
||||||
if ((QTextCodec*)NULL == codec) {
|
if (!codec) {
|
||||||
codec = QTextCodec::codecForLocale();
|
codec = QTextCodec::codecForLocale();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,11 +34,11 @@
|
|||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QVariantMap>
|
#include <QVariantMap>
|
||||||
|
|
||||||
static Env* env_instance = NULL;
|
static Env* env_instance = Q_NULLPTR;
|
||||||
|
|
||||||
Env* Env::instance()
|
Env* Env::instance()
|
||||||
{
|
{
|
||||||
if (NULL == env_instance) {
|
if (!env_instance) {
|
||||||
env_instance = new Env();
|
env_instance = new Env();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -216,7 +216,7 @@ void File::close()
|
|||||||
if (m_file) {
|
if (m_file) {
|
||||||
m_file->close();
|
m_file->close();
|
||||||
delete m_file;
|
delete m_file;
|
||||||
m_file = NULL;
|
m_file = Q_NULLPTR;
|
||||||
}
|
}
|
||||||
deleteLater();
|
deleteLater();
|
||||||
}
|
}
|
||||||
@ -228,7 +228,7 @@ bool File::setEncoding(const QString& encoding)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// "Binary" mode doesn't use/need text codecs
|
// "Binary" mode doesn't use/need text codecs
|
||||||
if ((QTextStream*)NULL == m_fileStream) {
|
if (!m_fileStream) {
|
||||||
// TODO: Should we switch to "text" mode?
|
// TODO: Should we switch to "text" mode?
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -237,7 +237,7 @@ bool File::setEncoding(const QString& encoding)
|
|||||||
// "utf-8"), we need to get the codec in the system first and use its
|
// "utf-8"), we need to get the codec in the system first and use its
|
||||||
// canonical name
|
// canonical name
|
||||||
QTextCodec* codec = QTextCodec::codecForName(encoding.toLatin1());
|
QTextCodec* codec = QTextCodec::codecForName(encoding.toLatin1());
|
||||||
if ((QTextCodec*)NULL == codec) {
|
if (!codec) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -258,7 +258,7 @@ QString File::getEncoding() const
|
|||||||
{
|
{
|
||||||
QString encoding;
|
QString encoding;
|
||||||
|
|
||||||
if ((QTextStream*)NULL != m_fileStream) {
|
if (m_fileStream) {
|
||||||
encoding = QString(m_fileStream->codec()->name());
|
encoding = QString(m_fileStream->codec()->name());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ const qint64 MAX_REQUEST_POST_BODY_SIZE = 10 * 1000 * 1000;
|
|||||||
|
|
||||||
static const char* toString(QNetworkAccessManager::Operation op)
|
static const char* toString(QNetworkAccessManager::Operation op)
|
||||||
{
|
{
|
||||||
const char* str = 0;
|
const char* str = Q_NULLPTR;
|
||||||
switch (op) {
|
switch (op) {
|
||||||
case QNetworkAccessManager::HeadOperation:
|
case QNetworkAccessManager::HeadOperation:
|
||||||
str = "HEAD";
|
str = "HEAD";
|
||||||
@ -157,7 +157,7 @@ NetworkAccessManager::NetworkAccessManager(QObject* parent, const Config* config
|
|||||||
, m_maxAuthAttempts(3)
|
, m_maxAuthAttempts(3)
|
||||||
, m_resourceTimeout(0)
|
, m_resourceTimeout(0)
|
||||||
, m_idCounter(0)
|
, m_idCounter(0)
|
||||||
, m_networkDiskCache(0)
|
, m_networkDiskCache(Q_NULLPTR)
|
||||||
, m_sslConfiguration(QSslConfiguration::defaultConfiguration())
|
, m_sslConfiguration(QSslConfiguration::defaultConfiguration())
|
||||||
{
|
{
|
||||||
if (config->diskCacheEnabled()) {
|
if (config->diskCacheEnabled()) {
|
||||||
@ -242,7 +242,7 @@ void NetworkAccessManager::prepareSslConfiguration(const Config* config)
|
|||||||
m_sslConfiguration.setCaCertificates(caCerts);
|
m_sslConfiguration.setCaCertificates(caCerts);
|
||||||
m_sslConfiguration.setLocalCertificate(clientCert);
|
m_sslConfiguration.setLocalCertificate(clientCert);
|
||||||
|
|
||||||
QFile* keyFile = NULL;
|
QFile* keyFile = Q_NULLPTR;
|
||||||
if (config->sslClientKeyFile().isEmpty()) {
|
if (config->sslClientKeyFile().isEmpty()) {
|
||||||
keyFile = new QFile(config->sslClientCertificateFile());
|
keyFile = new QFile(config->sslClientCertificateFile());
|
||||||
} else {
|
} else {
|
||||||
|
@ -57,7 +57,7 @@
|
|||||||
#error "This version of QtWebKit is not supported. Please use QtWebKit >= 5.212"
|
#error "This version of QtWebKit is not supported. Please use QtWebKit >= 5.212"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static Phantom* phantomInstance = NULL;
|
static Phantom* phantomInstance = Q_NULLPTR;
|
||||||
|
|
||||||
// private:
|
// private:
|
||||||
Phantom::Phantom(QObject* parent)
|
Phantom::Phantom(QObject* parent)
|
||||||
@ -157,7 +157,7 @@ void Phantom::init()
|
|||||||
// public:
|
// public:
|
||||||
Phantom* Phantom::instance()
|
Phantom* Phantom::instance()
|
||||||
{
|
{
|
||||||
if (NULL == phantomInstance) {
|
if (!phantomInstance) {
|
||||||
phantomInstance = new Phantom();
|
phantomInstance = new Phantom();
|
||||||
phantomInstance->init();
|
phantomInstance->init();
|
||||||
}
|
}
|
||||||
@ -405,7 +405,7 @@ QString Phantom::proxy()
|
|||||||
{
|
{
|
||||||
QNetworkProxy proxy = QNetworkProxy::applicationProxy();
|
QNetworkProxy proxy = QNetworkProxy::applicationProxy();
|
||||||
if (proxy.hostName().isEmpty()) {
|
if (proxy.hostName().isEmpty()) {
|
||||||
return NULL;
|
return QString();
|
||||||
}
|
}
|
||||||
return proxy.hostName() + ":" + QString::number(proxy.port());
|
return proxy.hostName() + ":" + QString::number(proxy.port());
|
||||||
}
|
}
|
||||||
|
@ -167,7 +167,7 @@ public slots:
|
|||||||
* @param port The proxy port
|
* @param port The proxy port
|
||||||
* @param proxyType The type of this proxy
|
* @param proxyType The type of this proxy
|
||||||
*/
|
*/
|
||||||
void setProxy(const QString& ip, const qint64& port = 80, const QString& proxyType = "http", const QString& user = NULL, const QString& password = NULL);
|
void setProxy(const QString& ip, const qint64& port = 80, const QString& proxyType = "http", const QString& user = QString(), const QString& password = QString());
|
||||||
|
|
||||||
QString proxy();
|
QString proxy();
|
||||||
|
|
||||||
|
@ -66,12 +66,12 @@
|
|||||||
// public:
|
// public:
|
||||||
bool REPL::instanceExists()
|
bool REPL::instanceExists()
|
||||||
{
|
{
|
||||||
return REPL::getInstance() != NULL;
|
return REPL::getInstance() != Q_NULLPTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
REPL* REPL::getInstance(QWebFrame* webframe, Phantom* parent)
|
REPL* REPL::getInstance(QWebFrame* webframe, Phantom* parent)
|
||||||
{
|
{
|
||||||
static REPL* singleton = NULL;
|
static REPL* singleton = Q_NULLPTR;
|
||||||
if (!singleton && webframe && parent) {
|
if (!singleton && webframe && parent) {
|
||||||
// This will create the singleton only when all the parameters are given
|
// This will create the singleton only when all the parameters are given
|
||||||
singleton = new REPL(webframe, parent);
|
singleton = new REPL(webframe, parent);
|
||||||
@ -202,7 +202,7 @@ void REPL::startLoop()
|
|||||||
|
|
||||||
// Load REPL history
|
// Load REPL history
|
||||||
linenoiseHistoryLoad(m_historyFilepath.data()); //< requires "char *"
|
linenoiseHistoryLoad(m_historyFilepath.data()); //< requires "char *"
|
||||||
while (m_looping && (userInput = linenoise(PROMPT)) != NULL) {
|
while (m_looping && (userInput = linenoise(PROMPT)) != Q_NULLPTR) {
|
||||||
if (userInput[0] != '\0') {
|
if (userInput[0] != '\0') {
|
||||||
// Send the user input to the main Phantom frame for evaluation
|
// Send the user input to the main Phantom frame for evaluation
|
||||||
m_webframe->evaluateJavaScript(
|
m_webframe->evaluateJavaScript(
|
||||||
|
@ -54,9 +54,9 @@ QString getOSRelease()
|
|||||||
|
|
||||||
System::System(QObject* parent)
|
System::System(QObject* parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
, m_stdout((File*)NULL)
|
, m_stdout(Q_NULLPTR)
|
||||||
, m_stderr((File*)NULL)
|
, m_stderr(Q_NULLPTR)
|
||||||
, m_stdin((File*)NULL)
|
, m_stdin(Q_NULLPTR)
|
||||||
{
|
{
|
||||||
// Populate "env"
|
// Populate "env"
|
||||||
m_env = Env::instance()->asVariantMap();
|
m_env = Env::instance()->asVariantMap();
|
||||||
@ -165,17 +165,17 @@ System::System(QObject* parent)
|
|||||||
System::~System()
|
System::~System()
|
||||||
{
|
{
|
||||||
// Clean-up standard streams
|
// Clean-up standard streams
|
||||||
if ((File*)NULL != m_stdout) {
|
if (m_stdout) {
|
||||||
delete m_stdout;
|
delete m_stdout;
|
||||||
m_stdout = (File*)NULL;
|
m_stdout = Q_NULLPTR;
|
||||||
}
|
}
|
||||||
if ((File*)NULL != m_stderr) {
|
if (m_stderr) {
|
||||||
delete m_stderr;
|
delete m_stderr;
|
||||||
m_stderr = (File*)NULL;
|
m_stderr = Q_NULLPTR;
|
||||||
}
|
}
|
||||||
if ((File*)NULL != m_stdin) {
|
if (m_stdin) {
|
||||||
delete m_stdin;
|
delete m_stdin;
|
||||||
m_stdin = (File*)NULL;
|
m_stdin = Q_NULLPTR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -211,7 +211,7 @@ bool System::isSSLSupported() const
|
|||||||
|
|
||||||
QObject* System::_stdout()
|
QObject* System::_stdout()
|
||||||
{
|
{
|
||||||
if ((File*)NULL == m_stdout) {
|
if (!m_stdout) {
|
||||||
QFile* f = new QFile();
|
QFile* f = new QFile();
|
||||||
f->open(stdout, QIODevice::WriteOnly | QIODevice::Unbuffered);
|
f->open(stdout, QIODevice::WriteOnly | QIODevice::Unbuffered);
|
||||||
m_stdout = createFileInstance(f);
|
m_stdout = createFileInstance(f);
|
||||||
@ -222,7 +222,7 @@ QObject* System::_stdout()
|
|||||||
|
|
||||||
QObject* System::_stderr()
|
QObject* System::_stderr()
|
||||||
{
|
{
|
||||||
if ((File*)NULL == m_stderr) {
|
if (!m_stderr) {
|
||||||
QFile* f = new QFile();
|
QFile* f = new QFile();
|
||||||
f->open(stderr, QIODevice::WriteOnly | QIODevice::Unbuffered);
|
f->open(stderr, QIODevice::WriteOnly | QIODevice::Unbuffered);
|
||||||
m_stderr = createFileInstance(f);
|
m_stderr = createFileInstance(f);
|
||||||
@ -233,7 +233,7 @@ QObject* System::_stderr()
|
|||||||
|
|
||||||
QObject* System::_stdin()
|
QObject* System::_stdin()
|
||||||
{
|
{
|
||||||
if ((File*)NULL == m_stdin) {
|
if (!m_stdin) {
|
||||||
QFile* f = new QFile();
|
QFile* f = new QFile();
|
||||||
f->open(stdin, QIODevice::ReadOnly | QIODevice::Unbuffered);
|
f->open(stdin, QIODevice::ReadOnly | QIODevice::Unbuffered);
|
||||||
m_stdin = createFileInstance(f);
|
m_stdin = createFileInstance(f);
|
||||||
@ -246,15 +246,15 @@ QObject* System::_stdin()
|
|||||||
|
|
||||||
void System::_onTerminalEncodingChanged(const QString& encoding)
|
void System::_onTerminalEncodingChanged(const QString& encoding)
|
||||||
{
|
{
|
||||||
if ((File*)NULL != m_stdin) {
|
if (!m_stdin) {
|
||||||
m_stdin->setEncoding(encoding);
|
m_stdin->setEncoding(encoding);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((File*)NULL != m_stdout) {
|
if (!m_stdout) {
|
||||||
m_stdout->setEncoding(encoding);
|
m_stdout->setEncoding(encoding);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((File*)NULL != m_stderr) {
|
if (!m_stderr) {
|
||||||
m_stderr->setEncoding(encoding);
|
m_stderr->setEncoding(encoding);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,7 @@ class CustomPage : public QWebPage {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CustomPage(WebPage* parent = 0)
|
CustomPage(WebPage* parent = Q_NULLPTR)
|
||||||
: QWebPage(parent)
|
: QWebPage(parent)
|
||||||
, m_webPage(parent)
|
, m_webPage(parent)
|
||||||
{
|
{
|
||||||
@ -265,13 +265,13 @@ class WebpageCallbacks : public QObject {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
WebpageCallbacks(QObject* parent = 0)
|
WebpageCallbacks(QObject* parent = Q_NULLPTR)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
, m_genericCallback(NULL)
|
, m_genericCallback(Q_NULLPTR)
|
||||||
, m_filePickerCallback(NULL)
|
, m_filePickerCallback(Q_NULLPTR)
|
||||||
, m_jsConfirmCallback(NULL)
|
, m_jsConfirmCallback(Q_NULLPTR)
|
||||||
, m_jsPromptCallback(NULL)
|
, m_jsPromptCallback(Q_NULLPTR)
|
||||||
, m_jsInterruptCallback(NULL)
|
, m_jsInterruptCallback(Q_NULLPTR)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1603,7 +1603,7 @@ QObject* WebPage::getPage(const QString& windowName) const
|
|||||||
return childPages.at(i);
|
return childPages.at(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
return Q_NULLPTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WebPage::ownsPages() const
|
bool WebPage::ownsPages() const
|
||||||
@ -1720,7 +1720,7 @@ void WebPage::switchToMainFrame()
|
|||||||
|
|
||||||
bool WebPage::switchToParentFrame()
|
bool WebPage::switchToParentFrame()
|
||||||
{
|
{
|
||||||
if (m_currentFrame->parentFrame() != NULL) {
|
if (m_currentFrame->parentFrame()) {
|
||||||
this->changeCurrentFrame(m_currentFrame->parentFrame());
|
this->changeCurrentFrame(m_currentFrame->parentFrame());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1759,10 +1759,10 @@ static void injectCallbacksObjIntoFrame(QWebFrame* frame, WebpageCallbacks* call
|
|||||||
|
|
||||||
void WebPage::setupFrame(QWebFrame* frame)
|
void WebPage::setupFrame(QWebFrame* frame)
|
||||||
{
|
{
|
||||||
qDebug() << "WebPage - setupFrame" << (frame == NULL ? "" : frame->frameName());
|
qDebug() << "WebPage - setupFrame" << (frame == Q_NULLPTR ? "" : frame->frameName());
|
||||||
|
|
||||||
// Inject the Callbacks object in the main frame
|
// Inject the Callbacks object in the main frame
|
||||||
injectCallbacksObjIntoFrame(frame == NULL ? m_mainFrame : frame, m_callbacks);
|
injectCallbacksObjIntoFrame(frame == Q_NULLPTR ? m_mainFrame : frame, m_callbacks);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebPage::updateLoadingProgress(int progress)
|
void WebPage::updateLoadingProgress(int progress)
|
||||||
|
@ -275,7 +275,7 @@ public slots:
|
|||||||
* @brief getPage
|
* @brief getPage
|
||||||
* @param windowName
|
* @param windowName
|
||||||
* @return Returns the page that matches <code>'window.name'</code>,
|
* @return Returns the page that matches <code>'window.name'</code>,
|
||||||
* or NULL if none is found
|
* or Q_NULLPTR if none is found
|
||||||
*/
|
*/
|
||||||
QObject* getPage(const QString& windowName) const;
|
QObject* getPage(const QString& windowName) const;
|
||||||
|
|
||||||
@ -507,7 +507,7 @@ signals:
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void finish(bool ok);
|
void finish(bool ok);
|
||||||
void setupFrame(QWebFrame* frame = NULL);
|
void setupFrame(QWebFrame* frame = Q_NULLPTR);
|
||||||
void updateLoadingProgress(int progress);
|
void updateLoadingProgress(int progress);
|
||||||
void handleRepaintRequested(const QRect& dirtyRect);
|
void handleRepaintRequested(const QRect& dirtyRect);
|
||||||
void handleUrlChanged(const QUrl& url);
|
void handleUrlChanged(const QUrl& url);
|
||||||
|
@ -119,7 +119,7 @@ bool WebServer::listenOnPort(const QString& port, const QVariantMap& opts)
|
|||||||
options << "enable_keep_alive"
|
options << "enable_keep_alive"
|
||||||
<< "yes";
|
<< "yes";
|
||||||
}
|
}
|
||||||
options << NULL;
|
options << 0;
|
||||||
|
|
||||||
// Start the server
|
// Start the server
|
||||||
m_ctx = mg_start(&callback, this, options.data());
|
m_ctx = mg_start(&callback, this, options.data());
|
||||||
|
Loading…
Reference in New Issue
Block a user