Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix race conditions in signal handling #2

Merged
merged 10 commits into from
Mar 11, 2022
72 changes: 36 additions & 36 deletions resources/default.html
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
<html>
<head>
<title>Qt WebKit browser for Kiosk</title>
<style type="text/css">
.center {
position: absolute;
top: 50%;
left: 50%;
margin-top: -240px;
margin-left: -320px;
width:640;
height:480;
font-size:14pt;
vertical-align:middle;
}
</style>
</head>
<body>
<div class="center">
<h1>Hello, World!</h1>
<p>This is your kiosk browser, written in Qt/C++ & WebKit!</p>
<hr/>
<p>Check <a href="#">link click</a> sound.</p>
<p>Check <a href="#" onclick="window.print(); return false;">print</a> via Javascript</p>
<p>Try <a href="#" onclick="window.close(); return false;">Close window</a> via Javascript (tag a).</p>
<p>Try <button onclick="window.close();">Close window</button> via Javascript (tag button).</p>
<p>Try <button onclick="setTimeout(function(){ for (;;); },100); return false;">Hang JavaScript</button> and wait for Qt to interrupt.</p>
<p>Fullscreen mode switched by &lt;F11&gt;</p>
<p>Toggle Developer Tools by &lt;F12&gt; if enabled</p>
<p>To reload page press &lt;F5&gt;</p>
<p>To reload page with cache clean up press &lt;CTRL+R&gt;</p>
<p>To Quit press &lt;CTRL+Q&gt;</p>
</div>
</body>
</html>
<html>
<head>
<title>Qt WebKit browser for Kiosk</title>
<style type="text/css">
.center {
position: absolute;
top: 50%;
left: 50%;
margin-top: -240px;
margin-left: -320px;

width:640;
height:480;
font-size:14pt;
vertical-align:middle;
}
</style>
</head>
<body>
<div class="center">
<h1>Hello, World!</h1>
<p>This is your kiosk browser, written in Qt/C++ & WebKit!</p>
<hr/>
<p>Check <a href="#">link click</a> sound.</p>
<p>Check <a href="#" onclick="window.print(); return false;">print</a> via Javascript</p>
<p>Try <a href="#" onclick="window.close(); return false;">Close window</a> via Javascript (tag a).</p>
<p>Try <button onclick="window.close();">Close window</button> via Javascript (tag button).</p>
<p>Try <button onclick="setTimeout(function(){ for (;;); },100); return false;">Hang JavaScript</button> and wait for Qt to interrupt.</p>
<p>Fullscreen mode switched by &lt;F11&gt;</p>
<p>Toggle Developer Tools by &lt;F12&gt; if enabled</p>
<p>To reload page press &lt;F5&gt;</p>
<p>To reload page with cache clean up press &lt;CTRL+R&gt;</p>
<p>To Quit press &lt;CTRL+Q&gt;</p>
</div>
</body>
</html>
3 changes: 2 additions & 1 deletion src/anyoption.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1003,10 +1003,11 @@ AnyOption::consumeFile( char *buffer )
bool newline = true;
for( unsigned int i = 0 ; i < strlen( buffer ) ; i++ ){
if( *cursor == endofline ) { /* end of line */
if( pline != NULL ) /* valid line */
if( pline != NULL ) { /* valid line */
processLine( pline, linelength );
pline = NULL;
newline = true;
}
}else if( newline ){ /* start of line */
newline = false;
if( (*cursor != comment ) ){ /* not a comment */
Expand Down
24 changes: 12 additions & 12 deletions src/cachingnm.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#include <cachingnm.h>
CachingNetworkManager::CachingNetworkManager(QObject *parent) : QNetworkAccessManager(parent)
{
}
QNetworkReply *CachingNetworkManager::createRequest(QNetworkAccessManager::Operation op, const QNetworkRequest &req, QIODevice *outgoingData)
{
QNetworkRequest request(req);
request.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache);
return QNetworkAccessManager::createRequest(op, request, outgoingData);
}
#include <cachingnm.h>

CachingNetworkManager::CachingNetworkManager(QObject *parent) : QNetworkAccessManager(parent)
{
}

QNetworkReply *CachingNetworkManager::createRequest(QNetworkAccessManager::Operation op, const QNetworkRequest &req, QIODevice *outgoingData)
{
QNetworkRequest request(req);
request.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache);
return QNetworkAccessManager::createRequest(op, request, outgoingData);
}
34 changes: 17 additions & 17 deletions src/cachingnm.h
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
#ifndef CACHINGNM_H
#define CACHINGNM_H
#include <QtNetwork>
class CachingNetworkManager : public QNetworkAccessManager
{
Q_OBJECT
public:
explicit CachingNetworkManager(QObject* parent = 0);
QNetworkReply *createRequest( Operation op, const QNetworkRequest & req, QIODevice * outgoingData);
};
#endif // CACHINGNM_H
#ifndef CACHINGNM_H
#define CACHINGNM_H

#include <QtNetwork>

class CachingNetworkManager : public QNetworkAccessManager
{
Q_OBJECT

public:
explicit CachingNetworkManager(QObject* parent = 0);

QNetworkReply *createRequest( Operation op, const QNetworkRequest & req, QIODevice * outgoingData);
};


#endif // CACHINGNM_H
50 changes: 25 additions & 25 deletions src/fakewebview.cpp
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
#include <fakewebview.h>
FakeWebView::FakeWebView(QWidget *parent) : QWebView(parent)
{
#include <fakewebview.h>

FakeWebView::FakeWebView(QWidget *parent) : QWebView(parent)
{
this->settings()->setAttribute(QWebSettings::JavascriptEnabled, false);
this->settings()->setAttribute(QWebSettings::WebGLEnabled, false);
this->settings()->setAttribute(QWebSettings::JavaEnabled, false);
this->settings()->setAttribute(QWebSettings::PluginsEnabled, false);
}
void FakeWebView::setUrl(const QUrl &url)
{
emit ( urlChanged( url ) );
}
void FakeWebView::load(const QUrl &url)
{
emit ( urlChanged( url ) );
}
void FakeWebView::load(const QNetworkRequest &request,
QNetworkAccessManager::Operation operation,
const QByteArray &body)
{
Q_UNUSED(operation);
Q_UNUSED(body);
emit ( urlChanged( request.url() ) );
}
}

void FakeWebView::setUrl(const QUrl &url)
{
emit ( urlChanged( url ) );
}


void FakeWebView::load(const QUrl &url)
{
emit ( urlChanged( url ) );
}

void FakeWebView::load(const QNetworkRequest &request,
QNetworkAccessManager::Operation operation,
const QByteArray &body)
{
Q_UNUSED(operation);
Q_UNUSED(body);
emit ( urlChanged( request.url() ) );
}
42 changes: 21 additions & 21 deletions src/fakewebview.h
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
#ifndef FAKEWEBVIEW_H
#define FAKEWEBVIEW_H
#include <QtNetwork>
#ifndef FAKEWEBVIEW_H
#define FAKEWEBVIEW_H

#include <QtNetwork>

#ifdef QT5
#include <QtWebKitWidgets/QWebView>
#include <QtWebKitWidgets/QWebView>
#else
#include <QWebView>
#include <QWebView>
#endif
class FakeWebView : public QWebView
{
Q_OBJECT
public:
explicit FakeWebView(QWidget* parent = 0);
void load(const QUrl& url);
void load(const QNetworkRequest& request, QNetworkAccessManager::Operation operation = QNetworkAccessManager::GetOperation, const QByteArray &body = QByteArray());
void setUrl(const QUrl &url);
};
#endif // FAKEWEBVIEW_H

class FakeWebView : public QWebView
{
Q_OBJECT

public:
explicit FakeWebView(QWidget* parent = 0);

void load(const QUrl& url);
void load(const QNetworkRequest& request, QNetworkAccessManager::Operation operation = QNetworkAccessManager::GetOperation, const QByteArray &body = QByteArray());
void setUrl(const QUrl &url);

};

#endif // FAKEWEBVIEW_H
Loading