diff --git a/GpApp/About.cpp b/GpApp/About.cpp index af61ad4..4301a1a 100644 --- a/GpApp/About.cpp +++ b/GpApp/About.cpp @@ -87,7 +87,7 @@ void DoAbout (void) if (okayButtScanlineMask != nil) okayButtScanlineMask->Destroy(); // Clean up! - DisposeDialog(aboutDialog); + aboutDialog->Destroy(); UseResFile(wasResFile); } diff --git a/GpApp/DialogUtils.cpp b/GpApp/DialogUtils.cpp index 6b2eada..3c374c9 100644 --- a/GpApp/DialogUtils.cpp +++ b/GpApp/DialogUtils.cpp @@ -33,7 +33,7 @@ void BringUpDialog (Dialog **theDialog, short dialogID) // CenterDialog(dialogID); if (*theDialog == nil) RedAlert(kErrDialogDidntLoad); - SetGraphicsPort(&(*theDialog)->GetWindow()->m_graf); + SetGraphicsPort(&(*theDialog)->GetWindow()->m_surface); ShowWindow((*theDialog)->GetWindow()); DrawDefaultButton(*theDialog); } diff --git a/GpApp/HighScores.cpp b/GpApp/HighScores.cpp index 451af40..785f748 100644 --- a/GpApp/HighScores.cpp +++ b/GpApp/HighScores.cpp @@ -514,7 +514,7 @@ void GetHighScoreName (short place) } } - DisposeDialog(theDial); + theDial->Destroy(); } //-------------------------------------------------------------- UpdateBannerDialog diff --git a/GpApp/House.cpp b/GpApp/House.cpp index b3030a2..009cdad 100644 --- a/GpApp/House.cpp +++ b/GpApp/House.cpp @@ -697,7 +697,7 @@ Boolean GoToFilter (Dialog *dial, EventRecord *event, short *item) } } - DisposeDialog(theDialog); + theDialog->Destroy(); if (!canceled) { diff --git a/GpApp/HouseInfo.cpp b/GpApp/HouseInfo.cpp index 6041ebe..24153ca 100644 --- a/GpApp/HouseInfo.cpp +++ b/GpApp/HouseInfo.cpp @@ -287,7 +287,7 @@ void DoHouseInfo (void) } } InitCursor(); - DisposeDialog(houseInfoDialog); + houseInfoDialog->Destroy(); } //-------------------------------------------------------------- WarnLockingHouse diff --git a/GpApp/MainWindow.cpp b/GpApp/MainWindow.cpp index 14d7ed1..4958085 100644 --- a/GpApp/MainWindow.cpp +++ b/GpApp/MainWindow.cpp @@ -124,7 +124,7 @@ void RedrawSplashScreen (void) // DissBits(&workSrcRect); CopyRectMainToWork(&workSrcRect); - mainWindow->m_graf.m_port.SetDirty(PortabilityLayer::QDPortDirtyFlag_Contents); + mainWindow->m_surface.m_port.SetDirty(PortabilityLayer::QDPortDirtyFlag_Contents); PortabilityLayer::MenuManager::GetInstance()->SetMenuVisible(true); } @@ -160,7 +160,7 @@ void UpdateMainWindow (void) DrawOnSplash(mainWindow->GetDrawSurface()); } - mainWindow->m_graf.m_port.SetDirty(PortabilityLayer::QDPortDirtyFlag_Contents); + mainWindow->m_surface.m_port.SetDirty(PortabilityLayer::QDPortDirtyFlag_Contents); splashDrawn = true; } diff --git a/GpApp/Menu.cpp b/GpApp/Menu.cpp index b07456c..7d4ea5b 100644 --- a/GpApp/Menu.cpp +++ b/GpApp/Menu.cpp @@ -749,7 +749,7 @@ short QueryResumeGame (void) leaving = true; } } - DisposeDialog(theDial); + theDial->Destroy(); return (hitWhat); } diff --git a/GpApp/ObjectInfo.cpp b/GpApp/ObjectInfo.cpp index 331728a..8591b73 100644 --- a/GpApp/ObjectInfo.cpp +++ b/GpApp/ObjectInfo.cpp @@ -1088,7 +1088,7 @@ void DoBlowerObjectInfo (short what) } } - DisposeDialog(infoDial); + infoDial->Destroy(); if (doReturn) { @@ -1149,7 +1149,7 @@ void DoFurnitureObjectInfo (void) } } - DisposeDialog(infoDial); + infoDial->Destroy(); if (doReturn) { @@ -1247,8 +1247,8 @@ void DoCustPictObjectInfo (void) leaving = true; } } - - DisposeDialog(infoDial); + + infoDial->Destroy(); } //-------------------------------------------------------------- DoSwitchObjectInfo @@ -1346,8 +1346,8 @@ void DoSwitchObjectInfo (void) doReturn = true; } } - - DisposeDialog(infoDial); + + infoDial->Destroy(); if (doLink) { @@ -1498,8 +1498,8 @@ void DoTriggerObjectInfo (void) } } } - - DisposeDialog(infoDial); + + infoDial->Destroy(); if (doLink) { @@ -1593,8 +1593,8 @@ void DoLightObjectInfo (void) doReturn = true; } } - - DisposeDialog(infoDial); + + infoDial->Destroy(); if (doReturn) { @@ -1705,8 +1705,8 @@ void DoApplianceObjectInfo (short what) } } } - - DisposeDialog(infoDial); + + infoDial->Destroy(); if (doReturn) { @@ -1825,8 +1825,8 @@ void DoMicrowaveObjectInfo (void) doReturn = true; } } - - DisposeDialog(infoDial); + + infoDial->Destroy(); if (doReturn) { @@ -1895,8 +1895,8 @@ void DoGreaseObjectInfo (void) doReturn = true; } } - - DisposeDialog(infoDial); + + infoDial->Destroy(); if (doReturn) { @@ -2004,8 +2004,8 @@ void DoInvisBonusObjectInfo (void) doReturn = true; } } - - DisposeDialog(infoDial); + + infoDial->Destroy(); if (doReturn) { @@ -2110,8 +2110,8 @@ void DoTransObjectInfo (short what) SetDialogItemValue(infoDial, kInitialStateCheckbox3, (short)wasState); } } - - DisposeDialog(infoDial); + + infoDial->Destroy(); if (doLink) { @@ -2229,8 +2229,8 @@ void DoEnemyObjectInfo (short what) } } } - - DisposeDialog(infoDial); + + infoDial->Destroy(); if (doReturn) { @@ -2324,8 +2324,8 @@ void DoFlowerObjectInfo (void) doReturn = true; } } - - DisposeDialog(infoDial); + + infoDial->Destroy(); if (doReturn) { diff --git a/GpApp/Play.cpp b/GpApp/Play.cpp index 6ee735c..0093f2f 100644 --- a/GpApp/Play.cpp +++ b/GpApp/Play.cpp @@ -143,7 +143,7 @@ void NewGame (short mode) #ifdef COMPILEQT if ((thisMac.hasQT) && (hasMovie)) { - SetMovieGWorld(theMovie, &mainWindow->m_graf, nil); + SetMovieGWorld(theMovie, &mainWindow->m_surface, nil); } #endif diff --git a/GpApp/RoomInfo.cpp b/GpApp/RoomInfo.cpp index c4dc59a..a6da379 100644 --- a/GpApp/RoomInfo.cpp +++ b/GpApp/RoomInfo.cpp @@ -594,7 +594,7 @@ void DoRoomInfo (void) } InitCursor(); - DisposeDialog(roomInfoDialog); + roomInfoDialog->Destroy(); // KillOffScreenPixMap(tileSrcMap); DisposeGWorld(tileSrcMap); @@ -847,7 +847,7 @@ short ChooseOriginalArt (short was) } } - DisposeDialog(theDialog); + theDialog->Destroy(); return (newPictID); } diff --git a/GpApp/SelectHouse.cpp b/GpApp/SelectHouse.cpp index ed89a64..ffa12e6 100644 --- a/GpApp/SelectHouse.cpp +++ b/GpApp/SelectHouse.cpp @@ -514,8 +514,8 @@ void DoLoadHouse (void) PageDownHouses(theDial); } } - - DisposeDialog(theDial); + + theDial->Destroy(); } #endif diff --git a/GpApp/Settings.cpp b/GpApp/Settings.cpp index 658cf7c..8b3a20a 100644 --- a/GpApp/Settings.cpp +++ b/GpApp/Settings.cpp @@ -75,7 +75,7 @@ void HandleSoundMusicChange (short, Boolean); Boolean SoundFilter (Dialog *, EventRecord *, short *); void DoSoundPrefs (void); void DisplayDefaults (void); -void FrameDisplayIcon (Dialog *); +void FrameDisplayIcon (Dialog *, const PortabilityLayer::RGBAColor &color); void DisplayUpdate (Dialog *); Boolean DisplayFilter (Dialog *, EventRecord *, short *); void DoDisplayPrefs (void); @@ -317,7 +317,7 @@ void DoBrainsPrefs (void) } } - DisposeDialog(prefDlg); + prefDlg->Destroy(); } //-------------------------------------------------------------- SetControlsToDefaults @@ -601,8 +601,8 @@ void DoControlPrefs (void) break; } } - - DisposeDialog(prefDlg); + + prefDlg->Destroy(); } //-------------------------------------------------------------- SoundDefaults @@ -882,8 +882,8 @@ void DoSoundPrefs (void) break; } } - - DisposeDialog(prefDlg); + + prefDlg->Destroy(); } //-------------------------------------------------------------- DisplayDefaults @@ -898,7 +898,7 @@ void DisplayDefaults (void) //-------------------------------------------------------------- FrameDisplayIcon -void FrameDisplayIcon (Dialog *theDialog) +void FrameDisplayIcon (Dialog *theDialog, const PortabilityLayer::RGBAColor &color) { Rect theRect; @@ -919,7 +919,7 @@ void FrameDisplayIcon (Dialog *theDialog) DrawSurface *surface = theDialog->GetWindow()->GetDrawSurface(); - surface->SetForeColor(StdColors::Black()); + surface->SetForeColor(color); theRect.left -= 3; theRect.top += 0; @@ -943,7 +943,7 @@ void DisplayUpdate (Dialog *theDialog) SetDialogItemValue(theDialog, kUseScreen2Item, (short)wasScreen2); ForeColor(redColor); - FrameDisplayIcon(theDialog); + FrameDisplayIcon(theDialog, StdColors::Red()); ForeColor(blackColor); FrameDialogItemC(theDialog, 8, kRedOrangeColor8); FrameDialogItemC(theDialog, 13, kRedOrangeColor8); @@ -1058,9 +1058,11 @@ int16_t DisplayFilter(Dialog *dial, const TimeTaggedVOSEvent &evt) return kUseQDItem; default: - return(false); + return -1; } } + + return -1; } //-------------------------------------------------------------- DoDisplayPrefs @@ -1110,35 +1112,26 @@ void DoDisplayPrefs (void) break; case kDisplay1Item: - ForeColor(whiteColor); - FrameDisplayIcon(prefDlg); + FrameDisplayIcon(prefDlg, StdColors::White()); numNeighbors = 1; - ForeColor(redColor); - FrameDisplayIcon(prefDlg); - ForeColor(blackColor); + FrameDisplayIcon(prefDlg, StdColors::Red()); break; case kDisplay3Item: if (thisMac.screen.right > 512) { - ForeColor(whiteColor); - FrameDisplayIcon(prefDlg); + FrameDisplayIcon(prefDlg, StdColors::White()); numNeighbors = 3; - ForeColor(redColor); - FrameDisplayIcon(prefDlg); - ForeColor(blackColor); + FrameDisplayIcon(prefDlg, StdColors::Red()); } break; case kDisplay9Item: if (thisMac.screen.right > 512) { - ForeColor(whiteColor); - FrameDisplayIcon(prefDlg); + FrameDisplayIcon(prefDlg, StdColors::White()); numNeighbors = 9; - ForeColor(redColor); - FrameDisplayIcon(prefDlg); - ForeColor(blackColor); + FrameDisplayIcon(prefDlg, StdColors::Red()); } break; @@ -1155,8 +1148,7 @@ void DoDisplayPrefs (void) break; case kDispDefault: - ForeColor(whiteColor); - FrameDisplayIcon(prefDlg); + FrameDisplayIcon(prefDlg, StdColors::White()); ForeColor(blackColor); DisplayDefaults(); DisplayUpdate(prefDlg); @@ -1361,20 +1353,20 @@ void DoSettingsMain (void) case kDisplayButton: FlashSettingsButton(surface, 0); DoDisplayPrefs(); - SetGraphicsPort(&prefDlg->GetWindow()->m_graf); + SetGraphicsPort(&prefDlg->GetWindow()->m_surface); break; case kSoundButton: FlashSettingsButton(surface, 1); DoSoundPrefs(); - SetGraphicsPort(&prefDlg->GetWindow()->m_graf); + SetGraphicsPort(&prefDlg->GetWindow()->m_surface); FlushEvents(everyEvent, 0); break; case kControlsButton: FlashSettingsButton(surface, 2); DoControlPrefs(); - SetGraphicsPort(&prefDlg->GetWindow()->m_graf); + SetGraphicsPort(&prefDlg->GetWindow()->m_surface); break; case kBrainsButton: @@ -1386,7 +1378,7 @@ void DoSettingsMain (void) } FlashSettingsButton(surface, 3); DoBrainsPrefs(); - SetGraphicsPort(&prefDlg->GetWindow()->m_graf); + SetGraphicsPort(&prefDlg->GetWindow()->m_surface); break; case kAllDefaultsButton: @@ -1395,7 +1387,7 @@ void DoSettingsMain (void) } } - DisposeDialog(prefDlg); + prefDlg->Destroy(); if (nextRestartChange) BitchAboutChanges(); diff --git a/PortabilityLayer/PLButtonWidget.cpp b/PortabilityLayer/PLButtonWidget.cpp index 8c83bba..59d6582 100644 --- a/PortabilityLayer/PLButtonWidget.cpp +++ b/PortabilityLayer/PLButtonWidget.cpp @@ -10,7 +10,7 @@ namespace PortabilityLayer { } - WidgetHandleState_t ButtonWidget::ProcessEvent(Window *window, const TimeTaggedVOSEvent &evt) + WidgetHandleState_t ButtonWidget::ProcessEvent(const TimeTaggedVOSEvent &evt) { if (m_haveMouseDown) { @@ -18,7 +18,7 @@ namespace PortabilityLayer { m_haveMouseDown = false; - const Point pt = window->MouseToLocal(evt.m_vosEvent.m_event.m_mouseInputEvent); + const Point pt = m_window->MouseToLocal(evt.m_vosEvent.m_event.m_mouseInputEvent); if (m_rect.Contains(pt)) return WidgetHandleStates::kActivated; else @@ -31,7 +31,7 @@ namespace PortabilityLayer { if (evt.IsLMouseDownEvent()) { - const Point pt = window->MouseToLocal(evt.m_vosEvent.m_event.m_mouseInputEvent); + const Point pt = m_window->MouseToLocal(evt.m_vosEvent.m_event.m_mouseInputEvent); if (m_rect.Contains(pt)) { diff --git a/PortabilityLayer/PLButtonWidget.h b/PortabilityLayer/PLButtonWidget.h index 215cceb..1578fcb 100644 --- a/PortabilityLayer/PLButtonWidget.h +++ b/PortabilityLayer/PLButtonWidget.h @@ -12,7 +12,7 @@ namespace PortabilityLayer bool Init(const WidgetBasicState &state) override; - WidgetHandleState_t ProcessEvent(Window *window, const TimeTaggedVOSEvent &evt); + WidgetHandleState_t ProcessEvent(const TimeTaggedVOSEvent &evt) override; private: bool m_haveMouseDown; diff --git a/PortabilityLayer/PLCore.cpp b/PortabilityLayer/PLCore.cpp index 32e19b8..b13a400 100644 --- a/PortabilityLayer/PLCore.cpp +++ b/PortabilityLayer/PLCore.cpp @@ -225,7 +225,7 @@ void DisposeWindow(WindowPtr window) void GetWindowBounds(WindowPtr window, WindowRegionType windowRegion, Rect *rect) { if (windowRegion == kWindowContentRgn) - *rect = window->m_graf.m_port.GetRect(); + *rect = window->m_surface.m_port.GetRect(); else { PL_NotYetImplemented(); @@ -817,15 +817,19 @@ WindowPtr PL_GetPutInFrontWindowPtr() } Window::Window() - : m_graf(PortabilityLayer::QDPortType_Window) + : m_surface(PortabilityLayer::QDPortType_Window) , m_wmX(0) , m_wmY(0) { } +Window::~Window() +{ +} + DrawSurface *Window::GetDrawSurface() const { - return const_cast(&m_graf); + return const_cast(&m_surface); } Point Window::MouseToLocal(const GpMouseInputEvent &evt) const diff --git a/PortabilityLayer/PLCore.h b/PortabilityLayer/PLCore.h index f97a1b8..9a31c55 100644 --- a/PortabilityLayer/PLCore.h +++ b/PortabilityLayer/PLCore.h @@ -108,12 +108,15 @@ struct Window // Convenience method to convert a mouse event to local point Point MouseToLocal(const GpMouseInputEvent &evt) const; - DrawSurface m_graf; // Must be the first item + DrawSurface m_surface; // Must be the first item until the immediate mode draw API is completely removed // The port is always at 0,0 // These are the WM coordinates int32_t m_wmX; int32_t m_wmY; + +protected: + ~Window(); }; struct DateTimeRec diff --git a/PortabilityLayer/PLDialogs.cpp b/PortabilityLayer/PLDialogs.cpp index d9dd2d9..7b55933 100644 --- a/PortabilityLayer/PLDialogs.cpp +++ b/PortabilityLayer/PLDialogs.cpp @@ -52,10 +52,6 @@ void ModalDialog(ModalFilterUPP filter, short *item) PL_NotYetImplemented(); } -void DisposeDialog(Dialog *dialog) -{ - PL_NotYetImplemented(); -} void DisposeModalFilterUPP(ModalFilterUPP upp) { diff --git a/PortabilityLayer/PLDialogs.h b/PortabilityLayer/PLDialogs.h index f1f99ad..00ae005 100644 --- a/PortabilityLayer/PLDialogs.h +++ b/PortabilityLayer/PLDialogs.h @@ -41,7 +41,5 @@ void SelectDialogItemText(Dialog *dialog, int item, int firstSelChar, int lastSe void ModalDialog(ModalFilterUPP filter, short *item); -void DisposeDialog(Dialog *dialog); - void ShowDialogItem(Dialog *dialog, int item); void HideDialogItem(Dialog *dialog, int item); diff --git a/PortabilityLayer/PLIconWidget.cpp b/PortabilityLayer/PLIconWidget.cpp index 958603a..e8ec1d4 100644 --- a/PortabilityLayer/PLIconWidget.cpp +++ b/PortabilityLayer/PLIconWidget.cpp @@ -2,6 +2,7 @@ #include "IconLoader.h" #include "QDPixMap.h" +#include "PLTimeTaggedVOSEvent.h" #include @@ -46,4 +47,12 @@ namespace PortabilityLayer CopyMask(*m_iconImage, *m_iconMask, *surface->m_port.GetPixMap(), &(*m_iconImage)->m_rect, &(*m_iconMask)->m_rect, &m_rect); surface->m_port.SetDirty(PortabilityLayer::QDPortDirtyFlag_Contents); } + + WidgetHandleState_t IconWidget::ProcessEvent(const TimeTaggedVOSEvent &evt) + { + if (evt.IsLMouseDownEvent() && m_rect.Contains(m_window->MouseToLocal(evt.m_vosEvent.m_event.m_mouseInputEvent))) + return WidgetHandleStates::kActivated; + else + return WidgetHandleStates::kIgnored; + } } diff --git a/PortabilityLayer/PLIconWidget.h b/PortabilityLayer/PLIconWidget.h index 2239e2e..ae6dff9 100644 --- a/PortabilityLayer/PLIconWidget.h +++ b/PortabilityLayer/PLIconWidget.h @@ -17,6 +17,8 @@ namespace PortabilityLayer void DrawControl(DrawSurface *surface) override; + WidgetHandleState_t ProcessEvent(const TimeTaggedVOSEvent &evt) override; + private: THandle m_iconImage; THandle m_iconMask; diff --git a/PortabilityLayer/PLQDraw.cpp b/PortabilityLayer/PLQDraw.cpp index 931251e..85a6390 100644 --- a/PortabilityLayer/PLQDraw.cpp +++ b/PortabilityLayer/PLQDraw.cpp @@ -260,7 +260,7 @@ void SetPort(GrafPtr graf) void EndUpdate(WindowPtr graf) { - graf->m_graf.m_port.SetDirty(PortabilityLayer::QDPortDirtyFlag_Contents); + graf->m_surface.m_port.SetDirty(PortabilityLayer::QDPortDirtyFlag_Contents); } PLError_t GetIconSuite(Handle *suite, short resID, IconSuiteFlags flags) @@ -286,7 +286,7 @@ void SetRect(Rect *rect, short left, short top, short right, short bottom) void SetPortWindowPort(WindowPtr window) { PortabilityLayer::WindowManager *wm = PortabilityLayer::WindowManager::GetInstance(); - PortabilityLayer::QDManager::GetInstance()->SetPort(&window->m_graf.m_port); + PortabilityLayer::QDManager::GetInstance()->SetPort(&window->m_surface.m_port); } void SetPortDialogPort(Dialog *dialog) @@ -423,6 +423,8 @@ static void PlotLine(PortabilityLayer::QDState *qdState, DrawSurface *surface, c PL_NotYetImplemented(); return; } + + surface->m_port.SetDirty(PortabilityLayer::QDPortDirtyFlag_Contents); } void SetOrigin(int x, int y) @@ -604,6 +606,8 @@ void DrawSurface::DrawString(const Point &point, const PLPasStr &str) else DrawGlyph(qdState, pixMap, rect, penPos, rfont, chars[i]); } + + m_port.SetDirty(PortabilityLayer::QDPortDirtyFlag_Contents); } size_t DrawSurface::MeasureString(const PLPasStr &str) @@ -765,11 +769,14 @@ void DrawSurface::FillRect(const Rect &rect) PL_NotYetImplemented(); return; } + + m_port.SetDirty(PortabilityLayer::QDPortDirtyFlag_Contents); } void DrawSurface::FillRectWithPattern8x8(const Rect &rect, const uint8_t *pattern) { PL_NotYetImplemented(); + m_port.SetDirty(PortabilityLayer::QDPortDirtyFlag_Contents); } void DrawSurface::SetApplicationFont(int size, int variationFlags) @@ -992,6 +999,8 @@ void DrawSurface::FillScanlineMask(const PortabilityLayer::ScanlineMask *scanlin } } } + + m_port.SetDirty(PortabilityLayer::QDPortDirtyFlag_Contents); } @@ -1051,6 +1060,8 @@ void DrawSurface::FrameRect(const Rect &rect) edgeRect.top = edgeRect.bottom - 1; FillRect(edgeRect); } + + m_port.SetDirty(PortabilityLayer::QDPortDirtyFlag_Contents); } void DrawSurface::FrameRoundRect(const Rect &rect, int quadrantWidth, int quadrantHeight) @@ -1396,7 +1407,7 @@ BitMap *GetPortBitMapForCopyBits(DrawSurface *grafPtr) DrawSurface *GetWindowPort(WindowPtr window) { - return &window->m_graf; + return &window->m_surface; } diff --git a/PortabilityLayer/QDGraf.cpp b/PortabilityLayer/QDGraf.cpp index a19c3b3..4842040 100644 --- a/PortabilityLayer/QDGraf.cpp +++ b/PortabilityLayer/QDGraf.cpp @@ -4,6 +4,10 @@ #include "IGpDisplayDriver.h" #include "IGpDisplayDriverSurface.h" +DrawSurface::~DrawSurface() +{ +} + void DrawSurface::PushToDDSurface(IGpDisplayDriver *displayDriver) { const PixMap *pixMap = *m_port.GetPixMap(); diff --git a/PortabilityLayer/QDGraf.h b/PortabilityLayer/QDGraf.h index 243a764..6a00556 100644 --- a/PortabilityLayer/QDGraf.h +++ b/PortabilityLayer/QDGraf.h @@ -36,6 +36,8 @@ struct DrawSurface final { } + ~DrawSurface(); + PLError_t Init(const Rect &rect, GpPixelFormat_t pixelFormat) { if (PLError_t errorCode = m_port.Init(rect, pixelFormat)) diff --git a/PortabilityLayer/QDPort.cpp b/PortabilityLayer/QDPort.cpp index 7314e68..04b6056 100644 --- a/PortabilityLayer/QDPort.cpp +++ b/PortabilityLayer/QDPort.cpp @@ -3,6 +3,7 @@ #include "PLHandle.h" #include "MemoryManager.h" #include "MMHandleBlock.h" +#include "QDManager.h" #include "QDPixMap.h" #if GP_DEBUG_CONFIG @@ -32,6 +33,11 @@ namespace PortabilityLayer QDPort::~QDPort() { +#if GP_DEBUG_CONFIG + // Detach the port BEFORE destroying it!! + assert(PortabilityLayer::QDManager::GetInstance()->GetPort() != this); +#endif + DisposePixMap(); } diff --git a/PortabilityLayer/WindowManager.cpp b/PortabilityLayer/WindowManager.cpp index 2abda1b..895dc4a 100644 --- a/PortabilityLayer/WindowManager.cpp +++ b/PortabilityLayer/WindowManager.cpp @@ -100,7 +100,7 @@ namespace PortabilityLayer GpPixelFormat_t pixelFormat = PortabilityLayer::DisplayDeviceManager::GetInstance()->GetPixelFormat(); - if (int errorCode = m_graf.Init(adjustedBounds, pixelFormat)) + if (int errorCode = m_surface.Init(adjustedBounds, pixelFormat)) return false; return true; @@ -108,11 +108,11 @@ namespace PortabilityLayer bool WindowImpl::Resize(int width, int height) { - Rect rect = m_graf.m_port.GetRect(); + Rect rect = m_surface.m_port.GetRect(); rect.right = rect.left + width; rect.bottom = rect.top + height; - return m_graf.Resize(rect); + return m_surface.Resize(rect); } WindowImpl *WindowImpl::GetWindowAbove() const @@ -254,7 +254,7 @@ namespace PortabilityLayer WindowImpl *window = m_windowStackTop; while (window) { - const Rect windowRect = window->m_graf.m_port.GetRect(); + const Rect windowRect = window->m_surface.m_port.GetRect(); const int32_t localX = point.h - window->m_wmX; const int32_t localY = point.v - window->m_wmY; @@ -286,6 +286,9 @@ namespace PortabilityLayer DetachWindow(window); + if (PortabilityLayer::QDManager::GetInstance()->GetPort() == &windowImpl->m_surface.m_port) + PortabilityLayer::QDManager::GetInstance()->SetPort(nullptr); + windowImpl->~WindowImpl(); PortabilityLayer::MemoryManager::GetInstance()->Release(windowImpl); } @@ -341,7 +344,7 @@ namespace PortabilityLayer void WindowManagerImpl::RenderWindow(WindowImpl *window, IGpDisplayDriver *displayDriver) { - DrawSurface &graf = window->m_graf; + DrawSurface &graf = window->m_surface; graf.PushToDDSurface(displayDriver);