My project uses qt webengine. The release version works fine, but debug version crashes very quickly when I navigate tumblr.com. Error message shown as below. I want to know what's this message about, and how to fix it.
Versions:
Qt 5.9.4 - msvc2015-32bit
windows 10
Error output:
[16056:14736:0128/180851.894:WARNING:sqlite_channel_id_store.cc(262)] Server bound cert database is too new.
[16056:14736:0128/180851.894:WARNING:sqlite_channel_id_store.cc(262)] Server bound cert database is too new.
[16056:14736:0128/180851.894:FATAL:sqlite_channel_id_store.cc(203)] Check failed: false. Unable to open cert DB.
Backtrace:
GetHandleVerifier [0x112471F7+262887]
QWebEngineUrlSchemeHandler::_q_destroyedUrlSchemeHandler [0x1118256B+3003]
IsSandboxedProcess [0x12D7FBD5+9233173]
IsSandboxedProcess [0x1496E3C7+38521607]
QtWebEngineCore::JavaScriptDialogController::qt_static_metacall [0x1091BA15+7234709]
IsSandboxedProcess [0x143ABE13+32482643]
IsSandboxedProcess [0x143AEE24+32494948]
QtWebEngineCore::ColorChooserController::reject [0x101A8DBE+48654]
GetHandleVerifier [0x112538F4+313828]
IsSandboxedProcess [0x131BF2E2+13687330]
QtWebEngineCore::JavaScriptDialogController::qt_static_metacall [0x10242484+52996]
QtWebEngineCore::JavaScriptDialogController::qt_static_metacall [0x1024259B+53275]
QtWebEngineCore::JavaScriptDialogController::qt_static_metacall [0x10243EF4+59764]
QtWebEngineCore::ColorChooserController::reject [0x101A8DBE+48654]
QWebEngineUrlSchemeHandler::_q_destroyedUrlSchemeHandler [0x111CD7C7+310807]
QWebEngineUrlSchemeHandler::_q_destroyedUrlSchemeHandler [0x111CCC83+307923]
QWebEngineUrlSchemeHandler::_q_destroyedUrlSchemeHandler [0x11200659+519337]
QWebEngineUrlSchemeHandler::_q_destroyedUrlSchemeHandler [0x111909EC+61500]
BaseThreadInitThunk [0x76678654+36]
RtlGetAppContainerNamedObjectPath [0x77834A77+311]
RtlGetAppContainerNamedObjectPath [0x77834A47+263]
[16056:14736:0128/180851.894:FATAL:sqlite_channel_id_store.cc(203)] Check failed: false. Unable to open cert DB.
Backtrace:
GetHandleVerifier [0x112471F7+262887]
QWebEngineUrlSchemeHandler::_q_destroyedUrlSchemeHandler [0x1118256B+3003]
IsSandboxedProcess [0x12D7FBD5+9233173]
IsSandboxedProcess [0x1496E3C7+38521607]
QtWebEngineCore::JavaScriptDialogController::qt_static_metacall [0x1091BA15+7234709]
IsSandboxedProcess [0x143ABE13+32482643]
IsSandboxedProcess [0x143AEE24+32494948]
QtWebEngineCore::ColorChooserController::reject [0x101A8DBE+48654]
GetHandleVerifier [0x112538F4+313828]
IsSandboxedProcess [0x131BF2E2+13687330]
QtWebEngineCore::JavaScriptDialogController::qt_static_metacall [0x10242484+52996]
QtWebEngineCore::JavaScriptDialogController::qt_static_metacall [0x1024259B+53275]
QtWebEngineCore::JavaScriptDialogController::qt_static_metacall [0x10243EF4+59764]
QtWebEngineCore::ColorChooserController::reject [0x101A8DBE+48654]
QWebEngineUrlSchemeHandler::_q_destroyedUrlSchemeHandler [0x111CD7C7+310807]
QWebEngineUrlSchemeHandler::_q_destroyedUrlSchemeHandler [0x111CCC83+307923]
QWebEngineUrlSchemeHandler::_q_destroyedUrlSchemeHandler [0x11200659+519337]
QWebEngineUrlSchemeHandler::_q_destroyedUrlSchemeHandler [0x111909EC+61500]
BaseThreadInitThunk [0x76678654+36]
RtlGetAppContainerNamedObjectPath [0x77834A77+311]
RtlGetAppContainerNamedObjectPath [0x77834A47+263]
The program has unexpectedly finished.
The process was ended forcefully.
WebView initialize:
view_ = new WebView(widget_);
QWebEnginePage *page = new QWebEnginePage(view_);
view_->setPage(page);
page->settings()->setAttribute(QWebEngineSettings::AutoLoadImages, true);
page->settings()->setAttribute(QWebEngineSettings::JavascriptEnabled, true);
page->settings()->setAttribute(QWebEngineSettings::JavascriptCanOpenWindows, true);
page->settings()->setAttribute(QWebEngineSettings::JavascriptCanAccessClipboard, true);
page->settings()->setAttribute(QWebEngineSettings::LinksIncludedInFocusChain, true);
page->settings()->setAttribute(QWebEngineSettings::LocalStorageEnabled, true);
page->settings()->setAttribute(QWebEngineSettings::LocalContentCanAccessRemoteUrls, true);
page->settings()->setAttribute(QWebEngineSettings::XSSAuditingEnabled, true);
page->settings()->setAttribute(QWebEngineSettings::SpatialNavigationEnabled, true);
page->settings()->setAttribute(QWebEngineSettings::LocalContentCanAccessFileUrls, true);
page->settings()->setAttribute(QWebEngineSettings::HyperlinkAuditingEnabled, true);
page->settings()->setAttribute(QWebEngineSettings::ScrollAnimatorEnabled, true);
page->settings()->setAttribute(QWebEngineSettings::ErrorPageEnabled, true);
page->settings()->setAttribute(QWebEngineSettings::PluginsEnabled, true);
page->settings()->setAttribute(QWebEngineSettings::FullScreenSupportEnabled, true);
page->settings()->setAttribute(QWebEngineSettings::ScreenCaptureEnabled, true);
page->settings()->setAttribute(QWebEngineSettings::WebGLEnabled, true);
page->settings()->setAttribute(QWebEngineSettings::Accelerated2dCanvasEnabled, true);
page->settings()->setAttribute(QWebEngineSettings::HyperlinkAuditingEnabled, true);
page->settings()->setAttribute(QWebEngineSettings::AutoLoadIconsForPage, true);
page->settings()->setAttribute(QWebEngineSettings::TouchIconsEnabled, true);
cookie_ = new CookieJar(this); // for cookie sync
page->profile()->setPersistentStoragePath(gVar.getCachePath());
page->profile()->setCachePath(gVar.getCachePath());
page->profile()->setHttpCacheMaximumSize(100 * 1024 * 1024);
page->profile()->setHttpCacheType(QWebEngineProfile::DiskHttpCache);
page->profile()->setHttpUserAgent("Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.101 Safari/537.36");
page->profile()->setPersistentCookiesPolicy(QWebEngineProfile::ForcePersistentCookies);
connect(view_->page(), SIGNAL(loadFinished(bool)),
SLOT(pageLoadFinished()), Qt::QueuedConnection);
QUrl url = QUrl::fromUserInput(kMainPageUrl);
view_->setUrl(url);
WebView is a delegate class, and do nothing:
class WebView : public QWebEngineView
{
Q_OBJECT
public:
explicit WebView(QWidget *parent = 0);
};
run cmd.exe
cd %AppData%/../Local/qwebengine
rmdir /s QtWebEngine
Related
I have just installed Ubuntu 19.04 and I'm using the Qt distribution it provides in the apt-get repo. I'm seeing that the QSytemTrayIcon signals do not emit upon mouse click. I'm aware of the issues with "activated" signal so I also connected a slot to listen to the "aboutToShow" signal from the QSystemTrayIcon's context menu which also should emit on mouse click. Neither of these signals are going out.
Here's my code for the QSystemTrayIcon:
// Create tray and setup tray icon
void MyClass::createTrayIcon()
{
m_pTrayIconMenu = new QMenu(this);
m_pTrayImage = new QPixmap(IMG_SMALL_NOT_CONNECTED);
m_pTrayIcon = new QSystemTrayIcon(this);
m_pTrayIcon->setContextMenu(m_pTrayIconMenu);
QIcon icon(*m_pTrayImage);
m_pTrayIcon->setIcon(icon);
setWindowIcon(icon);
m_pTrayIcon->show();
connect(m_pTrayIconMenu, SIGNAL(aboutToShow()),
this, SLOT(onActivated()));
connect(m_pTrayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
this, SLOT(onActivated(QSystemTrayIcon::ActivationReason)));
}
// Slot to handle context menu aboutToShow signal
void MyClass::onActivated()
{
if (!this->isVisible())
{
this->show();
}
else
{
this->hide();
}
}
// Slot to handle tray icon activated signal
void MyClass::onActivated(QSystemTrayIcon::ActivationReason r)
{
if (r == QSystemTrayIcon::Trigger)
{
if (!this->isVisible())
{
this->show();
}
else
{
this->hide();
}
}
}
In Ubuntu 18.04, the signals all emitted and everything was working fine. In Ubuntu 19.04 the signals do not emit.
I have a Qt Application which i want to show in the System Tray.
My desired behavior is that if the user clicks the close button of the Application than that application hides in the system tray but does not exit.
My code in main.cpp is :
if (QSystemTrayIcon::isSystemTrayAvailable())
{
QObject *root = engine.rootObjects().at(0);
QQuickWindow *window = qobject_cast<QQuickWindow *>(root);
QAction *showAction = new QAction(QObject::tr("Show"), window);
window->connect(showAction, SIGNAL(triggered()), window, SLOT(show()));
QAction *hideAction = new QAction(QObject::tr("Hide"), window);
window->connect(hideAction, SIGNAL(triggered()), window, SLOT(hide()));
QAction *quitAction = new QAction(QObject::tr("&Quit"), window);
window->connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
QObject::connect(qApp,SIGNAL(aboutToQuit()),window,SLOT(hide()));
QMenu *trayIconMenu = new QMenu();
trayIconMenu->addAction(showAction);
trayIconMenu->addAction(hideAction);
trayIconMenu->addSeparator();
trayIconMenu->addAction(quitAction);
QSystemTrayIcon *trayIcon = new QSystemTrayIcon(window);
trayIcon->setContextMenu(trayIconMenu);
trayIcon->setToolTip("xxx");
trayIcon->setIcon(QIcon("xxx.png"));
trayIcon->show();
}
Now i am not able to connect the aboutToQuit signal and hide the application in the tray i.e
QObject::connect(qApp,SIGNAL(aboutToQuit()),window,SLOT(hide())); line is not correct but i am not getting any errors etc.
Apart from this everything is working correctly.Can someone please tell me what i am doing wrong and how can i achieve my desired behavior.
I would also like to know whether i have got the right signal to connect or whether i should try connecting to some other signal.
Thanks in advance.
You can use :
qApp()->setQuitOnLastWindowClosed(false);
quitOnLastWindowClosed property is true by default which causes your application to quit when the last window is closed. By setting it to false, your application does not terminate when you close the main window.
You can also reimplement closeEvent of your main widget, ignore the close event and just hide your window :
void MainWindow::closeEvent(QCloseEvent * e)
{
e->ignore();
this->hide();
}
When I run the following function, the dialog shows with everything in place. The problem is that the buttons won't connect. OK and Cancel do not response to mouse clicks.
void MainWindow::initializeBOX(){
QDialog dlg;
QVBoxLayout la(&dlg);
QLineEdit ed;
la.addWidget(&ed);
//QDialogButtonBox bb(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
//btnbox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
la.addWidget(buttonBox);
dlg.setLayout(&la);
if(dlg.exec() == QDialog::Accepted)
{
mTabWidget->setTabText(0, ed.text());
}
}
At runtime, an error in the cmd shows: No such slots as accept() and reject().
You are specifying the wrong receiver in the connection. It's the dialog that has the accept() and reject() slots, not the main window (i.e. this).
So, instead, you just need:
connect(buttonBox, SIGNAL(accepted()), &dlg, SLOT(accept()));
connect(buttonBox, SIGNAL(rejected()), &dlg, SLOT(reject()));
And now when you click the buttons, the dialog will close, and exec() will return either QDialog::Accepted for OK, or QDialog::Rejected for Cancel.
I am trying to listen for SIP messages on multiple ports within my Qt console-based application. I am simply creating multiple objects of my class proxy.
Sample example of proxy.cpp:
proxy* thisProxy;
proxy::proxy(quint16 port, QObject *parent) :
QObject(parent), portFromConfig(port)
{
thisProxy = this;
thread = new QThread(this);
connect(thread, SIGNAL(started()), this, SLOT(start()));
connect(thread, SIGNAL(finished()), this, SLOT(deleteLater()));
this->moveToThread(thread);
thread->start();
}
void proxy::start()
{
pj_status_t status;
pj_caching_pool caching_pool;
pj_sockaddr_in sockaddr;
pj_str_t ourAddressFromConfig;
pj_thread_desc initdec;
pj_thread_t* thread = 0;
if (!pj_thread_is_registered() && pj_thread_register("PJ_THREAD", initdec, &thread ) != PJ_SUCCESS)
return;
pjsip_module proxy = {
NULL,
NULL,
pj_str("proxy"),
-1,
PJSIP_MOD_PRIORITY_UA_PROXY_LAYER,
NULL,
NULL,
NULL,
NULL,
&onReceivedRequest,
&onReceivedResponse,
NULL,
NULL,
NULL
};
pj_log_set_level(4);
//initialize pj
status = pj_init();
if (status != PJ_SUCCESS)
{
qDebug() << "pj_init failed";
return;
}
//initilaize pjlib_util
status = pjlib_util_init();
if (status != PJ_SUCCESS)
{
qDebug() << "pjlib_util_init failed";
return;
}
//initialize caching pool
pj_caching_pool_init(&caching_pool, &pj_pool_factory_default_policy, 0);
//create the endpoint
status = pjsip_endpt_create(&caching_pool.factory, NULL, &endpoint);
if (status != PJ_SUCCESS)
{
qDebug() << "pjsip_endpt_create failed";
return;
}
//specify our socket
ourAddressFromConfig = pj_str(addressFromConfig.toLatin1().data());
sockaddr.sin_family = pj_AF_INET();
if (ourAddressFromConfig.slen)
pj_inet_aton(&ourAddressFromConfig, &sockaddr.sin_addr);
else
sockaddr.sin_addr.s_addr = 0;
sockaddr.sin_port = pj_htons((pj_uint16_t) portFromConfig);
//start the socket
status = pjsip_udp_transport_start(endpoint, &sockaddr, NULL, 1, &transport);
if (status != PJ_SUCCESS)
{
qDebug() << "pjsip_udp_transport_start failed";
return;
}
//create the caching pool
poolt = pj_pool_create(&caching_pool.factory, "UDPproxy", 4000, 4000, NULL);
//register the proxy module
status = pjsip_endpt_register_module(endpoint, &proxy);
if (status != PJ_SUCCESS)
{
qDebug() << "pjsip_endpt_register_module failed";
return;
}
pj_time_val delay = {0, 10};
while(true)
{
pjsip_endpt_handle_events(endpoint, &delay);
}
qDebug() << "finished";
}
The most interesting thing is that when I create first two instances of proxy its working but when I create the third instance my app terminates with these error:
server: ../src/pjsip/sip_tel_uri.c:173: pjsip_tel_uri_subsys_init: Assertion `status==0' failed.
Aborted (core dumped)
Backtrace from dumped core:
(gdb) bt
#0 0xb777d424 in __kernel_vsyscall ()
#1 0xb6e881df in raise () from /lib/i386-linux-gnu/libc.so.6
#2 0xb6e8b825 in abort () from /lib/i386-linux-gnu/libc.so.6
#3 0xb6e81085 in ?? () from /lib/i386-linux-gnu/libc.so.6
#4 0xb6e81137 in __assert_fail () from /lib/i386-linux-gnu/libc.so.6
#5 0x08079344 in pjsip_tel_uri_subsys_init ()
#6 0x08069265 in pjsip_endpt_create ()
#7 0x080569a7 in proxy::start (this=0x8905db8) at ../server/proxy.cpp:93
#8 0x0805f0c1 in proxy::qt_static_metacall (_o=0x8905db8, _c=QMetaObject::InvokeMetaMethod, _id=1, _a=0xb3aff270) at moc_proxy.cpp:75
#9 0xb73d4c5d in QMetaObject::activate(QObject*, int, int, void**) () from /home/dev/Qt/5.1.1/gcc/lib/libQt5Core.so.5
#10 0xb73d567b in QMetaObject::activate(QObject*, QMetaObject const*, int, void**) () from /home/dev/Qt/5.1.1/gcc/lib/libQt5Core.so.5
#11 0xb7444ef5 in QThread::started(QThread::QPrivateSignal) () from /home/dev/Qt/5.1.1/gcc/lib/libQt5Core.so.5
#12 0xb71d7388 in ?? () from /home/dev/Qt/5.1.1/gcc/lib/libQt5Core.so.5
#13 0xb713ad4c in start_thread () from /lib/i386-linux-gnu/libpthread.so.0
#14 0xb6f49bae in clone () from /lib/i386-linux-gnu/libc.so.6
I don't know what am I doing wrong. Could anybody help, please?
Thanks in advance for any help.
Main problem is that you're creating a new SIP endpoint on every proxy instance and, although current documentation states that "theoretically", multiple instance of SIP endpoint is supported, actually, it is not.
More specifically, first time you call pjsip_endpt_create three static URI parsers are registered (for sip:, sips: and tel:), second time tel: is registered again (there's a check to avoid sip: and sips: but not for tel:) and, when trying to register tel: again, at third time, maximum number of URI parsers (4) is overpassed, registration fails and an assertion dumps.
I suggest you to work with only one SIP endpoint, creating a new UDP socket for every proxy instance and attaching it to the endpoint by using pjsip_udp_transport_attach2
I try to get this following url using the downloadURL function as follows:
http://www.ncbi.nlm.nih.gov/nuccore/27884304
But the data is not as what we can see through the browser, now I know it's because some correct information (such as browser type) is needed. How can I know what kind of information I need to set, and how can I set it? (By setHeader function or some other way??)
In VC++, we can use CInternetSession and CHttpConnection Object to get the correct data without setting any other detail information, is there any similar way in Qt or other cross-platform C++ network lib?? (Yes, I need the the cross-platform property.)
QNetworkReply::NetworkError downloadURL(const QUrl &url, QByteArray &data) {
QNetworkAccessManager manager;
QNetworkRequest request(url);
request.setHeader(QNetworkRequest::ContentTypeHeader ,"Mozilla/5.0 (Windows; U; Windows NT
6.0; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7 (.NET CLR 3.5.30729)");
QNetworkReply *reply = manager.get(request);
QEventLoop loop;
QObject::connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
loop.exec();
QVariant statusCodeV = reply->attribute(QNetworkRequest::RedirectionTargetAttribute);
QUrl redirectTo = statusCodeV.toUrl();
if (!redirectTo.isEmpty())
{
if (redirectTo.host().isEmpty())
{
const QByteArray newaddr = ("http://"+url.host()+redirectTo.encodedPath()).toAscii();
redirectTo.setEncodedUrl(newaddr);
redirectTo.setHost(url.host());
}
return (downloadURL(redirectTo, data));
}
if (reply->error() != QNetworkReply::NoError)
{
return reply->error();
}
data = reply->readAll();
delete reply;
return QNetworkReply::NoError; }
By VC, we can just do this, then the correct data is in the CHttpFile.
CString downloadURL (CString sGetFromURL)
{
// create an internet session
CInternetSession csiSession;
int pos;
BOOL neof;
// parse URL to get server/object/port
DWORD dwServiceType;
CString sServerName;
CString sObject;
INTERNET_PORT nPort;
CHttpConnection* pHTTPServer = NULL;
CHttpFile* pFile = NULL;
AfxParseURL ( sGetFromURL, dwServiceType, sServerName, sObject, nPort );
// open HTTP connection
pHTTPServer = csiSession.GetHttpConnection ( sServerName, nPort );
// get HTTP object
pFile = pHTTPServer->OpenRequest ( CHttpConnection::HTTP_VERB_GET, sObject, NULL, 1, NULL, NULL, INTERNET_FLAG_RELOAD );
pFile->SendRequest();
}
You set wrong Content-Type header. The value you provided fits more User-Agent header
Close, but you aren't setting the correct header. You need to do:
request.setRawHeader("User-Agent", "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7 (.NET CLR 3.5.30729)" );