Процесс завершен с кодом выхода -1073740791 (0xC0000409)
Я понимаю, что эта ошибка вызвана переполнением стека, но я дважды проверил свой код и не могу определить, где может произойти утечка памяти. Я сузил проблему до нескольких функций событий, которые обрабатывают ввод с помощью мыши и стилуса.
Код: Выделить всё
def mousePressEvent(self, event):
if event.button() == Qt.LeftButton:
self.mousedown = True
x, y = event.pos().x(), event.pos().y()
if y >= self.height() - 80:
for rect, colour in self.palette_rects:
if rect.collidepoint(x, y):
self.selected_colour = colour
print(f"Selected colour: {self.selected_colour}")
break
else:
self.shade = self.selected_colour
elif event.button() == Qt.RightButton:
self.mousedown = True
self.shade = self.backdrop
def mouseMoveEvent(self, event):
if self.mousedown:
spot = (event.pos().x(), event.pos().y())
adjusted_radius = int(self.radius * self.pen_pressure)
pygame.draw.circle(self.transparent_surface, self.shade, spot, adjusted_radius)
self.update()
print(f"Spot: {spot}, Radius: {adjusted_radius}")
def mouseReleaseEvent(self, event):
if event.button() == Qt.LeftButton or event.button() == Qt.RightButton:
self.mousedown = False
def keyPressEvent(self, event):
print(f"Key pressed: {event.key()}")
if event.key() == Qt.Key_Q:
self.close()
Код: Выделить всё
if __name__ == '__main__':
app = QApplication(sys.argv)
if not check_license():
sys.exit() # Exit the app if the license is not valid
window = SketchWidget()
window.resize(800, 800)
window.show()
try:
while True:
window.update()
window.clock.tick(60) # Limit the frame rate to 60 FPS
if not app.exec_():
break
except Exception as e:
print(f"An error occurred: {e}")
finally:
pygame.quit() # Clean up Pygame before exiting
sys.exit()
Подробнее здесь: https://stackoverflow.com/questions/791 ... -sensitive