Skip to content

Commit

Permalink
Provide a cleaner error message for windows.wt
Browse files Browse the repository at this point in the history
If Windows.wt is missing, surge can go horribly awry. We
issued no error message in this case. So do so now.

Closes surge-synthesizer#1247
  • Loading branch information
baconpaul committed Oct 15, 2019
1 parent 88755fe commit 687adea
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
27 changes: 23 additions & 4 deletions src/common/SurgeStorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,24 @@ SurgeStorage::SurgeStorage(std::string suppliedDataPath)

// WindowWT is a WaveTable which now has a constructor so don't do this
// memset(&WindowWT, 0, sizeof(WindowWT));
load_wt_wt(datapath + "windows.wt", &WindowWT);
if( ! load_wt_wt(datapath + "windows.wt", &WindowWT) )
{
std::ostringstream oss;
oss << "Unable to load '" << datapath << "/windows.wt'. This file is required for surge to operate "
<< "properly. This occurs when Surge is mis-installed and shared resources are not in the "
<< "os-specific shared directory, which on your OS is a directory called 'Surge' in "
#if MAC
<< "the global or user local `Library/Application Support` directory."
#endif
#if WINDOWS
<< "your %LocalAppData% directory."
#endif
#if LINUX
<< "/usr/share or ~/.local/share."
#endif
<< " Please install shared assets correctly and restart.";
Surge::UserInteractions::promptError(oss.str(), "Unable to load windows.wt");
}
}

SurgePatch& SurgeStorage::getPatch()
Expand Down Expand Up @@ -703,11 +720,11 @@ void SurgeStorage::load_wt(string filename, Wavetable* wt)
}
}

void SurgeStorage::load_wt_wt(string filename, Wavetable* wt)
bool SurgeStorage::load_wt_wt(string filename, Wavetable* wt)
{
FILE* f = fopen(filename.c_str(), "rb");
if (!f)
return;
return false;
wt_header wh;
memset(&wh, 0, sizeof(wt_header));

Expand All @@ -718,7 +735,7 @@ void SurgeStorage::load_wt_wt(string filename, Wavetable* wt)
{
// SOME sort of error reporting is appropriate
fclose(f);
return;
return false;
}

void* data;
Expand Down Expand Up @@ -747,8 +764,10 @@ void SurgeStorage::load_wt_wt(string filename, Wavetable* wt)
<< " https://github.com/surge-synthesizer/surge/";
Surge::UserInteractions::promptError( oss.str(),
"Software Error on WT Load" );
return false;
}
fclose(f);
return true;
}
int SurgeStorage::get_clipboard_type()
{
Expand Down
2 changes: 1 addition & 1 deletion src/common/SurgeStorage.h
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ class alignas(16) SurgeStorage

void load_wt(int id, Wavetable* wt);
void load_wt(std::string filename, Wavetable* wt);
void load_wt_wt(std::string filename, Wavetable* wt);
bool load_wt_wt(std::string filename, Wavetable* wt);
// void load_wt_wav(std::string filename, Wavetable* wt);
void load_wt_wav_portable(std::string filename, Wavetable *wt);
void clipboard_copy(int type, int scene, int entry);
Expand Down

0 comments on commit 687adea

Please sign in to comment.