Ver código fonte

fix some deadlocks

Kolja Strohm 1 mês atrás
pai
commit
bb94048bfc

+ 0 - 2
FactoryCraft/FactoryClient.cpp

@@ -742,7 +742,6 @@ void FactoryClient::loadServerInfo()
         mdl->setSize(itemTypes[i]->getSize());
         w->addDrawable(mdl);
         w->tick(0);
-        window->zScreen()->writeLock().lock();
         DX11Texture* t = (DX11Texture*)window->zScreen()
                              ->zGraphicsApi()
                              ->createOrGetTexture(Text("rendered/items/")
@@ -753,7 +752,6 @@ void FactoryClient::loadServerInfo()
         t->copyToImage(result);
         itemTypes[i]->setBild(result);
         t->release();
-        window->zScreen()->writeLock().unlock();
         w->removeDrawable(mdl);
         loadMenu->stageProgress(1);
     }

+ 4 - 2
FactoryCraft/Game.cpp

@@ -323,8 +323,10 @@ void Game::showItemList()
     if (!itemListContainer)
     {
         itemListContainer = new ItemListContainer();
-        window->zScreen()->addMember(
-            dynamic_cast<Drawable*>(itemListContainer->getThis()));
+        window->zScreen()->postAction([this]() {
+            window->zScreen()->addMember(
+                dynamic_cast<Drawable*>(itemListContainer->getThis()));
+        });
     }
     itemListContainer->addStyle(Window::Style::Visible);
 }

+ 7 - 5
FactoryCraft/ItemList.cpp

@@ -30,11 +30,13 @@ ItemList::ItemList()
         if (slot != -1)
         {
             std::cout << "requesting tooltip for slot " << slot << "\n";
-            UIMLToolTip* tip = new UIMLToolTip();
-            tip->setUIML(itemTypes[slot]->getTooltipUIML());
-            tip->setWarten(0);
-            tip->setPosition(mausPos.x, mausPos.y + 15);
-            setToolTipZ(tip);
+            window->zScreen()->postAction([this, slot]() {
+                UIMLToolTip* tip = new UIMLToolTip();
+                tip->setUIML(itemTypes[slot]->getTooltipUIML());
+                tip->setWarten(0);
+                tip->setPosition(mausPos.x, mausPos.y + 15);
+                setToolTipZ(tip);
+            });
             currentTooltipSlot = slot;
             return 1;
         }

+ 1 - 1
FactoryCraft/Main.cpp

@@ -182,7 +182,7 @@ int KSGStart Framework::Start(Framework::Startparam p)
     window.setKeyboardAction(_ret1TE);
     Screen3D screen(
         dynamic_cast<NativeWindow*>(window.getThis()), new CustomDX11API());
-    screen.setHandleUserInputsOnTick(1);
+    screen.setHandleUserInputsOnTick(0);
     window.setScreen(dynamic_cast<Screen*>(screen.getThis()));
     screen.setFillColor(0);
     screen.setTestRend(0);

+ 4 - 2
FactoryCraft/Menu.cpp

@@ -9,8 +9,10 @@ Menu::Menu(Screen* zScreen)
 
 void Menu::show()
 {
-    for (auto member : elements)
-        zScreen->addMember(dynamic_cast<Drawable*>(member->getThis()));
+    zScreen->postAction([this]() {
+        for (auto member : elements)
+            zScreen->addMember(dynamic_cast<Drawable*>(member->getThis()));
+        });
 }
 
 void Menu::hide()