The reason you get the nil error is due to the getbottom and gettop etc functions returning a nil value due to the frame not being positioned in time or being reparented or the clearallpoints function is called. I worked past this so that I don't get that problem now.
Seerah worked past it by delaying the reparenting to allow blizz to do their stuff if I remember right.
I use the hooksecurefuncs to change what they do to what I want or if that doesn't work like the new WatchFrame_SetWidth function I just nullify it with the function end setting.
This is the parenting code I do during the ADDON_LOADED event
Code:
self:SetParent(nil);
self:SetParent(parent);
self:SetClampedToScreen( false );
I then resize and reposition during the VARIABLES_LOADED event to overrirde their automatic position and size settings.
First the Sizing
Code:
self:SetWidth( self:GetParent():GetWidth() - 30 );
self:SetHeight(self:GetParent():GetHeight() - 10 );
WATCHFRAME_MAXLINEWIDTH = self:GetWidth() - 10;
WATCHFRAME_EXPANDEDWIDTH = self:GetWidth();
WATCHFRAME_COLLAPSEDWIDTH = WatchFrameTitle:GetWidth() + 70;
Then the positioning. I have my watch frame reparented to a scroll frame so the setpoint here is relevant to that. But if I didn't I would set this to my chosen position. Because I call it after blizz does their positioning the user won't notice the difference.
Code:
self:SetAllPoints();
self:SetPoint( "TOPLEFT", 35, -5 );
self:SetPoint( "BOTTOMRIGHT", -5, 5 );
self.ClearAllPoints = function() end;
self.SetPoint = function() end;
self.SetAllPoints = function() end;
And then in PLAYER_LOGIN I show the frame.
And because my addon is an nUI friendly addon it disables nUI's control prior to any changes whatsoever.
This code though is still a work in progress and is only a part of my overrall code but it works pretty much as expected barring a couple of settings. I don't get any errors. Feel free to take a look at my last uploaded version.