Retrieve OAuth2 token with HTTP socket
ClosedPublic

Authored by davidk on Jan 15 2018, 10:26 AM.

Details

Summary

The webview gets redirected to a local socket and sends a http request to it.
The requests argument includes the token. Thus, we don't need to guess the
token page URL (which led to problems in the past).
The old method is deprecated and this method is the recommended one.

Test Plan
  • Login from KOrganizer and KMail works for my two accounts from two PCs (verified with debug logs and a working synchronization)
  • I did not test the error case (how can I do this?)

Diff Detail

Repository
R477 KGAPI Library
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
davidk requested review of this revision.Jan 15 2018, 10:26 AM
davidk created this revision.
mlaurent added inline comments.Jan 17 2018, 8:02 AM
src/core/ui/authwidget.cpp
105

remove space after !

src/core/ui/authwidget_p.cpp
251–255

new line after '()'

252

const QByteArray ?

265–274

QLAtin1Char(' ') + const QStringList

266

it will crash if line is empty no or == 1 ? Perhaps you can test it no ?

283

const

mlaurent requested changes to this revision.Jan 17 2018, 8:02 AM
This revision now requires changes to proceed.Jan 17 2018, 8:02 AM
davidk updated this revision to Diff 25538.Jan 17 2018, 1:22 PM

Fix style and constify

davidk marked 5 inline comments as done.Jan 17 2018, 1:23 PM
davidk added inline comments.Jan 17 2018, 1:26 PM
src/core/ui/authwidget_p.cpp
266

I don't think it will crash. If line.size() is unequal 3, the remaining checks will be skipped (lazy evaluation). Those will only be checked, if line.size() == 3.
Or did I missunderstand your comment?

dvratil requested changes to this revision.Jan 17 2018, 1:44 PM

Generally looks good. I tested it locally and it works nicely. Thanks a lot for the patch! The new user-facing strings are a bit unfortunate since that means we can't land this in Applications/17.12 branch, but I'd like to get this to users before 18.04. Probably we will have to ship the QStringLiteral version to stable branch and make it only translatable in master.

src/core/ui/authwidget.cpp
113

You may want to handle the QTcpSocket::error() signal in case there's some problem, in which case readyRead would not be emitted, so that the OAuth flow does not get stuck but shows an error instead.

115

You may want to use deleteLater() here instead of delete - it's not ideal to delete the emitter from its signal handler, since when code execution returns back to the emitter, it might try to access its this pointer which would be deleted at this point.

src/core/ui/authwidget_p.cpp
265–274

You can use QByteArray::split() and continue operating on QByteArray below and only convert the value on line.at(1) to QString when building the QUrl

266

You are correct, I think Laurent just didn't notice the initial size check.

267

Please add qCDebug(KGAPIRaw) that logs the content of the received data for easier debugging in case there's an error.

268

Please use tr() instead of QStringLiteral here, this is a user-facing message so it needs to be localized.

289

tr() instead of QStringLiteral

src/core/ui/authwidget_p.h
67–69

Initialize the new members here to default values

This revision now requires changes to proceed.Jan 17 2018, 1:44 PM
davidk updated this revision to Diff 25575.Jan 18 2018, 8:12 AM

Fix most issues.

davidk marked 9 inline comments as done.Jan 18 2018, 8:13 AM

I'm fine with putting a QStringLiteral version into 17.12.

src/core/ui/authwidget_p.cpp
267

I don't want to log the recieved data, as I don't want to log the recieved token. Another fast enough application may grab it and access your data. There is a commented log in line 277, one can enable to log it.

With your patch I'm getting a crash when authenticating in KIO GDrive. The crash happens in the last step when the "Authorizing token, please wait" page appears.

The code hits an assert as it appears that webengine failed to load an error page. I wonder if this is related to the redirection to localhost...

(This is with debug build of Qt 5.9.3)

