From d47ac98318d8edc11411da5a22154b32b5bc405d Mon Sep 17 00:00:00 2001 From: jules Date: Mon, 3 Jun 2013 22:39:21 +0100 Subject: [PATCH] Introjucer: checking for out-of-date introjucer binary. --- README.txt | 2 +- .../Source/Application/jucer_Application.h | 9 +++++ .../Source/Project/jucer_Module.cpp | 39 +++++++++++++++++++ .../Introjucer/Source/Project/jucer_Module.h | 1 + 4 files changed, 50 insertions(+), 1 deletion(-) diff --git a/README.txt b/README.txt index 620db36f81..89162f2751 100644 --- a/README.txt +++ b/README.txt @@ -8,4 +8,4 @@ most applications, and is particularly well-suited for building highly-customised GUIs, and for handling graphics and sound. For more information, visit the website: -http://www.rawmaterialsoftware.com \ No newline at end of file +http://www.juce.com \ No newline at end of file diff --git a/extras/Introjucer/Source/Application/jucer_Application.h b/extras/Introjucer/Source/Application/jucer_Application.h index 1546954051..5f96dae46e 100644 --- a/extras/Introjucer/Source/Application/jucer_Application.h +++ b/extras/Introjucer/Source/Application/jucer_Application.h @@ -472,6 +472,15 @@ public: } } + if (ModuleList().isLibraryNewerThanIntrojucer()) + { + AlertWindow::showMessageBox (AlertWindow::WarningIcon, + "Introjucer", + "This version of the introjucer is out-of-date!" + "\n\n" + "Always make sure that you're running the very latest version, preferably compiled directly from the juce tree that you're working with!"); + } + return true; } diff --git a/extras/Introjucer/Source/Project/jucer_Module.cpp b/extras/Introjucer/Source/Project/jucer_Module.cpp index c64e89612c..d80b1fefbd 100644 --- a/extras/Introjucer/Source/Project/jucer_Module.cpp +++ b/extras/Introjucer/Source/Project/jucer_Module.cpp @@ -73,6 +73,45 @@ bool ModuleList::isLocalModulesFolderValid() return isModulesFolder (getModulesFolderForJuceOrModulesFolder (getLocalModulesFolder (nullptr))); } +static int getVersionElement (const String& v, int index) +{ + StringArray parts; + parts.addTokens (v, "., ", String::empty); + + return parts [parts.size() - index - 1].getIntValue(); +} + +static int getJuceVersion (const String& v) +{ + return getVersionElement (v, 2) * 100000 + + getVersionElement (v, 1) * 1000 + + getVersionElement (v, 0); +} + +static int getBuiltJuceVersion() +{ + return JUCE_MAJOR_VERSION * 100000 + + JUCE_MINOR_VERSION * 1000 + + JUCE_BUILDNUMBER; +} + +bool ModuleList::isLibraryNewerThanIntrojucer() +{ + ModuleList list; + list.rescan (getModulesFolderForJuceOrModulesFolder (getLocalModulesFolder (nullptr))); + + for (int i = list.modules.size(); --i >= 0;) + { + const Module* m = list.modules.getUnchecked(i); + + if (m->uid.startsWith ("juce_") + && getJuceVersion (m->version) > getBuiltJuceVersion()) + return true; + } + + return false; +} + bool ModuleList::isJuceFolder (const File& folder) { return folder.getFileName().containsIgnoreCase ("juce") diff --git a/extras/Introjucer/Source/Project/jucer_Module.h b/extras/Introjucer/Source/Project/jucer_Module.h index 8911f37cb8..84c228d99a 100644 --- a/extras/Introjucer/Source/Project/jucer_Module.h +++ b/extras/Introjucer/Source/Project/jucer_Module.h @@ -129,6 +129,7 @@ public: static File getDefaultModulesFolder (Project*); static bool isLocalModulesFolderValid(); + static bool isLibraryNewerThanIntrojucer(); static File getLocalModulesFolder (Project*); static void setLocalModulesFolder (const File& newFile);