Remove "default_host" profile#2950
Conversation
|
Hey there! Thanks for helping Mudlet improve. 🌟 Test versionsYou can directly test the changes here:
No need to install anything - just unzip and run. |
src/dlgProfilePreferences.cpp
Outdated
| // count will be 2 in the case we particularly want to handle (adding the | ||
| // first real Host instance): | ||
| if (!mpHost && pHost && count < 3) { | ||
| if (!mpHost && pHost && count < 1) { |
There was a problem hiding this comment.
There were <3 before, you remove default_host, now it should be <2, right?
| QMutexLocker locker(& mLock); | ||
| bool isChanged = false; | ||
| QMutexLocker locker(&mLock); | ||
| bool dictionaryChanged {}; |
There was a problem hiding this comment.
Never seen this syntax before
There was a problem hiding this comment.
We've used it in a few places in Mudlet now. It creates dictionaryChanged and sets it to a default value you'd expect. If you just do bool dictionaryChanged; the value could be random because one wasn't given (it basically doesn't do anything at all to set one).
Technical term is "braced intializer", unfortunately all resources I could find from a quick search weren't an easy read.
There was a problem hiding this comment.
It uses the default constructor IIRC - in the same manner as it would be for a member in a class's constructor's initialization list, e.g. if dictionaryChanged was a member then this would do the same as:
, dictionaryChanged()
would do in the initialization list.
Arguments can also be provided for the constructor of more complex items - and even bools can be initialized to the non-default value true with:
bool dictionaryChanged {true};
![]()
|
@wiploo are you able to test if this breaks anything? It is a pretty fundamental change. |
src/mudlet.cpp
Outdated
|
|
||
| bool mudlet::addHost(const QString& hostname, const QString& port, const QString& login, const QString& pass) | ||
| { | ||
| auto success = mHostManager.addHost(hostname, port, login, pass); |
There was a problem hiding this comment.
We now have HostManager::addHost() and mudlet::addHost() and the intention is that it's only the latter that should be called, because it wraps some necessary initialisation (the central debug area) around the method once we have our first host.
I'm not sure how to properly describe it using C++ semantics.
There was a problem hiding this comment.
Make only the latter callable?
There was a problem hiding this comment.
The mudlet class is overriding the addHost method of the HostManager class maybe? 🤓
There was a problem hiding this comment.
In retrospect, this design was bad. Fixed it to a more logical one - you call HostManager.addHost as you did before now.
Not everyone has/uses/can use (Chinese users?) Discord. |
|
That is true, and they have their own QQ group, so IRC is not relevant to them. |
src/mudlet.cpp
Outdated
| ||(mMenuBarVisibility & visibleMaskNormally)) { | ||
|
|
||
| // Are there any profiles loaded? | ||
| if ((mHostManager.getHostCount() < 1 && mMenuBarVisibility & visibleAlways) |
src/mudlet.cpp
Outdated
| // as the first one | ||
| if ((mHostManager.getHostCount() < 2 && mToolbarVisibility & visibleAlways) || (mToolbarVisibility & visibleMaskNormally)) { | ||
| // Are there any profiles loaded? | ||
| if ((mHostManager.getHostCount() < 1 && mToolbarVisibility & visibleAlways) |
src/mudlet.cpp
Outdated
|
|
||
| if (success && !mpDebugArea) { | ||
| mpDebugArea = new QMainWindow(nullptr); | ||
| mpDefaultHost = mHostManager.getHost(hostname); |
There was a problem hiding this comment.
There was a problem hiding this comment.
Eh, yes, you raise a valid point. I'll have it migrate to the next available profile (if any) then.
There was a problem hiding this comment.
Hm, tough. We could just also close the debug area and re-open it with the next available host, but then the user experience is not so nice: everything that was in the debug area will get lost. On the other hand, implementing host migration for an existing TConsole is a fair bit of work just for this one usecase.
There was a problem hiding this comment.
Does it have to be a Host pointer - or is it only for the QObject::parent property so that if the parent is destroyed it causes all the QObject derived children of that parent to commit suicide? If that is the case then perhaps the CDC can be given the mudlet singleton as a parent - then things ought to be fine.
I haven't got the code open in front of me right now (😮) but I will take a look over the weekend if I can make sense of this...
On the other hand, implementing host migration for an existing TConsole is a fair bit of work just for this one usecase.
That one TConsole instance is an important use case - and we (I certainly) have suggested to users to have the debug console opened from a dummy profile before the one with a start-up problem is initiated - so that early debug output can be observed in the latter - so it is important that the CDC is shared equally between all open profiles. {Fair enough there is also a long-standing need for a means to show which profile produces which lines in the CDC!}
There was a problem hiding this comment.
It does need a valid Host, yeah.
| @@ -3685,7 +3690,7 @@ void mudlet::doAutoLogin(const QString& profile_name) | |||
|
|
|||
| // load an old profile if there is any | |||
| // PLACEMARKER: Host creation (2) - autoload case | |||
There was a problem hiding this comment.
Please revise the number down now that // PLACEMARKER: Host creation (1) ... has gone away.
There was a problem hiding this comment.
I still don't see the point of these placemakers. Revised, though.
There was a problem hiding this comment.
They were/are marking all the places where a profile/Host can be created (and there are some for destruction) - which is useful to check that all of them are passed through/tested in some situations (as we have had cases where one execution path showed a bug that another one didn't) and putting breakpoints on them is one technique I have used to debug things in those cases.
There was a problem hiding this comment.
Modern IDEs have a "find all usages of this function" feature which does the same, but better: it never forgets to update comments 😁
There was a problem hiding this comment.
Yes but, doing these things requires manual work to keep it up to date - which can be wrong! So it has a low reliability score - thus I'd ignore it and only trust the source...
src/dlgConnectionProfiles.cpp
Outdated
| @@ -2028,7 +2021,7 @@ void dlgConnectionProfiles::loadProfile(bool alsoConnect) | |||
| } | |||
| // load an old profile if there is any | |||
| // PLACEMARKER: Host creation (3) - normal case | |||
There was a problem hiding this comment.
Please revise the number down now that // PLACEMARKER: Host creation (1) ... has gone away.
src/mudlet.cpp
Outdated
|
|
||
| // For the first real host created the getHostCount() will return 2 because | ||
| // there is already a "default_host" | ||
| signal_hostCreated(pHost, mHostManager.getHostCount()); |
There was a problem hiding this comment.
If you haven't already done so, may I suggest checking any slots connected to this signal to ensure that they respond correctly given that the number passed will be one less now...?
There was a problem hiding this comment.
Yes, the only place it is used in is the settings window, and that works OK.
Also, this is a strange way to emit a signal...
There was a problem hiding this comment.
🤔 Humm, yeah - where has the emit gone?
There was a problem hiding this comment.
It was like that from the beginning 92f61bb#diff-84e2883dc57a4e7b034fbac3fd4668b5R2633 - I'll fix it.
src/mudlet.cpp
Outdated
|
|
||
| bool mudlet::addHost(const QString& hostname, const QString& port, const QString& login, const QString& pass) | ||
| { | ||
| auto success = mHostManager.addHost(hostname, port, login, pass); |
There was a problem hiding this comment.
The mudlet class is overriding the addHost method of the HostManager class maybe? 🤓
|
Ready for review. |
| mpMainToolBar->actions()[14]->setEnabled(false); | ||
|
|
||
| mpActionReplay->setEnabled(false); | ||
| mpActionIRC->setEnabled(false); |
There was a problem hiding this comment.
Is this the best place for this line of code - IMHO it would be better placed before or after the pair of lines it is sat between which both act on mpActionReplay rather than splitting them...?
demonnic
left a comment
There was a problem hiding this comment.
launches, deleted default_host, still launches, test profile isn't erroring. Does load faster.
It seems, *I think* that the removal of the "default host" profile (in Mudlet#2950) broke the logic that detected that any "real" profiles were loaded and prevented both the main menu bar and the main toolbar from being hidden when no such profiles were active. As it is now it is not possible to hide both the main menu and the main toolbar AFTER a profile is loaded - even though we provide the settings that are suppose to allow that. The original `enum` used to encode the wanted settings for the visibility of those two items used a cunning combination of bit patterns (and some application of DeMorgan's laws) to work out what the visibility settings are and what state the application is in (number of profiles active) so as to show or hide the main menu and main toolbars. Unfortunately I've lost track of how I put it together when the single "default host" profile was included in the count so had to rewrite the logic tests without changing the `enum` values. Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
It seems, *I think* that the removal of the "default host" profile (in #2950) broke the logic that detected that any "real" profiles were loaded and prevented both the main menu bar and the main toolbar from being hidden when no such profiles were active. As it is now it is not possible to hide both the main menu and the main toolbar AFTER a profile is loaded - even though we provide the settings that are suppose to allow that. The original `enum` used to encode the wanted settings for the visibility of those two items used a cunning combination of bit patterns (and some application of DeMorgan's laws) to work out what the visibility settings are and what state the application is in (number of profiles active) so as to show or hide the main menu and main toolbars. Unfortunately I've lost track of how I put it together when the single "default host" profile was included in the count so had to rewrite the logic tests without changing the `enum` values. Signed-off-by: Stephen Lyons <slysven@virginmedia.com>


Brief overview of PR changes/additions
Remove "default_host" profile.
Motivation for adding to Mudlet
200ms faster startup because of no extra host getting made + 10ms saved from creating the debug area only when you need it, less messy code workarounds to ignore the "default_host" and no messages like this in stdout which don't mean anything:
Other info (issues closed, discussion etc)
Opening IRC is now not possible until at least one profile open - but I don't think anyone seriously uses Mudlet as an IRC-only client. We previously kept this functionality was the only way to get help, but with Discord, this isn't needed.
Closes #1352, closes #1351, closes #736.