Thread 1 (Thread 0x7f1fd561a8c0 (LWP 14467)):
#0  0x00007f1fd37df66b in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#1  0x00007f1fd37e1381 in __GI_abort () at abort.c:79
#2  0x00007f1fd4515724 in qt_message_fatal(QtMsgType, QMessageLogContext const&, QString const&) (context=..., message="ASSERT: \"success\" in file /data/Qt/qt5/qtwebengine/src/webenginewidgets/api/qwebenginepage.cpp, line 355") at /data/Qt/qt5/qtbase/src/corelib/global/qlogging.cpp:1690
#3  0x00007f1fd4516280 in QMessageLogger::fatal(char const*, ...) const (this=this@entry=0x7ffc02496c30, msg=msg@entry=0x7f1fd47921e0 "ASSERT: \"%s\" in file %s, line %d")
    at /data/Qt/qt5/qtbase/src/corelib/global/qlogging.cpp:796
#4  0x00007f1fd450f6fd in qt_assert(char const*, char const*, int) (assertion=assertion@entry=0x7f1fd56087ed "success", file=file@entry=0x7f1fd5607ec0 "/data/Qt/qt5/qtwebengine/src/webenginewidgets/api/qwebenginepage.cpp", line=line@entry=355) at /data/Qt/qt5/qtbase/src/corelib/global/qglobal.cpp:3077
#5  0x00007f1fd55f1902 in QWebEnginePagePrivate::loadFinished(bool, QUrl const&, bool, int, QString const&) (this=0x17e3310, success=<optimized out>, url=..., isErrorPage=<optimized out>, errorCode=<optimized out>, errorDescription=...) at /data/Qt/qt5/qtwebengine/src/webenginewidgets/api/qwebenginepage.cpp:355
#6  0x00007f1fb51ad355 in QtWebEngineCore::WebContentsDelegateQt::DidFailLoad(content::RenderFrameHost*, GURL const&, int, std::__cxx11::basic_string<unsigned short, base::string16_char_traits, std::allocator<unsigned short> > const&, bool) (this=<optimized out>, render_frame_host=0x1a323a0, validated_url=..., error_code=-3, error_description=..., was_ignored_by_handler=<optimized out>) at /data/Qt/qt5/qtwebengine/src/core/web_contents_delegate_qt.cpp:237
#7  0x00007f1fb6655286 in content::WebContentsImpl::DidFailLoadWithError(content::RenderFrameHostImpl*, GURL const&, int, std::__cxx11::basic_string<unsigned short, base::string16_char_traits, std::allocator<unsigned short> > const&, bool) (this=0x1a9a130, render_frame_host=0x1a323a0, url=..., error_code=-3, error_description="T\000h\000e\000 \000w\000e\000b\000p\000a\000g\000e\000 \000a\000t\000 \000<\000s\000t\000r\000o\000n\000g\000 \000j\000s\000c\000o\000n\000t\000e\000n\000t\000=\000\"\000f\000a\000i\000l\000e\000d\000U\000r\000l\000\"\000>\000<\000/\000s\000t\000r\000o\000n\000g\000>\000 \000m\000i\000g\000h\000t\000 \000b\000e\000 \000t\000e\000m\000p\000o\000r\000a\000r\000i\000l\000y\000 \000d\000o\000w\000n\000 \000o\000r\000 \000i\000t\000 \000m\000a\000y\000 \000h\000a\000v\000e\000 \000m\000o\000v\000e\000"..., was_ignored_by_handler=false)
    at ../../../../../qtwebengine/src/3rdparty/chromium/content/browser/web_contents/web_contents_impl.cc:3350
#8  0x00007f1fb5cb80f4 in content::NavigatorImpl::DidFailLoadWithError(content::RenderFrameHostImpl*, GURL const&, int, std::__cxx11::basic_string<unsigned short, base::string16_char_traits, std::allocator<unsigned short> > const&, bool) (this=0x1ac3e40, render_frame_host=0x1a323a0, url=..., error_code=-3, error_description="T\000h\000e\000 \000w\000e\000b\000p\000a\000g\000e\000 \000a\000t\000 \000<\000s\000t\000r\000o\000n\000g\000 \000j\000s\000c\000o\000n\000t\000e\000n\000t\000=\000\"\000f\000a\000i\000l\000e\000d\000U\000r\000l\000\"\000>\000<\000/\000s\000t\000r\000o\000n\000g\000>\000 \000m\000i\000g\000h\000t\000 \000b\000e\000 \000t\000e\000m\000p\000o\000r\000a\000r\000i\000l\000y\000 \000d\000o\000w\000n\000 \000o\000r\000 \000i\000t\000 \000m\000a\000y\000 \000h\000a\000v\000e\000 \000m\000o\000v\000e\000"..., was_ignored_by_handler=false)
    at ../../../../../qtwebengine/src/3rdparty/chromium/content/browser/frame_host/navigator_impl.cc:276
