Simple PropertiesFile test crashes because of Timer?


#1

I was just playing around with a very simple PropertiesFile test and it crashes on an assert in Timer::startTimer(). I don’t understand. Here’s my code:

#include "../JuceLibraryCode/JuceHeader.h"

int main (int argc, char* argv[])
{
    ScopedPointer<PropertiesFile>globalsFile;

    PropertiesFile::Options options;
    options.applicationName     = "Vtree";
    options.filenameSuffix      = "ini";
    options.osxLibrarySubFolder = "Application Support/MyCompany";

    globalsFile = new PropertiesFile(options);
    globalsFile->setValue("myKey", 5);
    globalsFile->save();   // <-----assert failure 

    return 0;
}

What’s going on? Thanks.


#2

It’s telling you that there’s no MessageManager, because you’re not running an event-loop app. PropertiesFile uses timers and events, so although the subset of its features that you’re calling should work in a command line app, the class as a whole isn’t really designed for that situation.


#3

Damn. ok. I was trying to keep my testing bare bones with a console app. I assume then, this would work in a GUI application, yes?


#4

Yep, that’s what it’s for.