diff --git a/extras/JuceDemo/Source/demos/TreeViewDemo.cpp b/extras/JuceDemo/Source/demos/TreeViewDemo.cpp index 2f7a4065e6..29df726c85 100644 --- a/extras/JuceDemo/Source/demos/TreeViewDemo.cpp +++ b/extras/JuceDemo/Source/demos/TreeViewDemo.cpp @@ -125,7 +125,7 @@ public: const String treeXmlString (BinaryData::treedemo_xml); XmlDocument parser (treeXmlString); treeXml = parser.getDocumentElement(); - jassert (treeXml != 0); + jassert (treeXml != nullptr); } rootItem = new TreeViewDemoItem (*treeXml); @@ -150,28 +150,29 @@ public: ~TreeViewDemo() { - fileTreeComp = 0; - directoryList = 0; // (need to make sure this is deleted before the TimeSliceThread) + treeView = nullptr; + fileTreeComp = nullptr; + directoryList = nullptr; // (need to make sure this is deleted before the TimeSliceThread) } void paint (Graphics& g) { g.setColour (Colours::grey); - if (treeView != 0) + if (treeView != nullptr) g.drawRect (treeView->getX(), treeView->getY(), treeView->getWidth(), treeView->getHeight()); - if (fileTreeComp != 0) + if (fileTreeComp != nullptr) g.drawRect (fileTreeComp->getX(), fileTreeComp->getY(), fileTreeComp->getWidth(), fileTreeComp->getHeight()); } void resized() { - if (treeView != 0) + if (treeView != nullptr) treeView->setBoundsInset (BorderSize (40, 10, 10, 10)); - else if (fileTreeComp != 0) + else if (fileTreeComp != nullptr) fileTreeComp->setBoundsInset (BorderSize (40, 10, 10, 10)); typeButton.changeWidthToFitText (22); @@ -180,8 +181,8 @@ public: void showCustomTreeView() { - treeView = 0; - fileTreeComp = 0; + treeView = nullptr; + fileTreeComp = nullptr; addAndMakeVisible (treeView = new TreeView()); treeView->setRootItem (rootItem); @@ -192,8 +193,8 @@ public: void showFileTreeComp() { - treeView = 0; - fileTreeComp = 0; + treeView = nullptr; + fileTreeComp = nullptr; addAndMakeVisible (fileTreeComp = new FileTreeComponent (*directoryList)); resized(); @@ -206,11 +207,11 @@ public: m.addItem (2, "FileTreeComponent showing the file system"); m.addSeparator(); m.addItem (3, "Show root item", true, - treeView != 0 ? treeView->isRootItemVisible() - : fileTreeComp->isRootItemVisible()); + treeView != nullptr ? treeView->isRootItemVisible() + : fileTreeComp->isRootItemVisible()); m.addItem (4, "Show open/close buttons", true, - treeView != 0 ? treeView->areOpenCloseButtonsVisible() - : fileTreeComp->areOpenCloseButtonsVisible()); + treeView != nullptr ? treeView->areOpenCloseButtonsVisible() + : fileTreeComp->areOpenCloseButtonsVisible()); m.showMenuAsync (PopupMenu::Options().withTargetComponent (&typeButton), ModalCallbackFunction::forComponent (menuItemChosenCallback, this)); @@ -218,7 +219,7 @@ public: static void menuItemChosenCallback (int result, TreeViewDemo* demoComponent) { - if (demoComponent != 0) + if (demoComponent != nullptr) demoComponent->menuItemChosenCallback (result); } @@ -234,16 +235,16 @@ public: } else if (result == 3) { - if (treeView != 0) + if (treeView != nullptr) treeView->setRootItemVisible (! treeView->isRootItemVisible()); - else + else if (fileTreeComp != nullptr) fileTreeComp->setRootItemVisible (! fileTreeComp->isRootItemVisible()); } else if (result == 4) { - if (treeView != 0) + if (treeView != nullptr) treeView->setOpenCloseButtonsVisible (! treeView->areOpenCloseButtonsVisible()); - else + else if (fileTreeComp != nullptr) fileTreeComp->setOpenCloseButtonsVisible (! fileTreeComp->areOpenCloseButtonsVisible()); } } diff --git a/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsList.cpp b/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsList.cpp index b80edf5b1a..9dff89ff81 100644 --- a/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsList.cpp +++ b/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsList.cpp @@ -37,7 +37,7 @@ DirectoryContentsList::DirectoryContentsList (const FileFilter* const fileFilter DirectoryContentsList::~DirectoryContentsList() { - clear(); + stopSearching(); } void DirectoryContentsList::setIgnoresHiddenFiles (const bool shouldIgnoreHiddenFiles) @@ -88,12 +88,16 @@ void DirectoryContentsList::setTypeFlags (const int newFlags) } } -void DirectoryContentsList::clear() +void DirectoryContentsList::stopSearching() { shouldStop = true; thread.removeTimeSliceClient (this); - fileFindHandle = nullptr; +} + +void DirectoryContentsList::clear() +{ + stopSearching(); if (files.size() > 0) { diff --git a/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsList.h b/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsList.h index f6528bc867..e861f0475c 100644 --- a/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsList.h +++ b/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsList.h @@ -200,6 +200,7 @@ private: ScopedPointer fileFindHandle; bool volatile shouldStop; + void stopSearching(); void changed(); bool checkNextFile (bool& hasChanged); bool addFile (const File& file, bool isDir, diff --git a/modules/juce_gui_basics/native/juce_win32_Windowing.cpp b/modules/juce_gui_basics/native/juce_win32_Windowing.cpp index 4215782d8d..94902390c8 100644 --- a/modules/juce_gui_basics/native/juce_win32_Windowing.cpp +++ b/modules/juce_gui_basics/native/juce_win32_Windowing.cpp @@ -2874,13 +2874,20 @@ void Desktop::getCurrentMonitorPositions (Array >& monitorCoords } //============================================================================== -Image juce_createIconForFile (const File& file) +static HICON extractFileHICON (const File& file) { - Image image; WORD iconNum = 0; + WCHAR name [MAX_PATH * 2]; + file.getFullPathName().copyToUTF16 (name, sizeof (name)); + + return ExtractAssociatedIcon ((HINSTANCE) Process::getCurrentModuleInstanceHandle(), + name, &iconNum); +} - HICON icon = ExtractAssociatedIcon ((HINSTANCE) Process::getCurrentModuleInstanceHandle(), - const_cast (file.getFullPathName().toWideCharPointer()), &iconNum); +Image juce_createIconForFile (const File& file) +{ + Image image; + HICON icon = extractFileHICON (file); if (icon != 0) {