#9  0x00007f1fb5cc5577 in content::RenderFrameHostImpl::OnDidFailLoadWithError(GURL const&, int, std::__cxx11::basic_string<unsigned short, base::string16_char_traits, std::allocator<unsigned short> > const&, bool) (this=0x1a323a0, url=..., error_code=-3, error_description="T\000h\000e\000 \000w\000e\000b\000p\000a\000g\000e\000 \000a\000t\000 \000<\000s\000t\000r\000o\000n\000g\000 \000j\000s\000c\000o\000n\000t\000e\000n\000t\000=\000\"\000f\000a\000i\000l\000e\000d\000U\000r\000l\000\"\000>\000<\000/\000s\000t\000r\000o\000n\000g\000>\000 \000m\000i\000g\000h\000t\000 \000b\000e\000 \000t\000e\000m\000p\000o\000r\000a\000r\000i\000l\000y\000 \000d\000o\000w\000n\000 \000o\000r\000 \000i\000t\000 \000m\000a\000y\000 \000h\000a\000v\000e\000 \000m\000o\000v\000e\000"..., was_ignored_by_handler=false)
    at ../../../../../qtwebengine/src/3rdparty/chromium/content/browser/frame_host/render_frame_host_impl.cc:1152
#10 0x00007f1fb5cf6512 in base::DispatchToMethodImpl<content::RenderFrameHostImpl*, void (content::RenderFrameHostImpl::*)(GURL const&, int, std::__cxx11::basic_string<unsigned short, base::string16_char_traits, std::allocator<unsigned short> > const&, bool), std::tuple<GURL, int, std::__cxx11::basic_string<unsigned short, base::string16_char_traits, std::allocator<unsigned short> >, bool> const&, 0ul, 1ul, 2ul, 3ul>(content::RenderFrameHostImpl* const&, void (content::RenderFrameHostImpl::*)(GURL const&, int, std::__cxx11::basic_string<unsigned short, base::string16_char_traits, std::allocator<unsigned short> > const&, bool), std::tuple<GURL, int, std::__cxx11::basic_string<unsigned short, base::string16_char_traits, std::allocator<unsigned short> >, bool> const&, base::IndexSequence<0ul, 1ul, 2ul, 3ul>) (obj=@0x7ffc02496f88: 0x1a323a0, method=
    (void (content::RenderFrameHostImpl::*)(content::RenderFrameHostImpl * const, const GURL &, int, const std::__cxx11::basic_string<unsigned short, base::string16_char_traits, std::allocator<unsigned short> > &, bool)) 0x7f1fb5cc54a2 <content::RenderFrameHostImpl::OnDidFailLoadWithError(GURL const&, int, std::__cxx11::basic_string<unsigned short, base::string16_char_traits, std::allocator<unsigned short> > const&, bool)>, args=std::tuple containing = {...}) at ../../../../../qtwebengine/src/3rdparty/chromium/base/tuple.h:144
#11 0x00007f1fb5cebf64 in base::DispatchToMethod<content::RenderFrameHostImpl*, void (content::RenderFrameHostImpl::*)(GURL const&, int, std::__cxx11::basic_string<unsigned short, base::string16_char_traits, std::allocator<unsigned short> > const&, bool), std::tuple<GURL, int, std::__cxx11::basic_string<unsigned short, base::string16_char_traits, std::allocator<unsigned short> >, bool> const&>(content::RenderFrameHostImpl* const&, void (content::RenderFrameHostImpl::*)(GURL const&, int, std::__cxx11::basic_string<unsigned short, base::string16_char_traits, std::allocator<unsigned short> > const&, bool), std::tuple<GURL, int, std::__cxx11::basic_string<unsigned short, base::string16_char_traits, std::allocator<unsigned short> >, bool> const&) (obj=@0x7ffc02496f88: 0x1a323a0, method=
    (void (content::RenderFrameHostImpl::*)(content::RenderFrameHostImpl * const, const GURL &, int, const std::__cxx11::basic_string<unsigned short, base::string16_char_traits, std::allocator<unsigned short> > &, bool)) 0x7f1fb5cc54a2 <content::RenderFrameHostImpl::OnDidFailLoadWithError(GURL const&, int, std::__cxx11::basic_string<unsigned short, base::string16_char_traits, std::allocator<unsigned short> > const&, bool)>, args=std::tuple containing = {...}) at ../../../../../qtwebengine/src/3rdparty/chromium/base/tuple.h:151
