Browse Source

Introjucer: fix for binary data with duplicate filenames.

tags/2021-05-28
jules 13 years ago
parent
commit
46f1c15f92
9 changed files with 41 additions and 97 deletions
  1. +17
    -34
      extras/Introjucer/JuceLibraryCode/BinaryData.cpp
  2. +5
    -8
      extras/Introjucer/Source/Project Saving/jucer_ResourceFile.cpp
  3. +1
    -1
      extras/Introjucer/Source/Project Saving/jucer_ResourceFile.h
  4. +0
    -2
      extras/Introjucer/Source/Project/jucer_Project.cpp
  5. +4
    -19
      extras/Introjucer/Source/Utility/jucer_CodeHelpers.cpp
  6. +5
    -10
      extras/JuceDemo/JuceLibraryCode/BinaryData.cpp
  7. +4
    -8
      extras/the jucer/JuceLibraryCode/BinaryData.cpp
  8. +2
    -2
      modules/juce_events/native/juce_linux_Messaging.cpp
  9. +3
    -13
      modules/juce_gui_basics/native/juce_linux_Windowing.cpp

+ 17
- 34
extras/Introjucer/JuceLibraryCode/BinaryData.cpp View File

@@ -884,40 +884,23 @@ const char* getNamedResource (const char* resourceNameUTF8, int& numBytes) throw
switch (hash)
{
case 0x44be9398:
case 0x2981a553: numBytes = 2112; return AudioPluginXCodeScript_txt;
case 0x4a0cfd09:
case 0x11a2eef1: numBytes = 151; return background_tile_png;
case 0x763d39dc:
case 0x15a79882: numBytes = 1050; return colourscheme_dark_xml;
case 0xe8b08520:
case 0xf23740fc: numBytes = 1050; return colourscheme_light_xml;
case 0x27c5a93a:
case 0xb6575890: numBytes = 1008; return jucer_AudioPluginEditorTemplate_cpp;
case 0x4d0721bf:
case 0xc244271a: numBytes = 799; return jucer_AudioPluginEditorTemplate_h;
case 0x51b49ac5:
case 0xc68aa4a1: numBytes = 4473; return jucer_AudioPluginFilterTemplate_cpp;
case 0x488afa0a:
case 0x99c7f951: numBytes = 2400; return jucer_AudioPluginFilterTemplate_h;
case 0x8905395b:
case 0x84a71cc0: numBytes = 470; return jucer_MainConsoleAppTemplate_cpp;
case 0x7a0186b1:
case 0x73760f7c: numBytes = 1742; return jucer_MainTemplate_cpp;
case 0xf4842835:
case 0x1329dd50: numBytes = 1389; return jucer_NewComponentTemplate_cpp;
case 0xe7bf237a:
case 0x1e76fc7c: numBytes = 649; return jucer_NewComponentTemplate_h;
case 0x02a2a077:
case 0x9a5d0862: numBytes = 260; return jucer_NewCppFileTemplate_cpp;
case 0x0842c43c:
case 0xfbfcda3c: numBytes = 308; return jucer_NewCppFileTemplate_h;
case 0x36e634a1:
case 0x2be6f132: numBytes = 1627; return jucer_NewInlineComponentTemplate_h;
case 0x3f052be8:
case 0xb905d1ba: numBytes = 905; return jucer_WindowTemplate_cpp;
case 0xb20377ed:
case 0x959d5d38: numBytes = 1220; return jucer_WindowTemplate_h;
case 0x44be9398: numBytes = 2112; return AudioPluginXCodeScript_txt;
case 0x4a0cfd09: numBytes = 151; return background_tile_png;
case 0x763d39dc: numBytes = 1050; return colourscheme_dark_xml;
case 0xe8b08520: numBytes = 1050; return colourscheme_light_xml;
case 0x27c5a93a: numBytes = 1008; return jucer_AudioPluginEditorTemplate_cpp;
case 0x4d0721bf: numBytes = 799; return jucer_AudioPluginEditorTemplate_h;
case 0x51b49ac5: numBytes = 4473; return jucer_AudioPluginFilterTemplate_cpp;
case 0x488afa0a: numBytes = 2400; return jucer_AudioPluginFilterTemplate_h;
case 0x8905395b: numBytes = 470; return jucer_MainConsoleAppTemplate_cpp;
case 0x7a0186b1: numBytes = 1742; return jucer_MainTemplate_cpp;
case 0xf4842835: numBytes = 1389; return jucer_NewComponentTemplate_cpp;
case 0xe7bf237a: numBytes = 649; return jucer_NewComponentTemplate_h;
case 0x02a2a077: numBytes = 260; return jucer_NewCppFileTemplate_cpp;
case 0x0842c43c: numBytes = 308; return jucer_NewCppFileTemplate_h;
case 0x36e634a1: numBytes = 1627; return jucer_NewInlineComponentTemplate_h;
case 0x3f052be8: numBytes = 905; return jucer_WindowTemplate_cpp;
case 0xb20377ed: numBytes = 1220; return jucer_WindowTemplate_h;
default: break;
}


