Skip to content

Commit 78a09e2

Browse files
committed
[Windows] RegisterDragDrop に失敗してもエンジン初期化を続行 #1238
1 parent 4b8e927 commit 78a09e2

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

Siv3D/src/Siv3D-Platform/WindowsDesktop/Siv3D/DragDrop/CDragDrop.cpp

+30-1
Original file line numberDiff line numberDiff line change
@@ -741,14 +741,23 @@ namespace s3d
741741

742742
if (FAILED(::RegisterDragDrop(m_hWnd, m_pDropTarget)))
743743
{
744-
throw EngineError{ U"RegisterDragDrop() failed" };
744+
LOG_WARNING(U"RegisterDragDrop() failed");
745+
}
746+
else
747+
{
748+
m_initialized = true;
745749
}
746750

747751
m_pDropTarget->Release();
748752
}
749753

750754
void CDragDrop::update()
751755
{
756+
if (not m_initialized)
757+
{
758+
return;
759+
}
760+
752761
const auto status = m_pDropTarget->getStatus();
753762

754763
const Array<DroppedFilePath>& filePaths = std::get<Array<DroppedFilePath>>(status);
@@ -768,11 +777,21 @@ namespace s3d
768777

769778
void CDragDrop::acceptFilePaths(const bool accept)
770779
{
780+
if (not m_initialized)
781+
{
782+
return;
783+
}
784+
771785
m_pDropTarget->acceptFilePaths(accept);
772786
}
773787

774788
void CDragDrop::acceptText(const bool accept)
775789
{
790+
if (not m_initialized)
791+
{
792+
return;
793+
}
794+
776795
m_pDropTarget->acceptText(accept);
777796
}
778797

@@ -829,13 +848,23 @@ namespace s3d
829848

830849
void CDragDrop::makeDragDrop(const Array<FilePath>& paths)
831850
{
851+
if (not m_initialized)
852+
{
853+
return;
854+
}
855+
832856
std::lock_guard lock{ m_mutex };
833857

834858
m_newDragPaths = paths;
835859
}
836860

837861
void CDragDrop::process()
838862
{
863+
if (not m_initialized)
864+
{
865+
return;
866+
}
867+
839868
Array<FilePath> paths;
840869

841870
{

Siv3D/src/Siv3D-Platform/WindowsDesktop/Siv3D/DragDrop/CDragDrop.hpp

+2
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ namespace s3d
5757

5858
HWND m_hWnd = nullptr;
5959

60+
bool m_initialized = false;
61+
6062
detail::DropTarget* m_pDropTarget = nullptr;
6163

6264
Array<DroppedFilePath> m_droppedFilePaths;

0 commit comments

Comments
 (0)