#12 0x00007f1fb5ce3366 in IPC::DispatchToMethod<content::RenderFrameHostImpl, void (content::RenderFrameHostImpl::*)(GURL const&, int, std::__cxx11::basic_string<unsigned short, base::string16_char_traits, std::allocator<unsigned short> > const&, bool), void, std::tuple<GURL, int, std::__cxx11::basic_string<unsigned short, base::string16_char_traits, std::allocator<unsigned short> >, bool> >(content::RenderFrameHostImpl*, void (content::RenderFrameHostImpl::*)(GURL const&, int, std::__cxx11::basic_string<unsigned short, base::string16_char_traits, std::allocator<unsigned short> > const&, bool), void*, std::tuple<GURL, int, std::__cxx11::basic_string<unsigned short, base::string16_char_traits, std::allocator<unsigned short> >, bool> const&) (obj=0x1a323a0, method=
    (void (content::RenderFrameHostImpl::*)(content::RenderFrameHostImpl * const, const GURL &, int, const std::__cxx11::basic_string<unsigned short, base::string16_char_traits, std::allocator<unsigned short> > &, bool)) 0x7f1fb5cc54a2 <content::RenderFrameHostImpl::OnDidFailLoadWithError(GURL const&, int, std::__cxx11::basic_string<unsigned short, base::string16_char_traits, std::allocator<unsigned short> > const&, bool)>, tuple=std::tuple containing = {...}) at ../../../../../qtwebengine/src/3rdparty/chromium/ipc/ipc_message_templates.h:26
#13 0x00007f1fb5cd6181 in IPC::MessageT<FrameHostMsg_DidFailLoadWithError_Meta, std::tuple<GURL, int, std::__cxx11::basic_string<unsigned short, base::string16_char_traits, std::allocator<unsigned short> >, bool>, void>::Dispatch<content::RenderFrameHostImpl, content::RenderFrameHostImpl, void, void (content::RenderFrameHostImpl::*)(GURL const&, int, std::__cxx11::basic_string<unsigned short, base::string16_char_traits, std::allocator<unsigned short> > const&, bool)>(IPC::Message const*, content::RenderFrameHostImpl*, content::RenderFrameHostImpl*, void*, void (content::RenderFrameHostImpl::*)(GURL const&, int, std::__cxx11::basic_string<unsigned short, base::string16_char_traits, std::allocator<unsigned short> > const&, bool)) (msg=0x7f1f600bf950, obj=0x1a323a0, sender=0x1a323a0, parameter=0x0, func=
    (void (content::RenderFrameHostImpl::*)(content::RenderFrameHostImpl * const, const GURL &, int, const std::__cxx11::basic_string<unsigned short, base::string16_char_traits, std::allocator<unsigned short> > &, bool)) 0x7f1fb5cc54a2 <content::RenderFrameHostImpl::OnDidFailLoadWithError(GURL const&, int, std::__cxx11::basic_string<unsigned short, base::string16_char_traits, std::allocator<unsigned short> > const&, bool)>) at ../../../../../qtwebengine/src/3rdparty/chromium/ipc/ipc_message_templates.h:121
#14 0x00007f1fb5cc1b89 in content::RenderFrameHostImpl::OnMessageReceived(IPC::Message const&) (this=0x1a323a0, msg=...)
    at ../../../../../qtwebengine/src/3rdparty/chromium/content/browser/frame_host/render_frame_host_impl.cc:697
#15 0x00007f1fb62c59fc in content::RenderProcessHostImpl::OnMessageReceived(IPC::Message const&) (this=0x1a90050, msg=...)
    at ../../../../../qtwebengine/src/3rdparty/chromium/content/browser/renderer_host/render_process_host_impl.cc:2015