+ 5
- 8
extras/Introjucer/Source/Project Saving/jucer_ResourceFile.cpp View File

@@ -70,17 +70,17 @@ void ResourceFile::addResourcesFromProjectItem (const Project::Item& projectItem
else
{
if (projectItem.shouldBeAddedToBinaryResources())
addFile (projectItem.getFile(), projectItem.getImageFileID());
addFile (projectItem.getFile());
}
}
//==============================================================================
void ResourceFile::setClassName (const String& className_)
void ResourceFile::setClassName (const String& name)
{
className = className_;
className = name;
}
void ResourceFile::addFile (const File& file, const String& imageProviderId)
void ResourceFile::addFile (const File& file)
{
files.add (file);
@@ -91,9 +91,6 @@ void ResourceFile::addFile (const File& file, const String& imageProviderId)
while (variableNames.contains (variableName))
variableName = variableNameRoot + String (suffix++);
if (imageProviderId.isNotEmpty())
variableName << "|" << imageProviderId;
variableNames.add (variableName);
}
@@ -147,7 +144,7 @@ bool ResourceFile::write (const File& cppFile, OutputStream& cpp, OutputStream&
const File& file = files.getReference(i);
const int64 dataSize = file.getSize();
const String variableName (variableNames[i].upToFirstOccurrenceOf ("|", false, false));
const String variableName (variableNames[i]);
FileInputStream fileStream (file);


+ 1
- 1
extras/Introjucer/Source/Project Saving/jucer_ResourceFile.h View File

@@ -45,7 +45,7 @@ public:
void setClassName (const String& className);
String getClassName() const { return className; }
void addFile (const File& file, const String& imageProviderId);
void addFile (const File& file);
String getDataVariableFor (const File& file) const;
String getSizeVariableFor (const File& file) const;


+ 0
- 2
extras/Introjucer/Source/Project/jucer_Project.cpp View File

@@ -442,8 +442,6 @@ Project::Item Project::Item::createCopy() { Item i (*this); i.state = i.
String Project::Item::getID() const { return state [Ids::ID]; }
void Project::Item::setID (const String& newID) { state.setProperty (Ids::ID, newID, nullptr); }
String Project::Item::getImageFileID() const { return "id:" + getID(); }
Image Project::Item::loadAsImageFile() const
{
return isValid() ? ImageCache::getFromFile (getFile())


+ 4
- 19
extras/Introjucer/Source/Utility/jucer_CodeHelpers.cpp View File

@@ -350,20 +350,15 @@ namespace CodeHelpers
static int findBestHashMultiplier (const StringArray& strings)
{
StringArray allStrings;
for (int i = strings.size(); --i >= 0;)
allStrings.addTokens (strings[i], "|", "");
int v = 31;
for (;;)
{
SortedSet <unsigned int> hashes;
bool collision = false;
for (int i = allStrings.size(); --i >= 0;)
for (int i = strings.size(); --i >= 0;)
{
const unsigned int hash = calculateHash (allStrings[i], v);
const unsigned int hash = calculateHash (strings[i], v);
if (hashes.contains (hash))
{
collision = true;
@@ -399,18 +394,8 @@ namespace CodeHelpers
for (int i = 0; i < strings.size(); ++i)
{
StringArray matchingStrings;
matchingStrings.addTokens (strings[i], "|", "");
for (int j = 0; j < matchingStrings.size(); ++j)
{
out << indent << " case 0x" << hexString8Digits (calculateHash (matchingStrings[j], hashMultiplier)) << ":";
if (j < matchingStrings.size() - 1)
out << newLine;
}
out << " " << codeToExecute[i] << newLine;
out << indent << " case 0x" << hexString8Digits (calculateHash (strings[i], hashMultiplier))
<< ": " << codeToExecute[i] << newLine;
}
out << indent << " default: break;" << newLine


+ 5
- 10
extras/JuceDemo/JuceLibraryCode/BinaryData.cpp View File

@@ -2151,16 +2151,11 @@ const char* getNamedResource (const char* resourceNameUTF8, int& numBytes) throw
switch (hash)
{
case 0x62032efa:
case 0x877c5941: numBytes = 46348; return cello_wav;
case 0xaec3f52f:
case 0x5ef7e0f0: numBytes = 5239; return demo_table_data_xml;
case 0xae303c7c:
case 0xae3ee894: numBytes = 83876; return icons_zip;
case 0xdf2195d7:
case 0xc23b6643: numBytes = 15290; return juce_png;
case 0xdd644959:
case 0x0ff8e16f: numBytes = 1126; return treedemo_xml;
case 0x62032efa: numBytes = 46348; return cello_wav;
case 0xaec3f52f: numBytes = 5239; return demo_table_data_xml;
case 0xae303c7c: numBytes = 83876; return icons_zip;
case 0xdf2195d7: numBytes = 15290; return juce_png;
case 0xdd644959: numBytes = 1126; return treedemo_xml;
default: break;
}


+ 4
- 8
extras/the jucer/JuceLibraryCode/BinaryData.cpp View File

@@ -518,14 +518,10 @@ const char* getNamedResource (const char* resourceNameUTF8, int& numBytes) throw
switch (hash)
{
case 0xe23b4891:
case 0xfe8a1589: numBytes = 24218; return jules_jpg;
case 0x496477a8:
case 0xf26e465b: numBytes = 1819; return prefs_about_png;
case 0x44e88a0d:
case 0xf6e6db91: numBytes = 3794; return prefs_keys_png;
case 0xdd254505:
case 0xe1146fbf: numBytes = 6162; return prefs_misc_png;
case 0xe23b4891: numBytes = 24218; return jules_jpg;
case 0x496477a8: numBytes = 1819; return prefs_about_png;
case 0x44e88a0d: numBytes = 3794; return prefs_keys_png;
case 0xdd254505: numBytes = 6162; return prefs_misc_png;
default: break;
}


+ 2
- 2
modules/juce_events/native/juce_linux_Messaging.cpp View File

@@ -31,8 +31,8 @@ Display* display = nullptr;
Window juce_messageWindowHandle = None;
XContext windowHandleXContext; // This is referenced from Windowing.cpp
extern void juce_windowMessageReceive (XEvent* event); // Defined in Windowing.cpp
extern void juce_handleSelectionRequest (XSelectionRequestEvent &evt); // Defined in Clipboard.cpp
extern void juce_windowMessageReceive (XEvent*); // Defined in Windowing.cpp
extern void juce_handleSelectionRequest (XSelectionRequestEvent&); // Defined in Clipboard.cpp
//==============================================================================
ScopedXLock::ScopedXLock() { XLockDisplay (display); }


+ 3
- 13
modules/juce_gui_basics/native/juce_linux_Windowing.cpp View File

@@ -2602,20 +2602,10 @@ void juce_windowMessageReceive (XEvent* event)
if (LinuxComponentPeer* const peer = LinuxComponentPeer::getPeerFor (event->xany.window))
peer->handleWindowMessage (event);
}
else
else if (event->xany.type == KeymapNotify)
{
switch (event->xany.type)
{
case KeymapNotify:
{
const XKeymapEvent* const keymapEvent = (const XKeymapEvent*) &event->xkeymap;
memcpy (Keys::keyStates, keymapEvent->key_vector, 32);
break;
}
default:
break;
}
const XKeymapEvent* const keymapEvent = (const XKeymapEvent*) &event->xkeymap;
memcpy (Keys::keyStates, keymapEvent->key_vector, 32);
}
}


Loading…
Cancel
Save