Skip to content
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

Provide a cleaner error message for windows.wt #1248

Merged
merged 1 commit into from
Oct 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 24 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,11 @@ 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" );
fclose(f);
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