#16 0x00007f1fb8ae9c9f in IPC::ChannelProxy::Context::OnDispatchMessage(IPC::Message const&) (this=0x1abc7b0, message=...)
    at ../../../../../qtwebengine/src/3rdparty/chromium/ipc/ipc_channel_proxy.cc:340
#17 0x00007f1fb8af1f2b in base::internal::FunctorTraits<void (IPC::ChannelProxy::Context::*)(IPC::Message const&), void>::Invoke<scoped_refptr<IPC::ChannelProxy::Context> const&, IPC::Message const&>(void (IPC::ChannelProxy::Context::*)(IPC::Message const&), scoped_refptr<IPC::ChannelProxy::Context> const&, IPC::Message const&) (method=
    (void (IPC::ChannelProxy::Context::*)(IPC::ChannelProxy::Context * const, const IPC::Message &)) 0x7f1fb8ae9bf6 <IPC::ChannelProxy::Context::OnDispatchMessage(IPC::Message const&)>, receiver_ptr=..., args#0=...) at ../../../../../qtwebengine/src/3rdparty/chromium/base/bind_internal.h:214
#18 0x00007f1fb8af101b in base::internal::InvokeHelper<false, void>::MakeItSo<void (IPC::ChannelProxy::Context::* const&)(IPC::Message const&), scoped_refptr<IPC::ChannelProxy::Context> const&, IPC::Message const&>(void (IPC::ChannelProxy::Context::* const&)(IPC::Message const&), scoped_refptr<IPC::ChannelProxy::Context> const&, IPC::Message const&) (functor=
    @0x7f1f600bf940: (void (IPC::ChannelProxy::Context::*)(IPC::ChannelProxy::Context * const, const IPC::Message &)) 0x7f1fb8ae9bf6 <IPC::ChannelProxy::Context::OnDispatchMessage(IPC::Message const&)>, args#0=..., args#1=...) at ../../../../../qtwebengine/src/3rdparty/chromium/base/bind_internal.h:285
#19 0x00007f1fb8aef184 in base::internal::Invoker<base::internal::BindState<void (IPC::ChannelProxy::Context::*)(IPC::Message const&), scoped_refptr<IPC::ChannelProxy::Context>, IPC::Message>, void ()>::RunImpl<void (IPC::ChannelProxy::Context::* const&)(IPC::Message const&), std::tuple<scoped_refptr<IPC::ChannelProxy::Context>, IPC::Message> const&, 0ul, 1ul>(void (IPC::ChannelProxy::Context::* const&)(IPC::Message const&), std::tuple<scoped_refptr<IPC::ChannelProxy::Context>, IPC::Message> const&, base::IndexSequence<0ul, 1ul>) (functor=
    @0x7f1f600bf940: (void (IPC::ChannelProxy::Context::*)(IPC::ChannelProxy::Context * const, const IPC::Message &)) 0x7f1fb8ae9bf6 <IPC::ChannelProxy::Context::OnDispatchMessage(IPC::Message const&)>, bound=std::tuple containing = {...}) at ../../../../../qtwebengine/src/3rdparty/chromium/base/bind_internal.h:361
#20 0x00007f1fb8aedadf in base::internal::Invoker<base::internal::BindState<void (IPC::ChannelProxy::Context::*)(IPC::Message const&), scoped_refptr<IPC::ChannelProxy::Context>, IPC::Message>, void ()>::Run(base::internal::BindStateBase*) (base=0x7f1f600bf920) at ../../../../../qtwebengine/src/3rdparty/chromium/base/bind_internal.h:339
#21 0x00007f1fb73dd06f in base::internal::RunMixin<base::Callback<void (), (base::internal::CopyMode)0, (base::internal::RepeatMode)0> >::Run() && (this=0x7ffc02497ab8)
    at ../../../../../qtwebengine/src/3rdparty/chromium/base/callback.h:47
#22 0x00007f1fb748404c in base::debug::TaskAnnotator::RunTask(char const*, base::PendingTask*) (this=0x1a5c070, queue_function=0x7f1fbe433ad8 "MessageLoop::PostTask", pending_task=0x7ffc02497aa0) at ../../../../../qtwebengine/src/3rdparty/chromium/base/debug/task_annotator.cc:52
#23 0x00007f1fb72dd402 in base::MessageLoop::RunTask(base::PendingTask*) (this=0x1a5be50, pending_task=0x7ffc02497aa0)
    at ../../../../../qtwebengine/src/3rdparty/chromium/base/message_loop/message_loop.cc:413
