-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixing crashes, code cleaning, and features! #34
base: master
Are you sure you want to change the base?
Fixing crashes, code cleaning, and features! #34
Conversation
Quite a few things: - Code formatting - More checks for failing functions and NULL - We look for B_SIMPLE_DATA (it's the same format as B_REFS_RECEIVED) - Added automatic size limits to the MainWindow - Removed unused "Buffering.h" and unused function "MainWindow::SetVisible" Should fix HaikuArchives#33, HaikuArchives#32, HaikuArchives#29
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, commented just for an explanation...
Also, in the future you may want to put all code style changes in its own commit (within the one PR). Makes sorting out the functional changes easier.
Station* existingStation | ||
= fSettings->Stations->FindItem(station->Name()); | ||
if (existingStation) { | ||
if (existingStation != NULL) { | ||
delete station; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just for my education:
- why is object 'station' destroyed via "delete" when it wasn't created with "new"?
- how can the object 'station' that was 'deleted' in the previous line get a new value assigned?
I ask genuinely. I really am a crappy 'coder'...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I must admit, I need to work on separating my style changes. :)
And hey, no worries! I'm happy to explain:
While it may look like the station
variable isn't allocated with "new", you'll want to look above at this line:
Station* station = Station::Load(ref.name, new BEntry(&ref));
We'll want to look in the Station.cpp file and find the function that's being called above:
Line 438 in c654e0c
Station::Load(BString name, BEntry* entry) |
We can see that in this function, a Station object is allocated with "new":
Line 443 in c654e0c
Station* station = new Station(name); |
Eventually, if all goes well in the Load()
function, we are returned the fresh "Station" object that was created by "new":
Line 551 in c654e0c
return station; |
As a result, the station
variable is assigned to the Station object that was created with "new".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As for the immediate reassignment, you'll want to check out this video about pointers:
https://youtu.be/DTxHyVn0ODg
He also makes a bunch of other great videos on C++ too:
https://www.youtube.com/playlist?list=PLlrATfBNZ98dudnM48yfGUldqGD0S4FFb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the explanations!
I didn't find anything on "immediate reassignment" in that video. I sat through the 15 minutes of it though and would advise the guy to keep away from the coffee while recording. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No problem! On the other hand, you get a lot of info and in a short amount of time! ;)
Hold up...one quick problem that I introduced that needs to be fixed... |
@CodeforEvolution, ready to be merged? Or, what's the quick problem? |
humdinger, I've been using this brach for a few days now. Not a single crash. Maybe just a couple of tweaks to the GUI are all that's needed now. |
Unfortunately this is still not mergeable, even though the program isn’t crashing, without that “delete”, StreamRadio will start leaking network threads and audio resources when switching between stations. I just don’t have the time to look into this further...though I think it might be BLocker related? |
Can you link to the specific location(s) in the code that's the issue? Not that I can fix it, most probably, but maybe someone else can... :) Are the leaks that severe that it impacts usage so significantly, that we shouldn't release these PRs improvements? |
/~https://github.com/CodeforEvolution/StreamRadio/blob/029dbd4c1212533b39cbe73c42f79db5507bc448/MainWindow.cpp#L321 |
Playing around with Cppcheck, so decided to run it on MainWindow.cpp. Result below. Hope it helps. ~/HaikuArchives/StreamRadio-crashEtClean> cppcheck --enable=all MainWindow.cpp |
Sorry about not quoting and stuff. I might have discovered what's happening here (but then again, I don't know jack about C++ so...). On the StreamPlayer class destructor, I've just commented the first line, which posts the MSG_PLAYER_STATE_CHANGED message (Stopped). If you take a look at MainWindow.cpp, when the window receives a message like that triggers the delete routine again, which in turn calls the destructor, which will try to post the message again, thus causing a loop or double-delete This change (plus the others) is already on PR. Can someone give it a try and confirm if it's working (and correct me if I'm wrong about what I think it's happening)? |
Just to clarify, the PR you ask to try is #39, right? (Pulkomandy and I alredy commented there.) |
I think I got carried away... :)