Fix crash in ProtoQueue
We had
QMap<int, HostQueue *> m_queuesBySerial;
QHash<QString, HostQueue> m_queuesByHostname;
with the pointer of the first being to the addresses in the second
That is wrong because QHash will copy/move its objects on insert so the pointer would point to an already deleted memory position
To fix it we change the QHash to an unordered_map with a unique_ptr
This way we keep the automatic memory management in m_queuesByHostname but we don't have to worry about the pointers in m_queuesBySerial to become invalid
valgrind trace
==127904== Invalid read of size 8
==127904== at 0x603C6FA: QtPrivate::QExplicitlySharedDataPointerV2<QMapData<std::map<int, KIO::SimpleJob*, std::less<int>, std::allocator<std::pair<int const, KIO::SimpleJob*> > > > >::operator bool() const (qshareddata_impl.h:117)
==127904== by 0x603D6EC: QMap<int, KIO::SimpleJob*>::begin() const (qmap.h:600)
==127904== by 0x603AFA7: QMap<int, KIO::SimpleJob*>::constBegin() const (qmap.h:601)
==127904== by 0x6036464: KIO::HostQueue::lowestSerial() const (scheduler.cpp:213)
==127904== by 0x6037589: KIO::ProtoQueue::startAJob() (scheduler.cpp:477)
==127904== by 0x604C30E: QtPrivate::FunctorCall<QtPrivate::IndexesList<>, QtPrivate::List<>, void, void (KIO::ProtoQueue::*)()>::call(void (KIO::ProtoQueue::*)(), KIO::ProtoQueue*, void**)::{lambda()#1}::operator()() const (qobjectdefs_impl.h:152)
==127904== by 0x604E088: void QtPrivate::FunctorCallBase::call_internal<void, QtPrivate::FunctorCall<QtPrivate::IndexesList<>, QtPrivate::List<>, void, void (KIO::ProtoQueue::*)()>::call(void (KIO::ProtoQueue::*)(), KIO::ProtoQueue*, void**)::{lambda()#1}>(void**, QtPrivate::FunctorCall<QtPrivate::IndexesList<>, QtPrivate::List<>, void, void (KIO::ProtoQueue::*)()>::call(void (KIO::ProtoQueue::*)(), KIO::ProtoQueue*, void**)::{lambda()#1}&&) (qobjectdefs_impl.h:65)
==127904== by 0x604C380: QtPrivate::FunctorCall<QtPrivate::IndexesList<>, QtPrivate::List<>, void, void (KIO::ProtoQueue::*)()>::call(void (KIO::ProtoQueue::*)(), KIO::ProtoQueue*, void**) (qobjectdefs_impl.h:151)
==127904== by 0x604946D: void QtPrivate::FunctionPointer<void (KIO::ProtoQueue::*)()>::call<QtPrivate::List<>, void>(void (KIO::ProtoQueue::*)(), KIO::ProtoQueue*, void**) (qobjectdefs_impl.h:199)
==127904== by 0x60458A0: QtPrivate::QCallableObject<void (KIO::ProtoQueue::*)(), QtPrivate::List<>, void>::impl(int, QtPrivate::QSlotObjectBase*, QObject*, void**, bool*) (qobjectdefs_impl.h:570)
==127904== by 0x7E89B28: UnknownInlinedFun (qobjectdefs_impl.h:486)
==127904== by 0x7E89B28: void doActivate<false>(QObject*, int, void**) (qobject.cpp:4124)
==127904== by 0x7E92B34: UnknownInlinedFun (moc_qtimer.cpp:223)
==127904== by 0x7E92B34: UnknownInlinedFun (qtimer.cpp:285)
==127904== by 0x7E92B34: QTimer::timerEvent(QTimerEvent*) (qtimer.cpp:279)
==127904== Address 0x20fe6f48 is 24 bytes inside a block of size 1,920 free'd
==127904== at 0x484A264: operator delete[](void*) (vg_replace_malloc.c:1410)
==127904== by 0x604A6AF: QHashPrivate::Span<QHashPrivate::Node<QString, KIO::HostQueue> >::addStorage() (qhash.h:410)
==127904== by 0x60496A6: QHashPrivate::Span<QHashPrivate::Node<QString, KIO::HostQueue> >::insert(unsigned long) (qhash.h:284)
==127904== by 0x6045DCB: QHashPrivate::Data<QHashPrivate::Node<QString, KIO::HostQueue> >::Bucket::insert() const (qhash.h:512)
==127904== by 0x6041D68: QHashPrivate::Data<QHashPrivate::Node<QString, KIO::HostQueue> >::InsertionResult QHashPrivate::Data<QHashPrivate::Node<QString, KIO::HostQueue> >::findOrInsert<QString>(QString const&) (qhash.h:731)
==127904== by 0x603E8EA: KIO::HostQueue& QHash<QString, KIO::HostQueue>::operatorIndexImpl<QString>(QString const&) (qhash.h:1090)
==127904== by 0x603BBAE: QHash<QString, KIO::HostQueue>::operator[](QString const&) (qhash.h:1083)
==127904== by 0x6036C08: KIO::ProtoQueue::queueJob(KIO::SimpleJob*) (scheduler.cpp:331)
==127904== by 0x6037FFA: KIO::SchedulerPrivate::doJob(KIO::SimpleJob*) (scheduler.cpp:647)
==127904== by 0x6037B1C: KIO::Scheduler::doJob(KIO::SimpleJob*) (scheduler.cpp:558)
==127904== by 0x601FC0B: KIO::SimpleJobPrivate::simpleJobInit() (simplejob.cpp:37)
==127904== by 0x601F9D6: KIO::SimpleJob::SimpleJob(KIO::SimpleJobPrivate&) (simplejob.cpp:23)
==127904== Block was alloc'd at
==127904== at 0x4846613: operator new[](unsigned long) (vg_replace_malloc.c:729)
==127904== by 0x604A56F: QHashPrivate::Span<QHashPrivate::Node<QString, KIO::HostQueue> >::addStorage() (qhash.h:395)
==127904== by 0x60496A6: QHashPrivate::Span<QHashPrivate::Node<QString, KIO::HostQueue> >::insert(unsigned long) (qhash.h:284)
==127904== by 0x6045DCB: QHashPrivate::Data<QHashPrivate::Node<QString, KIO::HostQueue> >::Bucket::insert() const (qhash.h:512)
==127904== by 0x6041D68: QHashPrivate::Data<QHashPrivate::Node<QString, KIO::HostQueue> >::InsertionResult QHashPrivate::Data<QHashPrivate::Node<QString, KIO::HostQueue> >::findOrInsert<QString>(QString const&) (qhash.h:731)
==127904== by 0x603E8EA: KIO::HostQueue& QHash<QString, KIO::HostQueue>::operatorIndexImpl<QString>(QString const&) (qhash.h:1090)
==127904== by 0x603BBAE: QHash<QString, KIO::HostQueue>::operator[](QString const&) (qhash.h:1083)
==127904== by 0x6036C08: KIO::ProtoQueue::queueJob(KIO::SimpleJob*) (scheduler.cpp:331)
==127904== by 0x6037FFA: KIO::SchedulerPrivate::doJob(KIO::SimpleJob*) (scheduler.cpp:647)
==127904== by 0x6037B1C: KIO::Scheduler::doJob(KIO::SimpleJob*) (scheduler.cpp:558)
==127904== by 0x601FC0B: KIO::SimpleJobPrivate::simpleJobInit() (simplejob.cpp:37)
==127904== by 0x601F9D6: KIO::SimpleJob::SimpleJob(KIO::SimpleJobPrivate&) (simplejob.cpp:23)