Skip to content

Commit

Permalink
Fixes issue of recreation of stations directory and alert popping up …
Browse files Browse the repository at this point in the history
…when running searches with large number of stations returned.

Task #1 - Various problems with different stations from Vidrep
  • Loading branch information
Fishpond committed Apr 29, 2017
1 parent f2a407d commit 4e9aea2
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
19 changes: 11 additions & 8 deletions Station.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,7 @@ status_t Station::InitCheck() {

Station* Station::LoadFromPlsFile(BString Name) {
BEntry stationEntry;
BDirectory* stationDir = StationDirectory();
stationEntry.SetTo(stationDir, Name);
delete stationDir;
stationEntry.SetTo(StationDirectory(), Name);
Station* station = Load(Name, &stationEntry);
if (station) station->unsaved = false;
return station;
Expand Down Expand Up @@ -514,25 +512,30 @@ void Station::checkFlags() {
fFlags |= STATION_HAS_META;
}

BDirectory* Station::fStationsDirectory = NULL;

BDirectory* Station::StationDirectory() {
if (fStationsDirectory)
return fStationsDirectory;

status_t status;
BPath configPath;
BDirectory configDir;
BDirectory* stationDir;

status = find_directory(B_USER_SETTINGS_DIRECTORY, &configPath);
configDir.SetTo(configPath.Path());
if (configDir.Contains(SubDirStations, B_DIRECTORY_NODE)) {
stationDir = new BDirectory(&configDir, SubDirStations);
fStationsDirectory = new BDirectory(&configDir, SubDirStations);
} else {
stationDir = new BDirectory();
configDir.CreateDirectory(SubDirStations, stationDir);
fStationsDirectory = new BDirectory();
configDir.CreateDirectory(SubDirStations, fStationsDirectory);
BAlert* alert = new BAlert("Stations directory created",
"A directory for saving stations has been created in your "
"settings folder. Link this directory to your deskbar menu "
"to play stations directly.",
"Ok");
alert->Go();
}
return stationDir;

return fStationsDirectory;
}
1 change: 1 addition & 0 deletions Station.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ class Station {
uint32 fEncoding;
uint32 fMetaInterval;
uint32 fFlags;
static BDirectory* fStationsDirectory;
};
#endif /* STATION_H */

6 changes: 5 additions & 1 deletion StationFinder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ bool StationFinderWindow::QuitRequested() {
void StationFinderWindow::MessageReceived(BMessage* msg) {
switch (msg->what) {
case MSG_BNSEARCH : {
if (txSearch->LayoutContext()) {
if (txSearch->IsEnabled()) {
if (txSearch->Text()[0]) {
DoSearch(txSearch->Text());
resultView->MakeFocus(true);
Expand Down Expand Up @@ -331,10 +331,14 @@ void StationFinderWindow::SelectCapability(int index) {

searchGrid->RemoveView(txSearch);
searchGrid->AddView(kwSearch, 1, 2);
kwSearch->SetEnabled(true);
txSearch->SetEnabled(false);
Layout(true);
} else {
searchGrid->RemoveView(kwSearch);
searchGrid->AddView(txSearch, 1, 2);
kwSearch->SetEnabled(false);
txSearch->SetEnabled(true);
Layout(true);
}
}
Expand Down
4 changes: 1 addition & 3 deletions nbproject/private/configurations.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
</df>
<df name="graphics">
</df>
<df name="objects.x86-cc2-release">
</df>
<df name="objects.x86-cc5-release">
<df name="objects.x86-cc2-debug">
</df>
<in>About.cpp</in>
<in>About.h</in>
Expand Down

0 comments on commit 4e9aea2

Please sign in to comment.