#24 0x00007f1fb72dd55f in base::MessageLoop::DeferOrRunPendingTask(base::PendingTask) (this=0x1a5be50, pending_task=...)
    at ../../../../../qtwebengine/src/3rdparty/chromium/base/message_loop/message_loop.cc:422
#25 0x00007f1fb72dda39 in base::MessageLoop::DoWork() (this=0x1a5be50) at ../../../../../qtwebengine/src/3rdparty/chromium/base/message_loop/message_loop.cc:515
#26 0x00007f1fb5124f90 in QtWebEngineCore::(anonymous namespace)::MessagePumpForUIQt::handleScheduledWork (this=0x1adab30)
    at /data/Qt/qt5/qtwebengine/src/core/content_browser_client_qt.cpp:217
#27 0x00007f1fb5124f90 in QtWebEngineCore::(anonymous namespace)::MessagePumpForUIQt::customEvent(QEvent*) (this=0x1adab30, ev=<optimized out>)
    at /data/Qt/qt5/qtwebengine/src/core/content_browser_client_qt.cpp:199
#28 0x00007f1fd471f0d3 in QObject::event(QEvent*) (this=0x1adab30, e=<optimized out>) at /data/Qt/qt5/qtbase/src/corelib/kernel/qobject.cpp:1268
#29 0x00007f1fc41abf91 in QApplicationPrivate::notify_helper(QObject*, QEvent*) (this=this@entry=0x13869e0, receiver=receiver@entry=0x1adab30, e=e@entry=0x7f1f6026d990)
    at /data/Qt/qt5/qtbase/src/widgets/kernel/qapplication.cpp:3722
#30 0x00007f1fc41b3342 in QApplication::notify(QObject*, QEvent*) (this=0x7ffc02498950, receiver=0x1adab30, e=0x7f1f6026d990)
    at /data/Qt/qt5/qtbase/src/widgets/kernel/qapplication.cpp:3094
#31 0x00007f1fd46ef61c in QCoreApplication::notifyInternal2(QObject*, QEvent*) (receiver=receiver@entry=0x1adab30, event=event@entry=0x7f1f6026d990)
    at /data/Qt/qt5/qtbase/src/corelib/kernel/qcoreapplication.cpp:1016
#32 0x00007f1fd46f4de5 in QCoreApplication::sendEvent(QObject*, QEvent*) (event=0x7f1f6026d990, receiver=0x1adab30)
    at ../../include/QtCore/../../../../qtbase/src/corelib/kernel/qcoreapplication.h:233
#33 0x00007f1fd46f4de5 in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) (receiver=receiver@entry=0x0, event_type=event_type@entry=0, data=0x134e460)
    at /data/Qt/qt5/qtbase/src/corelib/kernel/qcoreapplication.cpp:1676
#34 0x00007f1fd46f543a in QCoreApplication::sendPostedEvents(QObject*, int) (receiver=receiver@entry=0x0, event_type=event_type@entry=0)
    at /data/Qt/qt5/qtbase/src/corelib/kernel/qcoreapplication.cpp:1530
#35 0x00007f1fd47472ec in postEventSourceDispatch(GSource*, GSourceFunc, gpointer) (s=0x13ddfe0) at /data/Qt/qt5/qtbase/src/corelib/kernel/qeventdispatcher_glib.cpp:276
#36 0x00007f1fcfeafbb7 in g_main_dispatch (context=0x7f1fa8004ff0) at gmain.c:3148
#37 0x00007f1fcfeafbb7 in g_main_context_dispatch (context=context@entry=0x7f1fa8004ff0) at gmain.c:3813
#38 0x00007f1fcfeaff60 in g_main_context_iterate (context=context@entry=0x7f1fa8004ff0, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at gmain.c:3886
#39 0x00007f1fcfeaffec in g_main_context_iteration (context=0x7f1fa8004ff0, may_block=may_block@entry=1) at gmain.c:3947
#40 0x00007f1fd4746d02 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) (this=0x13dea60, flags=...)
    at /data/Qt/qt5/qtbase/src/corelib/kernel/qeventdispatcher_glib.cpp:423
