diff --git a/src/musikcore/library/track/TrackList.cpp b/src/musikcore/library/track/TrackList.cpp index 93e198dbf..8030422ea 100755 --- a/src/musikcore/library/track/TrackList.cpp +++ b/src/musikcore/library/track/TrackList.cpp @@ -278,9 +278,9 @@ void TrackList::CacheWindow(size_t from, size_t to, bool async) const { if (async) { currentWindow.Set(from, to); auto shared = shared_from_this(); /* ensure we remain alive for the duration of the query */ - bool completionFinished = false; - auto completion = [this, &completionFinished, shared, from, to, query](auto q) { - if (completionFinished) { + auto completionFinished = std::make_shared(false); /* ugh... keep it alive. */ + auto completion = [this, completionFinished, shared, from, to, query](auto q) { + if (*completionFinished) { return; } if (query->GetStatus() == IQuery::Finished) { @@ -296,7 +296,7 @@ void TrackList::CacheWindow(size_t from, size_t to, bool async) const { this->CacheWindow(from, to, true); } this->WindowCached(const_cast(this), from, to); - completionFinished = true; + *completionFinished = true; }; this->library->EnqueueAndWait(query, kCacheWindowTimeoutMs, completion); diff --git a/src/musikcube/cursespp/cursespp/InternalWindowMessages.h b/src/musikcube/cursespp/cursespp/InternalWindowMessages.h new file mode 100644 index 000000000..d17cfd641 --- /dev/null +++ b/src/musikcube/cursespp/cursespp/InternalWindowMessages.h @@ -0,0 +1,48 @@ +////////////////////////////////////////////////////////////////////////////// +// +// Copyright (c) 2004-2020 musikcube team +// +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// * Neither the name of the author nor the names of other contributors may +// be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// +////////////////////////////////////////////////////////////////////////////// + +#pragma once + +namespace cursespp { + namespace InternalWindowMessages { + /* range of message ids reserved for internal use. exercise caution if + creating your own messages within this range. */ + static const int kLastReservedMessageId = INT_MAX; + static const int kFirstReservedMessageId = kLastReservedMessageId - 1024; + + static const int NotifyVisibilityChanged = kFirstReservedMessageId + 1; + static const int NotifyChildFocusChanged = kFirstReservedMessageId + 2; + + } +}