Open all URLs in command line arguments
Needs ReviewPublic

Authored by abogical on Feb 25 2020, 4:13 PM.

Details

Reviewers
drosca
Group Reviewers
Falkon
Summary

BUG: 413195

Test Plan

Run the falkon command with multiple URLs, e.g:
./falkon example.com kde.org

Expected:
A new falkon window with each URL opened in a new tab. First URL selected.

Diff Detail

Repository
R875 Falkon
Branch
cmd-urls
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 24377
Build 24395: arc lint + arc unit
abogical created this revision.Feb 25 2020, 4:13 PM
Restricted Application added a project: Falkon. · View Herald TranscriptFeb 25 2020, 4:13 PM
Restricted Application added a subscriber: falkon. · View Herald Transcript
abogical requested review of this revision.Feb 25 2020, 4:13 PM
abogical added a comment.EditedFeb 25 2020, 4:34 PM

In case you're wondering, Yes, I'm interested in becoming a GSoC student. I've contributed to different KDE projects including this year's SoK. However, this is my first patch to Falkon. Once this is done, you can recommend another bug to fix if you prefer.

Also, full name is 'Abdel-Rahman Abdel-Rahman'. I'll try to contact the sysadmin to change my name on Phabricator since I can't change it myself. :/

Thanks!

abogical edited the test plan for this revision. (Show Details)Feb 25 2020, 5:39 PM
drosca requested changes to this revision.Mar 6 2020, 7:31 AM
drosca added inline comments.
src/lib/app/browserwindow.cpp
255

Just use takeLast() from m_startUrls instead of using iterator.

320

coding style

src/lib/app/browserwindow.h
80

No need for move semantics here.

src/lib/app/commandlineoptions.cpp
201–214
const QStringList args = parser.positionalArguments();
for (QString url : args) {
   ...
}
src/lib/app/mainapplication.cpp
442–447

const QUrl &startUrl

446

two empty lines

This revision now requires changes to proceed.Mar 6 2020, 7:31 AM
abogical updated this revision to Diff 77082.Mar 6 2020, 10:52 AM

Requested changes done.

abogical added inline comments.Mar 6 2020, 10:56 AM
src/lib/app/browserwindow.cpp
255

We can't use use takeLast on a const QList. cend() is meant to be used as a default when no URLs are given.

drosca added inline comments.Mar 6 2020, 12:33 PM
src/lib/app/browserwindow.cpp
255

That's why you should declare it non-const and clear the list in postLaunch as you process the urls. m_startUrls is no longer used after startup.

abogical marked 4 inline comments as done.Mar 6 2020, 12:48 PM
abogical updated this revision to Diff 77104.Mar 6 2020, 1:02 PM

Popping from QUrl list instead of using an iterator, as requested.

abogical marked 3 inline comments as done.Mar 6 2020, 1:02 PM
abogical marked an inline comment as done.Mar 6 2020, 1:23 PM
drosca added inline comments.Mar 6 2020, 5:18 PM
src/lib/app/mainapplication.cpp
344

BrowserWindow *window

447

Same here, no move semantics.

453

BrowserWindow *window

abogical updated this revision to Diff 77124.Mar 6 2020, 5:31 PM

Done requested changes.

abogical updated this revision to Diff 77125.Mar 6 2020, 5:34 PM
abogical marked 2 inline comments as done.

Stylistic fix

abogical marked an inline comment as done.Mar 6 2020, 5:35 PM
dfaure added a subscriber: dfaure.Mar 22 2020, 1:31 PM
dfaure added inline comments.
src/lib/app/browserwindow.cpp
320

range-for would be faster than modifying m_startUrls at each iteration.

If you use range-for, remember to qAsConst(m_startUrls)

src/lib/app/commandlineoptions.cpp
202

const QString &url

abogical added inline comments.Mar 22 2020, 6:07 PM
src/lib/app/browserwindow.cpp
320
abogical updated this revision to Diff 78246.Mar 22 2020, 6:33 PM

Using QString reference as requested.

dfaure added inline comments.Mar 22 2020, 7:51 PM
src/lib/app/browserwindow.cpp
320

A single takeFirst()/takeLast() is ok, but a loop over takeFirst() or takeLast() is *really* suboptimal.

My suggestion was a single take, and then a C++11 range-for.

abogical updated this revision to Diff 78259.Mar 22 2020, 9:40 PM

Used range loop as requested.

abogical marked 4 inline comments as done.Mar 22 2020, 9:41 PM
drosca requested changes to this revision.Mar 25 2020, 6:20 AM
drosca added inline comments.
src/lib/app/browserwindow.cpp
320

qAsConst(m_startUrls)

src/lib/app/commandlineoptions.cpp
201–214

const QStringList args

src/lib/app/mainapplication.cpp
453

Again no move semantics.

This revision now requires changes to proceed.Mar 25 2020, 6:20 AM
abogical updated this revision to Diff 78449.Mar 25 2020, 1:23 PM

Use qAsConst

abogical marked an inline comment as done.Mar 25 2020, 1:27 PM
abogical added inline comments.
src/lib/app/commandlineoptions.cpp
201–214

I can't since I need to use QString &url as @dfaure wanted. Thus it can't be const.

src/lib/app/mainapplication.cpp
453

This will invoke a copy of the list, which is what I'm trying to avoid.

dfaure added inline comments.Mar 28 2020, 10:13 AM
src/lib/app/commandlineoptions.cpp
202

I hadn't realized that this code actually modified url (hence the const in my suggestion).

Modifying the args list is a bit of an unexpected side effect.

I think for (QString url : args) would indeed be better then, or the more traditional for (const QString &arg : args) { QString url = arg; ..... } so that it doesn't look like someone simply forgot a const &...

src/lib/app/mainapplication.cpp
453

Note that copying QList is just increasing/decreasing a refcount, this isn't a full copy like what would happen with std::list or std::vector.

The traditional Qt way is to pass a const & in those methods, and copy into a member variable at the end of the chain where you end up in a constructor. Cheap copy.

The possibly more modern way is indeed pass by value and std::move, but only for constructors; don't do this for setters.

This code is maintained by drosca though, so if he doesn't like std::move, use const & everywhere.

abogical updated this revision to Diff 78739.Mar 28 2020, 4:45 PM

Done requested change