#41 0x00007f1fae87cba8 in QPAEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) (this=<optimized out>, flags=...)
    at /data/Qt/qt5/qtbase/src/platformsupport/eventdispatchers/qeventdispatcher_glib.cpp:122
#42 0x00007f1fd46ed523 in QEventLoop::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) (this=this@entry=0x7ffc02498160, flags=..., flags@entry=...)
    at /data/Qt/qt5/qtbase/src/corelib/kernel/qeventloop.cpp:134
#43 0x00007f1fd46ed938 in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) (this=0x7ffc02498160, flags=...) at /data/Qt/qt5/qtbase/src/corelib/kernel/qeventloop.cpp:212
#44 0x00007f1fc59cc4bb in KeychainAccountManager::refreshAccount(QSharedPointer<KGAPI2::Account> const&) (this=0x1782d00, account=...)
    at /data/KDE/src/extragear/network/kio-gdrive/src/keychainaccountmanager.cpp:120
#45 0x00007f1fc59b92b5 in KIOGDrive::handleError(KGAPI2::Job const&, QUrl const&) (this=0x7ffc02498910, job=..., url=<error reading variable: Cannot access memory at address 0x40>)
    at /data/KDE/src/extragear/network/kio-gdrive/src/kio_gdrive.cpp:112
#46 0x00007f1fc59bd9bc in KIOGDrive::runJob(KGAPI2::Job&, QUrl const&, QString const&) (this=0x7ffc02498910, job=..., url=<error reading variable: Cannot access memory at address 0x40>, accountId="dan.vratil@gmail.com") at /data/KDE/src/extragear/network/kio-gdrive/src/kio_gdrive.cpp:673
#47 0x00007f1fc59bb307 in KIOGDrive::rootFolderId(QString const&) (this=0x7ffc02498910, accountId="dan.vratil@gmail.com")
    at /data/KDE/src/extragear/network/kio-gdrive/src/kio_gdrive.cpp:394
#48 0x00007f1fc59bb748 in KIOGDrive::listDir(QUrl const&) (this=0x7ffc02498910, url=Python Exception <class 'gdb.error'> cannot resolve overloaded method `data': no arguments supplied: 
) at /data/KDE/src/extragear/network/kio-gdrive/src/kio_gdrive.cpp:427
#49 0x00007f1fd51fceca in KIO::SlaveBase::dispatch(int, QByteArray const&) (this=0x7ffc02498910, command=71, data="" = {...})
    at /data/KDE/src/frameworks/kio/src/core/slavebase.cpp:1177
#50 0x00007f1fd51f8f9d in KIO::SlaveBase::dispatchLoop() (this=0x7ffc02498910) at /data/KDE/src/frameworks/kio/src/core/slavebase.cpp:301
#51 0x00007f1fc59b8e53 in kdemain(int, char**) (argc=4, argv=0x7ffc02498b70) at /data/KDE/src/extragear/network/kio-gdrive/src/kio_gdrive.cpp:77
#52 0x000000000040158a in main(int, char**) (argc=5, argv=0x7ffc02498b68) at /data/KDE/src/frameworks/kio/src/kioslave/kioslave.cpp:130
Detaching from program: /data/install/kde/lib64/libexec/kf5/kioslave, process 14467
davidk updated this revision to Diff 25669.Jan 20 2018, 6:37 AM

Unfortunately i can't reproduce the crash (with QT 5.10.0).

But it may be related to the redirection to localhost, because i don't return a valid http response to the webview.
Instead, i close the connection after recieving the request. I added a line to cancel the page load, after recieving
the request on the socket. I hope this fixes the problem.

I wonder why the change breaks kio-gdrive but not the other applications i tried. Maybe it's related to the nested QEventLoop?

Anyways, would you mind trying it again?

dvratil accepted this revision.Jan 25 2018, 1:33 PM

Sorry for the delay. Looks good now. Thanks a lot!

Could you please commit without the tr() just (QStringLiterals) to Applications/17.12 branch, then merge to master and add the tr()s in separate commit on master?

This revision was not accepted when it landed; it landed in state Needs Review.Jan 28 2018, 9:27 AM
This revision was automatically updated to reflect the committed changes.